Browse Source

Fix NAnt addin sample.

pull/297/head
Matt Ward 11 years ago
parent
commit
5d4cdedf8d
  1. 4
      samples/NAnt/NAnt.AddIn.Tests/CscNAntOutputTestFixture.cs
  2. 4
      samples/NAnt/NAnt.AddIn.Tests/FatalErrorNAntOutputTestFixture.cs
  3. 2
      samples/NAnt/NAnt.AddIn.Tests/InvalidXmlNAntOutputTestFixture.cs
  4. 3
      samples/NAnt/NAnt.AddIn.Tests/NAnt.AddIn.Tests.csproj
  5. 2
      samples/NAnt/NAnt.AddIn.Tests/NAntErrorAndWarningOutputTestFixture.cs
  6. 2
      samples/NAnt/NAnt.AddIn.Tests/NonFatalErrorNAntOutputTestFixture.cs
  7. 2
      samples/NAnt/NAnt.AddIn.Tests/ReadOnlyPropertyNAntOutputTestFixture.cs
  8. 2
      samples/NAnt/NAnt.AddIn.Tests/TargetDoesNotExistNAntOutputTestFixture.cs
  9. 2
      samples/NAnt/NAnt.AddIn.Tests/VBErrorNAntOutputTestFixture.cs
  10. 2
      samples/NAnt/NAnt.AddIn.sln
  11. 31
      samples/NAnt/NAnt.AddIn/NAnt.AddIn.csproj
  12. 9
      samples/NAnt/NAnt.AddIn/NAnt.addin
  13. 93
      samples/NAnt/NAnt.AddIn/Resources/NAntAddInOptionPanel.xfrm
  14. 2
      samples/NAnt/NAnt.AddIn/Src/AddInOptions.cs
  15. 59
      samples/NAnt/NAnt.AddIn/Src/Commands/AbstractRunNAntCommand.cs
  16. 91
      samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionPanel.cs
  17. 91
      samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionsView.xaml
  18. 95
      samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionsView.xaml.cs
  19. 33
      samples/NAnt/NAnt.AddIn/Src/Gui/NAntPadContent.cs
  20. 4
      samples/NAnt/NAnt.AddIn/Src/Gui/NAntPadTreeView.cs
  21. 78
      samples/NAnt/NAnt.AddIn/Src/NAntMessageViewCategoryTextWriter.cs
  22. 64
      samples/NAnt/NAnt.AddIn/Src/NAntOutputParser.cs
  23. 101
      samples/NAnt/NAnt.AddIn/Src/NAntRunner.cs
  24. 24
      samples/NAnt/NAnt.AddIn/Src/TaskCollection.cs

4
samples/NAnt/NAnt.AddIn.Tests/CscNAntOutputTestFixture.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.NAnt.Tests @@ -19,7 +19,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(3, tasks.Count, "Should be three tasks.");
// First task.
Task task = tasks[0];
SDTask task = tasks[0];
Assert.AreEqual("c:\\Projects\\dotnet\\Test\\corsavytest\\Foo.cs", task.FileName.ToString(), "Task filename is incorrect.");
Assert.AreEqual(34, task.Line, "Task line is incorrect.");
Assert.AreEqual(4, task.Column, "Task column is incorrect.");
@ -57,7 +57,7 @@ namespace ICSharpCode.NAnt.Tests @@ -57,7 +57,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(1, tasks.Count, "Should be three tasks.");
// First task.
Task task = tasks[0];
SDTask task = tasks[0];
Assert.AreEqual("c:\\Projects\\dotnet\\Test\\corsavytest\\Foo.cs", task.FileName.ToString(), "Task filename is incorrect.");
Assert.AreEqual(39, task.Line, "Task line is incorrect.");
Assert.AreEqual(12, task.Column, "Task column is incorrect.");

4
samples/NAnt/NAnt.AddIn.Tests/FatalErrorNAntOutputTestFixture.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.NAnt.Tests @@ -19,7 +19,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(2, tasks.Count, "Should be two tasks.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.IsNull(task.FileName, "Task filename should be blank.");
Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
@ -46,7 +46,7 @@ namespace ICSharpCode.NAnt.Tests @@ -46,7 +46,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(3, tasks.Count, "Should be three tasks.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.IsNull(task.FileName, "Task filename should be blank.");
Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");

2
samples/NAnt/NAnt.AddIn.Tests/InvalidXmlNAntOutputTestFixture.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.NAnt.Tests @@ -17,7 +17,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(1, tasks.Count, "Should be one task.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.AreEqual(@"C:\Projects\foo\foo.build", task.FileName.ToString(), "Task filename is incorrect.");
Assert.AreEqual(7, task.Line, "Task line is incorrect.");
Assert.AreEqual(5, task.Column, "Task column is incorrect.");

3
samples/NAnt/NAnt.AddIn.Tests/NAnt.AddIn.Tests.csproj

@ -21,7 +21,8 @@ @@ -21,7 +21,8 @@
<OutputPath>bin\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<Optimize>False</Optimize>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>

2
samples/NAnt/NAnt.AddIn.Tests/NAntErrorAndWarningOutputTestFixture.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.NAnt.Tests @@ -17,7 +17,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(2, tasks.Count, "Should be two tasks.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.AreEqual("C:\\Projects\\dotnet\\Test\\corsavytest\\corsavytest.build", task.FileName.ToString(), "Task filename is incorrect.");
Assert.AreEqual(TaskType.Warning, task.TaskType, "Should be a warning task.");
Assert.AreEqual(5, task.Line, "Incorrect line number.");

2
samples/NAnt/NAnt.AddIn.Tests/NonFatalErrorNAntOutputTestFixture.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.NAnt.Tests @@ -16,7 +16,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(1, tasks.Count, "Should be one task.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.AreEqual("C:\\Projects\\dotnet\\Corsavy\\SharpDevelop\\src\\StandardAddIn.include", task.FileName.ToString(), "Task filename is incorrect.");
Assert.AreEqual(TaskType.Error, task.TaskType, "Should be a warning task.");

2
samples/NAnt/NAnt.AddIn.Tests/ReadOnlyPropertyNAntOutputTestFixture.cs

@ -14,7 +14,7 @@ namespace ICSharpCode.NAnt.Tests @@ -14,7 +14,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(1, tasks.Count, "Should be one task.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.IsNull(task.FileName, "Task filename is incorrect.");
Assert.AreEqual(TaskType.Warning, task.TaskType, "Should be a warning task.");

2
samples/NAnt/NAnt.AddIn.Tests/TargetDoesNotExistNAntOutputTestFixture.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.NAnt.Tests @@ -17,7 +17,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(1, tasks.Count, "Should be one task.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.IsNull(task.FileName, "Should not have any filename information.");
Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
Assert.AreEqual(0, task.Line, "Should be line number 0");

2
samples/NAnt/NAnt.AddIn.Tests/VBErrorNAntOutputTestFixture.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.NAnt.Tests @@ -19,7 +19,7 @@ namespace ICSharpCode.NAnt.Tests
Assert.AreEqual(3, tasks.Count, "Should be three tasks.");
Task task = tasks[0];
SDTask task = tasks[0];
Assert.AreEqual("C:\\Projects\\dotnet\\test\\corsavyvbtest\\corsavyvbtest.build", task.FileName.ToString(), "Task filename is incorrect.");
Assert.AreEqual(TaskType.Warning, task.TaskType, "Should be a warning task.");

2
samples/NAnt/NAnt.AddIn.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.5571
# SharpDevelop 4.4
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAnt.AddIn", "NAnt.AddIn\NAnt.AddIn.csproj", "{1DB3CAD2-38E8-4C5E-8E1B-0E37B1A5C006}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAnt.AddIn.Tests", "NAnt.AddIn.Tests\NAnt.AddIn.Tests.csproj", "{13AB8351-39E5-4F9D-A59C-B30D60CF6B8C}"

31
samples/NAnt/NAnt.AddIn/NAnt.AddIn.csproj

@ -18,7 +18,8 @@ @@ -18,7 +18,8 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<DebugSymbols>true</DebugSymbols>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Optimize>False</Optimize>
@ -35,10 +36,18 @@ @@ -35,10 +36,18 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.Core">
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.Core.Presentation">
<HintPath>..\..\..\bin\ICSharpCode.Core.Presentation.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.Core.WinForms">
<HintPath>..\..\..\bin\ICSharpCode.Core.WinForms.dll</HintPath>
<Private>False</Private>
@ -47,6 +56,12 @@ @@ -47,6 +56,12 @@
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Widgets">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Widgets.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -54,14 +69,22 @@ @@ -54,14 +69,22 @@
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Src\AddInOptions.cs" />
<Compile Include="Src\Commands\RunSelectedNAntCleanTargetCommand.cs" />
<Compile Include="Src\Gui\NAntAddInOptionPanel.cs" />
<Compile Include="Src\Commands\RunNAntCommand.cs" />
<Compile Include="Src\Gui\NAntAddInOptionsView.xaml.cs">
<DependentUpon>NAntAddInOptionsView.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\NAntAddInException.cs" />
<Compile Include="Src\NAntMessageViewCategoryTextWriter.cs" />
<Compile Include="Src\NAntRunner.cs" />
<Compile Include="Src\NAntExitEventArgs.cs" />
<Compile Include="Src\Commands\RunNAntCleanTargetCommand.cs" />
@ -87,7 +110,6 @@ @@ -87,7 +110,6 @@
<None Include="Resources\BitmapResources.resources">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Resources\NAntAddInOptionPanel.xfrm" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<None Include="NAnt.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -104,5 +126,8 @@ @@ -104,5 +126,8 @@
<Folder Include="Src\Commands\" />
<Folder Include="Resources" />
</ItemGroup>
<ItemGroup>
<Page Include="Src\Gui\NAntAddInOptionsView.xaml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

9
samples/NAnt/NAnt.AddIn/NAnt.addin

@ -74,9 +74,10 @@ @@ -74,9 +74,10 @@
<!-- Options panel -->
<Path name="/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id="NAntAddInOptionPanel"
label="NAnt"
class="ICSharpCode.NAnt.Gui.NAntAddInOptionPanel"/>
<OptionPanel
id="NAntAddInOptionPanel"
label="NAnt"
class="ICSharpCode.NAnt.Gui.NAntAddInOptionsView"/>
</Path>
<!-- NAnt pad -->
@ -160,7 +161,7 @@ @@ -160,7 +161,7 @@
<!-- NAnt templates -->
<Path name="/SharpDevelop/BackendBindings/Templates">
<Directory id="NAnt" path="./Templates"/>
<TemplateFile id="NAnt" path="./Templates"/>
</Path>
<!-- Bitmap resources -->

93
samples/NAnt/NAnt.AddIn/Resources/NAntAddInOptionPanel.xfrm

@ -1,93 +0,0 @@ @@ -1,93 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="NAntAddInOptionPanel" />
<ClientSize value="{Width=464, Height=344}" />
<Controls>
<System.Windows.Forms.GroupBox>
<Name value="nantConfigurationGroupBox" />
<Location value="{X=3,Y=3}" />
<Text value="NAnt Configuration" />
<Size value="{Width=448, Height=192}" />
<TabIndex value="2" />
<Anchor value="Top, Left, Right" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="debugModeCheckBox" />
<CheckAlign value="MiddleRight" />
<Location value="{X=8,Y=160}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Text value="&amp;Debug" />
<TabIndex value="9" />
<Size value="{Width=120, Height=24}" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="quietCheckBox" />
<CheckAlign value="MiddleRight" />
<Location value="{X=8,Y=88}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Text value="&amp;Quiet" />
<TabIndex value="6" />
<Size value="{Width=120, Height=24}" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="verboseCheckBox" />
<CheckAlign value="MiddleRight" />
<Location value="{X=8,Y=136}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Text value="Ver&amp;bose" />
<TabIndex value="8" />
<Size value="{Width=120, Height=24}" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="showLogoCheckBox" />
<CheckAlign value="MiddleRight" />
<Location value="{X=8,Y=112}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Text value="Show &amp;Logo" />
<TabIndex value="7" />
<Size value="{Width=120, Height=24}" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.Button>
<Name value="browseButton" />
<Location value="{X=408,Y=36}" />
<Text value="..." />
<Size value="{Width=32, Height=23}" />
<Anchor value="Top, Right" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<TabIndex value="3" />
</System.Windows.Forms.Button>
<System.Windows.Forms.TextBox>
<Name value="argumentsTextBox" />
<TabIndex value="5" />
<Anchor value="Top, Left, Right" />
<Size value="{Width=328, Height=21}" />
<Location value="{X=112,Y=64}" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="nantArgumentsLabel" />
<Location value="{X=8,Y=64}" />
<Text value="&amp;Arguments" />
<TextAlign value="MiddleLeft" />
<Size value="{Width=64, Height=16}" />
<TabIndex value="4" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="nantCommandTextBox" />
<TabIndex value="2" />
<Anchor value="Top, Left, Right" />
<Size value="{Width=288, Height=21}" />
<Location value="{X=112,Y=36}" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="nantCommandLabel" />
<Location value="{X=8,Y=34}" />
<Text value="&amp;Command" />
<TextAlign value="MiddleLeft" />
<Size value="{Width=56, Height=16}" />
<TabIndex value="1" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

2
samples/NAnt/NAnt.AddIn/Src/AddInOptions.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.NAnt @@ -55,7 +55,7 @@ namespace ICSharpCode.NAnt
static AddInOptions()
{
properties = PropertyService.Get(OptionsProperty, new Properties());
properties = PropertyService.NestedProperties(OptionsProperty);
}
static Properties Properties {

59
samples/NAnt/NAnt.AddIn/Src/Commands/AbstractRunNAntCommand.cs

@ -35,6 +35,7 @@ using ICSharpCode.SharpDevelop; @@ -35,6 +35,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Util;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.NAnt.Commands
{
@ -64,7 +65,6 @@ namespace ICSharpCode.NAnt.Commands @@ -64,7 +65,6 @@ namespace ICSharpCode.NAnt.Commands
if (runner == null) {
runner = NAntRunnerSingleton.Runner;
runner.NAntExited += new NAntExitEventHandler(NAntExited);
runner.OutputLineReceived += new LineReceivedEventHandler(OutputLineReceived);
}
}
@ -79,7 +79,7 @@ namespace ICSharpCode.NAnt.Commands @@ -79,7 +79,7 @@ namespace ICSharpCode.NAnt.Commands
IProject project = ProjectService.CurrentProject;
if (project != null) {
if (String.Compare(project.ActiveConfiguration, "debug", true) == 0) {
if (String.Compare(project.ActiveConfiguration.Configuration, "debug", true) == 0) {
isDebug = true;
}
}
@ -114,13 +114,13 @@ namespace ICSharpCode.NAnt.Commands @@ -114,13 +114,13 @@ namespace ICSharpCode.NAnt.Commands
string projectFileName = project.FileName;
string buildFileName = Path.Combine(Path.GetDirectoryName(projectFileName), DefaultBuildFileName);
if (project.IsFileInProject(buildFileName)) {
if (project.IsFileInProject(new FileName(buildFileName))) {
fileName = buildFileName;
} else {
// Look for <projectname>.build
buildFileName = Path.ChangeExtension(projectFileName, NAntBuildFileExtension);
if (project.IsFileInProject(buildFileName)) {
if (project.IsFileInProject(new FileName(buildFileName))) {
fileName = buildFileName;
} else {
@ -194,7 +194,6 @@ namespace ICSharpCode.NAnt.Commands @@ -194,7 +194,6 @@ namespace ICSharpCode.NAnt.Commands
}
CategoryWriteLine(StringParser.Parse("Running NAnt."));
CategoryWriteLine(runner.CommandLine);
try {
runner.Start();
@ -214,9 +213,8 @@ namespace ICSharpCode.NAnt.Commands @@ -214,9 +213,8 @@ namespace ICSharpCode.NAnt.Commands
{
string arguments = String.Empty;
IWorkbench Workbench = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench;
PadDescriptor padDescriptor = Workbench.GetPad(typeof(NAntPadContent));
PadDescriptor padDescriptor = SD.Workbench.GetPad(typeof(NAntPadContent));
if (padDescriptor != null && padDescriptor.PadContent != null) {
arguments = ((NAntPadContent)padDescriptor.PadContent).Arguments;
}
@ -243,20 +241,17 @@ namespace ICSharpCode.NAnt.Commands @@ -243,20 +241,17 @@ namespace ICSharpCode.NAnt.Commands
}
}
/// <summary>
/// Gets the NAnt message view output window.
/// </summary>
MessageViewCategory Category {
get {
if (category == null) {
category = new MessageViewCategory("NAnt");
CompilerMessageView cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).PadContent;
cmv.AddCategory(category);
}
return category;
}
}
/// <summary>
/// Gets the NAnt message view output window.
/// </summary>
public static MessageViewCategory Category {
get {
if (category == null) {
MessageViewCategory.Create(ref category, "NAnt");
}
return category;
}
}
/// <summary>
/// Writes a line of text to the output window.
@ -271,7 +266,7 @@ namespace ICSharpCode.NAnt.Commands @@ -271,7 +266,7 @@ namespace ICSharpCode.NAnt.Commands
/// </summary>
void ShowOutputPad()
{
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
SD.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
}
/// <summary>
@ -308,23 +303,17 @@ namespace ICSharpCode.NAnt.Commands @@ -308,23 +303,17 @@ namespace ICSharpCode.NAnt.Commands
// Update task list.
TaskCollection tasks = NAntOutputParser.Parse(outputText);
foreach (Task task in tasks) {
WorkbenchSingleton.SafeThreadAsyncCall(TaskService.Add, task);
foreach (SDTask task in tasks) {
SD.MainThread.InvokeAsyncAndForget(() => TaskService.Add(task));
}
// Bring task list to front.
if (tasks.Count > 0 && ErrorListPad.ShowAfterBuild) {
IWorkbench workbench = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench;
PadDescriptor padDescriptor = workbench.GetPad(typeof(ErrorListPad));
if (tasks.Count > 0 && ErrorListPad.ShowAfterBuild) {
PadDescriptor padDescriptor = SD.Workbench.GetPad(typeof(ErrorListPad));
if (padDescriptor != null) {
WorkbenchSingleton.SafeThreadAsyncCall(padDescriptor.BringPadToFront);
SD.MainThread.InvokeAsync(padDescriptor.BringPadToFront);
}
}
}
void OutputLineReceived(object sender, LineReceivedEventArgs e)
{
CategoryWriteLine(e.Line);
}
}
string GetNAntNotFoundErrorMessage(string fileName)

91
samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionPanel.cs

@ -1,91 +0,0 @@ @@ -1,91 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2007, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
namespace ICSharpCode.NAnt.Gui
{
/// <summary>
/// Options panel for the NAnt add-in.
/// </summary>
public class NAntAddInOptionPanel : XmlFormsOptionPanel
{
static readonly string commandTextBoxName = "nantCommandTextBox";
static readonly string argumentsTextBoxName = "argumentsTextBox";
static readonly string verboseCheckBoxName = "verboseCheckBox";
static readonly string browseButtonName = "browseButton";
static readonly string showLogoCheckBoxName = "showLogoCheckBox";
static readonly string quietCheckBoxName = "quietCheckBox";
static readonly string debugModeCheckBoxName = "debugModeCheckBox";
public override void LoadPanelContents()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.NAnt.Resources.NAntAddInOptionPanel.xfrm"));
ControlDictionary[commandTextBoxName].Text = AddInOptions.NAntFileName;
ControlDictionary[argumentsTextBoxName].Text = AddInOptions.NAntArguments;
((CheckBox)ControlDictionary[verboseCheckBoxName]).Checked = AddInOptions.Verbose;
((CheckBox)ControlDictionary[showLogoCheckBoxName]).Checked = AddInOptions.ShowLogo;
((CheckBox)ControlDictionary[quietCheckBoxName]).Checked = AddInOptions.Quiet;
((CheckBox)ControlDictionary[debugModeCheckBoxName]).Checked = AddInOptions.DebugMode;
ControlDictionary[browseButtonName].Click += new EventHandler(OnBrowse);
}
public override bool StorePanelContents()
{
AddInOptions.NAntFileName = ControlDictionary[commandTextBoxName].Text;
AddInOptions.NAntArguments = ControlDictionary[argumentsTextBoxName].Text;
AddInOptions.Verbose = ((CheckBox)ControlDictionary[verboseCheckBoxName]).Checked;
AddInOptions.ShowLogo = ((CheckBox)ControlDictionary[showLogoCheckBoxName]).Checked;
AddInOptions.Quiet = ((CheckBox)ControlDictionary[quietCheckBoxName]).Checked;
AddInOptions.DebugMode = ((CheckBox)ControlDictionary[debugModeCheckBoxName]).Checked;
return true;
}
/// <summary>
/// Allows the user to browse for the NAnt executable.
/// </summary>
void OnBrowse(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog()) {
openFileDialog.CheckFileExists = true;
openFileDialog.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
if (openFileDialog.ShowDialog() == DialogResult.OK) {
ControlDictionary[commandTextBoxName].Text = openFileDialog.FileName;
}
}
}
}
}

91
samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionsView.xaml

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
<gui:OptionPanel
x:Class="ICSharpCode.NAnt.Gui.NAntAddInOptionsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:nant="clr-namespace:ICSharpCode.NAnt"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<GroupBox
Header="NAnt Configuration"
Padding="4">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Content="_Command:"/>
<TextBox
Grid.Column="1"
Margin="2"
Text="{Binding NAntFileName}"/>
<Button
Grid.Column="2"
Content="..."
Command="{Binding BrowseCommand}"
Padding="4, 0"
Margin="2"/>
<Label
Grid.Row="1"
Content="_Arguments:"/>
<TextBox
Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="1"
Margin="2"
Text="{Binding NAntArguments}"/>
<Label
Grid.Row="2"
Content="_Quiet:"/>
<CheckBox
Grid.Row="2"
Grid.ColumnSpan="2"
Grid.Column="1"
Margin="2"
IsChecked="{Binding Quiet}"/>
<Label
Grid.Row="3"
Content="Show _Logo:"/>
<CheckBox
Grid.Row="3"
Grid.ColumnSpan="2"
Grid.Column="1"
Margin="2"
IsChecked="{Binding ShowLogo}"/>
<Label
Grid.Row="4"
Content="Ver_bose:"/>
<CheckBox
Grid.Row="4"
Grid.ColumnSpan="2"
Grid.Column="1"
Margin="2"
IsChecked="{Binding Verbose}"/>
<Label
Grid.Row="5"
Content="_Debug:"/>
<CheckBox
Grid.Row="5"
Grid.ColumnSpan="2"
Grid.Column="1"
Margin="2"
IsChecked="{Binding Debug}"/>
</Grid>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

95
samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionsView.xaml.cs

@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
// SharpDevelop samples
// Copyright (c) 2014, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.ComponentModel;
using System.Windows.Input;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Widgets;
using Microsoft.Win32;
namespace ICSharpCode.NAnt.Gui
{
public partial class NAntAddInOptionsView : OptionPanel, INotifyPropertyChanged
{
string nantFileName;
public NAntAddInOptionsView()
{
InitializeComponent();
this.nantFileName = AddInOptions.NAntFileName;
this.NAntArguments = AddInOptions.NAntArguments;
this.Quiet = AddInOptions.Quiet;
this.ShowLogo = AddInOptions.ShowLogo;
this.Debug = AddInOptions.DebugMode;
this.Verbose = AddInOptions.Verbose;
this.BrowseCommand = new RelayCommand(Browse);
this.DataContext = this;
}
public ICommand BrowseCommand { get; private set; }
public string NAntFileName {
get { return nantFileName; }
set {
nantFileName = value;
base.RaisePropertyChanged(() => NAntFileName);
}
}
public string NAntArguments { get; set; }
public bool Quiet { get; set; }
public bool Verbose { get; set; }
public bool ShowLogo { get; set; }
public bool Debug { get; set; }
void Browse()
{
var dialog = new OpenFileDialog();
dialog.DefaultExt = ".exe";
dialog.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
if (dialog.ShowDialog() == true) {
NAntFileName = dialog.FileName;
}
}
public override bool SaveOptions()
{
AddInOptions.NAntFileName = nantFileName;
AddInOptions.NAntArguments = NAntArguments;
AddInOptions.Quiet = Quiet;
AddInOptions.DebugMode = Debug;
AddInOptions.Verbose = Verbose;
AddInOptions.ShowLogo = ShowLogo;
return true;
}
}
}

33
samples/NAnt/NAnt.AddIn/Src/Gui/NAntPadContent.cs

@ -26,12 +26,16 @@ @@ -26,12 +26,16 @@
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.NAnt.Gui
{
@ -77,8 +81,8 @@ namespace ICSharpCode.NAnt.Gui @@ -77,8 +81,8 @@ namespace ICSharpCode.NAnt.Gui
ProjectService.SolutionClosed += SolutionClosed;
ProjectService.ProjectItemRemoved += ProjectItemRemoved;
ProjectService.ProjectItemAdded += ProjectItemAdded;
WorkbenchSingleton.Workbench.ViewOpened += WorkbenchViewOpened;
WorkbenchSingleton.Workbench.ViewClosed += WorkbenchViewClosed;
SD.Workbench.ViewOpened += WorkbenchViewOpened;
SD.Workbench.ViewClosed += WorkbenchViewClosed;
FileService.FileRenamed += FileRenamed;
FileService.FileRemoved += FileRemoved;
FileUtility.FileSaved += FileSaved;
@ -103,7 +107,7 @@ namespace ICSharpCode.NAnt.Gui @@ -103,7 +107,7 @@ namespace ICSharpCode.NAnt.Gui
public static NAntPadContent Instance {
get {
PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(typeof(NAntPadContent));
PadDescriptor descriptor = SD.Workbench.GetPad(typeof(NAntPadContent));
return (NAntPadContent)descriptor.PadContent;
}
}
@ -115,11 +119,11 @@ namespace ICSharpCode.NAnt.Gui @@ -115,11 +119,11 @@ namespace ICSharpCode.NAnt.Gui
{
treeView.Clear();
Solution solution = ProjectService.OpenSolution;
ISolution solution = ProjectService.OpenSolution;
if (solution != null) {
treeView.AddSolution(solution);
}
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
foreach (IViewContent view in SD.Workbench.ViewContentCollection) {
if (IsStandaloneNAntBuildFile(view.PrimaryFileName)) {
treeView.AddBuildFile(String.Empty, view.PrimaryFileName);
}
@ -172,8 +176,8 @@ namespace ICSharpCode.NAnt.Gui @@ -172,8 +176,8 @@ namespace ICSharpCode.NAnt.Gui
ProjectService.SolutionClosed -= SolutionClosed;
ProjectService.ProjectItemRemoved -= ProjectItemRemoved;
ProjectService.ProjectItemAdded -= ProjectItemAdded;
WorkbenchSingleton.Workbench.ViewOpened -= WorkbenchViewOpened;
WorkbenchSingleton.Workbench.ViewClosed -= WorkbenchViewClosed;
SD.Workbench.ViewOpened -= WorkbenchViewOpened;
SD.Workbench.ViewClosed -= WorkbenchViewClosed;
FileService.FileRenamed -= FileRenamed;
FileService.FileRemoved -= FileRemoved;
FileUtility.FileSaved -= FileSaved;
@ -200,7 +204,7 @@ namespace ICSharpCode.NAnt.Gui @@ -200,7 +204,7 @@ namespace ICSharpCode.NAnt.Gui
AddSolutionToPad(e.Solution);
}
void AddSolutionToPad(Solution solution)
void AddSolutionToPad(ISolution solution)
{
if (solution != null) {
treeView.AddSolution(solution);
@ -230,7 +234,12 @@ namespace ICSharpCode.NAnt.Gui @@ -230,7 +234,12 @@ namespace ICSharpCode.NAnt.Gui
void AddBuildFile(string fileName)
{
if (ProjectService.OpenSolution == null) return;
IProject project = ProjectService.OpenSolution.FindProjectContainingFile(fileName);
IProject project = ProjectService
.OpenSolution
.Projects
.FirstOrDefault(p => p.IsFileInProject(new FileName(fileName)));
if (project != null) {
treeView.AddBuildFile(project.Name, fileName);
}
@ -280,10 +289,10 @@ namespace ICSharpCode.NAnt.Gui @@ -280,10 +289,10 @@ namespace ICSharpCode.NAnt.Gui
bool IsInProject(string fileName)
{
Solution solution = ProjectService.OpenSolution;
ISolution solution = ProjectService.OpenSolution;
if (solution != null) {
foreach (IProject project in solution.Projects) {
if (project.IsFileInProject(fileName)) {
if (project.IsFileInProject(new FileName(fileName))) {
return true;
}
}
@ -319,7 +328,7 @@ namespace ICSharpCode.NAnt.Gui @@ -319,7 +328,7 @@ namespace ICSharpCode.NAnt.Gui
void NAntExited(object sender, NAntExitEventArgs e)
{
WorkbenchSingleton.SafeThreadAsyncCall(UpdateToolbar);
SD.MainThread.InvokeAsyncAndForget(UpdateToolbar);
}
}
}

4
samples/NAnt/NAnt.AddIn/Src/Gui/NAntPadTreeView.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.NAnt.Gui @@ -61,7 +61,7 @@ namespace ICSharpCode.NAnt.Gui
/// </summary>
NAntPadTreeViewState state = NAntPadTreeViewState.Nothing;
delegate void AddSolutionInvoker(Solution solution);
delegate void AddSolutionInvoker(ISolution solution);
public NAntPadTreeView()
{
@ -104,7 +104,7 @@ namespace ICSharpCode.NAnt.Gui @@ -104,7 +104,7 @@ namespace ICSharpCode.NAnt.Gui
/// in all the solution's subprojects.
/// </summary>
/// <param name="solution">A solution containing projects.</param>
public void AddSolution(Solution solution)
public void AddSolution(ISolution solution)
{
if (InvokeRequired) {
AddSolutionInvoker invoker = new AddSolutionInvoker(AddSolution);

78
samples/NAnt/NAnt.AddIn/Src/NAntMessageViewCategoryTextWriter.cs

@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
// SharpDevelop samples
// Copyright (c) 2014, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.IO;
using System.Text;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.NAnt
{
/// <summary>
/// TextWriter implementation that writes into a MessageViewCategory.
/// </summary>
public class NAntMessageViewCategoryTextWriter : TextWriter
{
readonly IOutputCategory target;
StringBuilder output;
public NAntMessageViewCategoryTextWriter(IOutputCategory target)
{
this.target = target;
this.output = new StringBuilder();
}
public override Encoding Encoding {
get { return Encoding.Unicode; }
}
public override void Write(char value)
{
target.AppendText(value.ToString());
output.Append(value.ToString());
}
public override void Write(string value)
{
if (value != null) {
target.AppendText(value);
output.Append(value);
}
}
public override void Write(char[] buffer, int index, int count)
{
string text = new string(buffer, index, count);
target.AppendText(text);
output.Append(text);
}
public string Output {
get { return output.ToString(); }
}
}
}

64
samples/NAnt/NAnt.AddIn/Src/NAntOutputParser.cs

@ -56,7 +56,7 @@ namespace ICSharpCode.NAnt @@ -56,7 +56,7 @@ namespace ICSharpCode.NAnt
output = output.Replace("\r\n", "\n");
// Look for errors on a per line basis.
Task task = null;
SDTask task = null;
StringReader reader = new StringReader(output);
while (reader.Peek() != -1) {
@ -93,9 +93,9 @@ namespace ICSharpCode.NAnt @@ -93,9 +93,9 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">A NAnt output line.</param>
/// <returns>A <see cref="Task"/> if the line contains an error or
/// a warning; otherwise <see langword="null"/>.</returns>
static Task ParseLine(string textLine)
static SDTask ParseLine(string textLine)
{
Task task = null;
SDTask task = null;
task = ParseCSharpError(textLine);
@ -128,9 +128,9 @@ namespace ICSharpCode.NAnt @@ -128,9 +128,9 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseCSharpError(string textLine)
static SDTask ParseCSharpError(string textLine)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*),([\d]*)\): (.*?) (.*?): (.*?)$");
if (match.Success) {
try {
@ -142,7 +142,7 @@ namespace ICSharpCode.NAnt @@ -142,7 +142,7 @@ namespace ICSharpCode.NAnt
if (String.Compare(match.Groups[4].Value, "warning", true) == 0) {
taskType = TaskType.Warning;
}
task = new Task(FileName.Create(match.Groups[1].Value), description, col, line, taskType);
task = new SDTask(FileName.Create(match.Groups[1].Value), description, col, line, taskType);
} catch (Exception) {
// Ignore.
}
@ -158,9 +158,9 @@ namespace ICSharpCode.NAnt @@ -158,9 +158,9 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseNAntError(string textLine)
static SDTask ParseNAntError(string textLine)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*),([\d]*)\): (.*?)$");
if (match.Success) {
@ -168,7 +168,7 @@ namespace ICSharpCode.NAnt @@ -168,7 +168,7 @@ namespace ICSharpCode.NAnt
int line = Convert.ToInt32(match.Groups[2].Value);
int col = Convert.ToInt32(match.Groups[3].Value);
task = new Task(FileName.Create(match.Groups[1].Value), match.Groups[4].Value, col, line, TaskType.Warning);
task = new SDTask(FileName.Create(match.Groups[1].Value), match.Groups[4].Value, col, line, TaskType.Warning);
} catch (Exception) {
// Ignore.
}
@ -186,9 +186,9 @@ namespace ICSharpCode.NAnt @@ -186,9 +186,9 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseVBError(string textLine)
static SDTask ParseVBError(string textLine)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*)\) : (.*?) (.*?): (.*?)$");
if (match.Success) {
try {
@ -199,7 +199,7 @@ namespace ICSharpCode.NAnt @@ -199,7 +199,7 @@ namespace ICSharpCode.NAnt
if (String.Compare(match.Groups[3].Value, "warning", true) == 0) {
taskType = TaskType.Warning;
}
task = new Task(FileName.Create(match.Groups[1].Value), description, 0, line, taskType);
task = new SDTask(FileName.Create(match.Groups[1].Value), description, 0, line, taskType);
} catch (Exception) {
// Ignore.
}
@ -215,19 +215,19 @@ namespace ICSharpCode.NAnt @@ -215,19 +215,19 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseFatalError(string textLine)
static SDTask ParseFatalError(string textLine)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(textLine, @"^.*?(fatal error .*?: .*?)$");
if (match.Success) {
try {
task = new Task(null, match.Groups[1].Value, 0, 0, TaskType.Error);
task = new SDTask(null, match.Groups[1].Value, 0, 0, TaskType.Error);
} catch (Exception) {
// Ignore.
}
}
return task;
return task;
}
/// <summary>
@ -237,21 +237,21 @@ namespace ICSharpCode.NAnt @@ -237,21 +237,21 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseVBFatalError(string textLine)
static SDTask ParseVBFatalError(string textLine)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(textLine, @"^.*?vbc : error (.*?): (.*?)$");
if (match.Success) {
try {
string description = String.Concat(match.Groups[2].Value, " (", match.Groups[1].Value, ")");
task = new Task(null, description, 0, 0, TaskType.Error);
task = new SDTask(null, description, 0, 0, TaskType.Error);
} catch (Exception) {
// Ignore.
}
}
return task;
}
return task;
}
/// <summary>
/// Looks for errors of the form
@ -260,19 +260,19 @@ namespace ICSharpCode.NAnt @@ -260,19 +260,19 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if a warning was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseNAntWarning(string textLine)
static SDTask ParseNAntWarning(string textLine)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(textLine, @"^.*?(Read-only property .*? cannot be overwritten.)$");
if (match.Success) {
try {
task = new Task(null, match.Groups[1].Value, 0, 0, TaskType.Warning);
task = new SDTask(null, match.Groups[1].Value, 0, 0, TaskType.Warning);
} catch (Exception) {
// Ignore.
}
}
return task;
return task;
}
/// <summary>
@ -284,9 +284,9 @@ namespace ICSharpCode.NAnt @@ -284,9 +284,9 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseNAntBuildFailedError(string output)
static SDTask ParseNAntBuildFailedError(string output)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(output, @"^BUILD FAILED.*?$\n^$\n^(\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^(.*?)$\n^(.*?)$", RegexOptions.Multiline);
@ -296,14 +296,14 @@ namespace ICSharpCode.NAnt @@ -296,14 +296,14 @@ namespace ICSharpCode.NAnt
int line = Convert.ToInt32(match.Groups[2].Value);
int col = Convert.ToInt32(match.Groups[3].Value);
string description = String.Concat(match.Groups[4], Environment.NewLine, match.Groups[5]);
task = new Task(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error);
task = new SDTask(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error);
} catch(Exception) { };
} else {
match = Regex.Match(output, @"^BUILD FAILED$\n^$\n^(.*?)$", RegexOptions.Multiline);
if (match.Success) {
task = new Task(null, match.Groups[1].Value, 0, 0, TaskType.Error);
task = new SDTask(null, match.Groups[1].Value, 0, 0, TaskType.Error);
}
}
@ -318,9 +318,9 @@ namespace ICSharpCode.NAnt @@ -318,9 +318,9 @@ namespace ICSharpCode.NAnt
/// <param name="textLine">The line of text to parse.</param>
/// <returns>A <see cref="Task"/> if an error was found; otherwise
/// <see langword="null"/>.</returns>
static Task ParseMultilineBuildError(string output)
static SDTask ParseMultilineBuildError(string output)
{
Task task = null;
SDTask task = null;
Match match = Regex.Match(output, @"^.*?\[delete\] (\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^.*?\[delete\] (.*?)$", RegexOptions.Multiline);
@ -330,7 +330,7 @@ namespace ICSharpCode.NAnt @@ -330,7 +330,7 @@ namespace ICSharpCode.NAnt
int line = Convert.ToInt32(match.Groups[2].Value);
int col = Convert.ToInt32(match.Groups[3].Value);
string description = String.Concat(match.Groups[4]);
task = new Task(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error);
task = new SDTask(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error);
} catch(Exception) { };
}

101
samples/NAnt/NAnt.AddIn/Src/NAntRunner.cs

@ -26,8 +26,14 @@ @@ -26,8 +26,14 @@
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using ICSharpCode.SharpDevelop.Util;
using System.Threading.Tasks;
using ICSharpCode.Core;
using ICSharpCode.NAnt.Commands;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.NAnt
{
@ -62,11 +68,6 @@ namespace ICSharpCode.NAnt @@ -62,11 +68,6 @@ namespace ICSharpCode.NAnt
/// </summary>
public event EventHandler NAntStopped;
/// <summary>
/// Triggered when an output line is received from NAnt.
/// </summary>
public event LineReceivedEventHandler OutputLineReceived;
public NAntRunner()
{
}
@ -167,16 +168,6 @@ namespace ICSharpCode.NAnt @@ -167,16 +168,6 @@ namespace ICSharpCode.NAnt
set {
debugMode = value;
}
}
/// <summary>
/// Gets the full NAnt command line that will be used by
/// the runner.
/// </summary>
public string CommandLine {
get {
return String.Concat(nantFileName, " ", GetArguments());
}
}
/// <summary>
@ -187,7 +178,7 @@ namespace ICSharpCode.NAnt @@ -187,7 +178,7 @@ namespace ICSharpCode.NAnt
bool isRunning = false;
if (runner != null) {
isRunning = runner.IsRunning;
isRunning = !runner.HasExited;
}
return isRunning;
@ -195,19 +186,35 @@ namespace ICSharpCode.NAnt @@ -195,19 +186,35 @@ namespace ICSharpCode.NAnt
}
public void Start()
{
string arguments = GetArguments();
{
RunNAnt().FireAndForget();
}
async Task<int> RunNAnt()
{
string[] arguments = GetArguments();
runner = new ProcessRunner();
runner.WorkingDirectory = workingDirectory;
runner.ProcessExited += new EventHandler(ProcessExited);
if (OutputLineReceived != null) {
runner.OutputLineReceived += new LineReceivedEventHandler(OnOutputLineReceived);
runner.ErrorLineReceived += new LineReceivedEventHandler(OnOutputLineReceived);
runner.RedirectStandardOutputAndErrorToSingleStream = true;
runner.Start(nantFileName, arguments);
AbstractRunNAntCommand.Category.AppendLine(runner.CommandLine);
var writer = new NAntMessageViewCategoryTextWriter(AbstractRunNAntCommand.Category);
using (TextReader reader = runner.OpenStandardOutputReader()) {
await reader.CopyToAsync(writer);
}
runner.Start(nantFileName, arguments);
OnNAntStarted();
await runner.WaitForExitAsync();
AbstractRunNAntCommand.Category.AppendLine(StringParser.Parse("${res:XML.MainMenu.ToolMenu.ExternalTools.ExitedWithCode} " + runner.ExitCode));
OnNAntExited(writer.Output, String.Empty, runner.ExitCode);
return runner.ExitCode;
}
/// <summary>
@ -242,63 +249,41 @@ namespace ICSharpCode.NAnt @@ -242,63 +249,41 @@ namespace ICSharpCode.NAnt
}
}
/// <summary>
/// Raises the <see cref="OutputLineReceived"/> event.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The event arguments.</param>
protected void OnOutputLineReceived(object sender, LineReceivedEventArgs e)
{
if (OutputLineReceived != null) {
OutputLineReceived(this, e);
}
}
/// <summary>
/// Handles the NAnt process exit event.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The event arguments.</param>
void ProcessExited(object sender, EventArgs e)
{
ProcessRunner runner = (ProcessRunner)sender;
OnNAntExited(runner.StandardOutput, runner.StandardError, runner.ExitCode);
}
/// <summary>
/// Adds extra command line arguments to those specified
/// by the user in the <see cref="Arguments"/> string.
/// </summary>
/// <returns></returns>
string GetArguments()
string[] GetArguments()
{
StringBuilder nantArguments = new StringBuilder();
var nantArguments = new List<string>();
if (!showLogo) {
nantArguments.Append("-nologo ");
nantArguments.Add("-nologo");
}
if (verbose) {
nantArguments.Append("-v ");
nantArguments.Add("-v");
}
if (quiet) {
nantArguments.Append("-q ");
nantArguments.Add("-q");
}
if (debugMode) {
nantArguments.Append("-debug ");
nantArguments.Add("-debug");
}
if (buildFileName.Length > 0) {
nantArguments.Append("-buildfile:");
nantArguments.Append(buildFileName);
nantArguments.Append(" ");
nantArguments.Add(String.Format("-buildfile:{0}", buildFileName));
}
nantArguments.Append(this.arguments);
string[] extraArguments = this.arguments.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
if (extraArguments.Length > 0) {
nantArguments.AddRange(extraArguments);
}
return nantArguments.ToString();
return nantArguments.ToArray();
}
}
}

24
samples/NAnt/NAnt.AddIn/Src/TaskCollection.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.NAnt @@ -70,7 +70,7 @@ namespace ICSharpCode.NAnt
/// <param name='val'>
/// A array of <see cref='Task'/> objects with which to intialize the collection
/// </param>
public TaskCollection(Task[] val)
public TaskCollection(SDTask[] val)
{
this.AddRange(val);
}
@ -83,9 +83,9 @@ namespace ICSharpCode.NAnt @@ -83,9 +83,9 @@ namespace ICSharpCode.NAnt
/// <para> The entry at the specified index of the collection.</para>
/// </value>
/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
public Task this[int index] {
public SDTask this[int index] {
get {
return ((Task)(List[index]));
return ((SDTask)(List[index]));
}
set {
List[index] = value;
@ -101,7 +101,7 @@ namespace ICSharpCode.NAnt @@ -101,7 +101,7 @@ namespace ICSharpCode.NAnt
/// <para>The index at which the new element was inserted.</para>
/// </returns>
/// <seealso cref='TaskCollection.AddRange'/>
public int Add(Task val)
public int Add(SDTask val)
{
return List.Add(val);
}
@ -116,7 +116,7 @@ namespace ICSharpCode.NAnt @@ -116,7 +116,7 @@ namespace ICSharpCode.NAnt
/// <para>None.</para>
/// </returns>
/// <seealso cref='TaskCollection.Add'/>
public void AddRange(Task[] val)
public void AddRange(SDTask[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
@ -153,7 +153,7 @@ namespace ICSharpCode.NAnt @@ -153,7 +153,7 @@ namespace ICSharpCode.NAnt
/// otherwise, <see langword='false'/>.</para>
/// </returns>
/// <seealso cref='TaskCollection.IndexOf'/>
public bool Contains(Task val)
public bool Contains(SDTask val)
{
return List.Contains(val);
}
@ -171,7 +171,7 @@ namespace ICSharpCode.NAnt @@ -171,7 +171,7 @@ namespace ICSharpCode.NAnt
/// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
/// <seealso cref='System.Array'/>
public void CopyTo(Task[] array, int index)
public void CopyTo(SDTask[] array, int index)
{
List.CopyTo(array, index);
}
@ -186,7 +186,7 @@ namespace ICSharpCode.NAnt @@ -186,7 +186,7 @@ namespace ICSharpCode.NAnt
/// <see cref='TaskCollection'/>, if found; otherwise, -1.</para>
/// </returns>
/// <seealso cref='TaskCollection.Contains'/>
public int IndexOf(Task val)
public int IndexOf(SDTask val)
{
return List.IndexOf(val);
}
@ -198,7 +198,7 @@ namespace ICSharpCode.NAnt @@ -198,7 +198,7 @@ namespace ICSharpCode.NAnt
/// <param name='val'>The <see cref='Task'/> to insert.</param>
/// <returns><para>None.</para></returns>
/// <seealso cref='TaskCollection.Add'/>
public void Insert(int index, Task val)
public void Insert(int index, SDTask val)
{
List.Insert(index, val);
}
@ -221,7 +221,7 @@ namespace ICSharpCode.NAnt @@ -221,7 +221,7 @@ namespace ICSharpCode.NAnt
/// <param name='val'>The <see cref='Task'/> to remove from the <see cref='TaskCollection'/> .</param>
/// <returns><para>None.</para></returns>
/// <exception cref='System.ArgumentException'><paramref name='val'/> is not found in the Collection. </exception>
public void Remove(Task val)
public void Remove(SDTask val)
{
List.Remove(val);
}
@ -237,9 +237,9 @@ namespace ICSharpCode.NAnt @@ -237,9 +237,9 @@ namespace ICSharpCode.NAnt
this.baseEnumerator = temp.GetEnumerator();
}
public Task Current {
public SDTask Current {
get {
return ((Task)(baseEnumerator.Current));
return ((SDTask)(baseEnumerator.Current));
}
}

Loading…
Cancel
Save