diff --git a/src/Libraries/ICSharpCode.Build.Tasks/ICSharpCode.Build.Tasks.sln b/src/Libraries/ICSharpCode.Build.Tasks/ICSharpCode.Build.Tasks.sln new file mode 100644 index 0000000000..26da2d8060 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/ICSharpCode.Build.Tasks.sln @@ -0,0 +1,8 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# SharpDevelop 2.0.0.546 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks.Tests", "Test\ICSharpCode.Build.Tasks.Tests.csproj", "{B7C2A664-B454-4920-AC6E-318F5274B2EF}" +EndProject +Global +EndGlobal diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/CompilerCommandLineArguments.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/CompilerCommandLineArguments.cs new file mode 100644 index 0000000000..a0b8e99cf0 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/CompilerCommandLineArguments.cs @@ -0,0 +1,127 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using Microsoft.Build.Framework; +using Microsoft.Build.Tasks; +using Microsoft.Build.Utilities; +using System; +using System.Text; +using System.IO; + +namespace ICSharpCode.Build.Tasks +{ + public class CompilerCommandLineArguments : CommandLineBuilderExtension + { + public CompilerCommandLineArguments(MonoCompilerTask compilerTask) + { + GenerateCommandLineArguments(compilerTask); + } + + public static bool IsNetModule(string fileName) + { + return Path.GetExtension(fileName).ToLowerInvariant() == ".netmodule"; + } + + void GenerateCommandLineArguments(MonoCompilerTask compilerTask) + { + AppendSwitchIfTrue("-noconfig", compilerTask.NoConfig); + AppendSwitch("-warn:", compilerTask.WarningLevel.ToString()); + AppendFileNameIfNotNull("-out:", compilerTask.OutputAssembly); + AppendTarget(compilerTask.TargetType); + AppendSwitchWithoutParameterIfNotNull("-debug", compilerTask.DebugType); + AppendSwitchIfTrue("-optimize", compilerTask.Optimize); + AppendSwitchIfTrue("-nologo", compilerTask.NoLogo); + AppendSwitchIfTrue("-unsafe", compilerTask.AllowUnsafeBlocks); + AppendSwitchIfTrue("-nostdlib", compilerTask.NoStandardLib); + AppendSwitchIfTrue("-checked", compilerTask.CheckForOverflowUnderflow); + AppendSwitchIfTrue("-delaysign", compilerTask.DelaySign); + AppendSwitchIfNotNull("-langversion:", compilerTask.LangVersion); + AppendSwitchIfNotNull("-keycontainer:", compilerTask.KeyContainer); + AppendSwitchIfNotNull("-keyfile:", compilerTask.KeyFile); + AppendSwitchIfNotNull("-define:", compilerTask.DefineConstants); + AppendSwitchIfTrue("-warnaserror", compilerTask.TreatWarningsAsErrors); + AppendSwitchIfNotNull("-nowarn:", compilerTask.DisabledWarnings); + AppendSwitchIfNotNull("-main:", compilerTask.MainEntryPoint); + AppendFileNameIfNotNull("-doc:", compilerTask.DocumentationFile); + AppendSwitchIfNotNull("-lib:", compilerTask.AdditionalLibPaths, ","); + AppendReferencesIfNotNull(compilerTask.References); + AppendResourcesIfNotNull(compilerTask.Resources); + AppendFileNameIfNotNull("-win32res:", compilerTask.Win32Resource); + AppendFileNameIfNotNull("-win32icon:", compilerTask.Win32Icon); + AppendFileNamesIfNotNull(compilerTask.Sources, " "); + } + + void AppendReferencesIfNotNull(ITaskItem[] references) + { + if (references == null) { + return; + } + + foreach (ITaskItem reference in references) { + string fileName = reference.ItemSpec; + if (CompilerCommandLineArguments.IsNetModule(fileName)) { + AppendFileNameIfNotNull("-addmodule:", reference); + } else { + AppendFileNameIfNotNull("-r:", reference); + } + } + } + + void AppendResourcesIfNotNull(ITaskItem[] resources) + { + if (resources == null) { + return; + } + + foreach (ITaskItem resource in resources) { + AppendFileNameIfNotNull("-resource:", resource); + } + } + + void AppendSwitchWithoutParameterIfNotNull(string switchName, string parameter) + { + if (parameter != null && parameter.Trim().Length > 0) { + AppendSwitch(switchName); + } + } + + void AppendSwitchIfTrue(string switchName, bool parameter) + { + if (parameter) { + AppendSwitch(switchName); + } + } + + void AppendSwitch(string switchName, string parameter) + { + AppendSwitchIfNotNull(switchName, parameter); + } + + void AppendFileNameIfNotNull(string switchName, ITaskItem fileItem) + { + if (fileItem != null) { + AppendFileNameIfNotNull(switchName, fileItem.ItemSpec); + } + } + + void AppendFileNameIfNotNull(string switchName, string fileName) + { + if (fileName != null) { + AppendSpaceIfNotEmpty(); + AppendTextUnquoted(switchName); + AppendFileNameWithQuoting(fileName); + } + } + + void AppendTarget(string targetType) + { + if (targetType != null) { + AppendSwitch("-target:", targetType.ToLowerInvariant()); + } + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/CompilerResultsParser.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/CompilerResultsParser.cs new file mode 100644 index 0000000000..655e8b0359 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/CompilerResultsParser.cs @@ -0,0 +1,76 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; +using System.CodeDom.Compiler; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; + +namespace ICSharpCode.Build.Tasks +{ + public class CompilerResultsParser : ICompilerResultsParser + { + public const string NormalErrorPattern = @"(?.*)\((?\d+),(?\d+)\):\s+(?\w+)\s+(?[\d\w]+):\s+(?.*)"; + public const string GeneralErrorPattern = @"(?.+?)\s+(?[\d\w]+?):\s+(?.*)"; + + Regex normalError = new Regex(NormalErrorPattern, RegexOptions.Compiled); + Regex generalError = new Regex(GeneralErrorPattern, RegexOptions.Compiled); + + public CompilerResultsParser() + { + } + + public CompilerResults Parse(TempFileCollection tempFiles, string fileName) + { + CompilerResults results = new CompilerResults(tempFiles); + + StringBuilder compilerOutput = new StringBuilder(); + StreamReader resultsReader = File.OpenText(fileName); + + while (true) { + string curLine = resultsReader.ReadLine(); + compilerOutput.Append(curLine); + compilerOutput.Append('\n'); + if (curLine == null) { + break; + } + curLine = curLine.Trim(); + if (curLine.Length == 0) { + continue; + } + + CompilerError error = new CompilerError(); + + // try to match standard mono errors + Match match = normalError.Match(curLine); + if (match.Success) { + error.Column = Int32.Parse(match.Result("${column}")); + error.Line = Int32.Parse(match.Result("${line}")); + error.FileName = Path.GetFullPath(match.Result("${file}")); + error.IsWarning = match.Result("${error}") == "warning"; + error.ErrorNumber = match.Result("${number}"); + error.ErrorText = match.Result("${message}"); + + results.Errors.Add(error); + } else { + match = generalError.Match(curLine); + if (match.Success) { + error.IsWarning = match.Result("${error}") == "warning"; + error.ErrorNumber = match.Result("${number}"); + error.ErrorText = match.Result("${message}"); + + results.Errors.Add(error); + } + } + } + resultsReader.Close(); + + return results; + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/Gmcs.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/Gmcs.cs new file mode 100644 index 0000000000..ddb8a37d8c --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/Gmcs.cs @@ -0,0 +1,29 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using Microsoft.Build.Framework; +using System; + +namespace ICSharpCode.Build.Tasks +{ + /// + /// MSBuild task for Mono's GMCS. + /// + public class Gmcs : MonoCompilerTask + { + protected override string ToolName { + get { + return "Gmcs.exe"; + } + } + + protected override string GenerateFullPathToTool() + { + return String.Concat(Environment.GetEnvironmentVariable("ComSpec"), " /c gmcs"); + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/ICSharpCode.Build.Tasks.csproj b/src/Libraries/ICSharpCode.Build.Tasks/Project/ICSharpCode.Build.Tasks.csproj index 1f78783456..707cd8bf8f 100644 --- a/src/Libraries/ICSharpCode.Build.Tasks/Project/ICSharpCode.Build.Tasks.csproj +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/ICSharpCode.Build.Tasks.csproj @@ -34,6 +34,19 @@ + + Always + + + + + + + + + + Always + @@ -41,4 +54,4 @@ - + \ No newline at end of file diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/ICompilerResultsParser.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/ICompilerResultsParser.cs new file mode 100644 index 0000000000..1190ad23ae --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/ICompilerResultsParser.cs @@ -0,0 +1,17 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; +using System.CodeDom.Compiler; + +namespace ICSharpCode.Build.Tasks +{ + public interface ICompilerResultsParser + { + CompilerResults Parse(TempFileCollection tempFiles, string fileName); + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/Mcs.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/Mcs.cs new file mode 100644 index 0000000000..e475826868 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/Mcs.cs @@ -0,0 +1,29 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using Microsoft.Build.Framework; +using System; + +namespace ICSharpCode.Build.Tasks +{ + /// + /// MSBuild task for Mono's MCS. + /// + public class Mcs : MonoCompilerTask + { + protected override string ToolName { + get { + return "Mcs.exe"; + } + } + + protected override string GenerateFullPathToTool() + { + return String.Concat(Environment.GetEnvironmentVariable("ComSpec"), " /c mcs"); + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/MonoCompiler.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/MonoCompiler.cs new file mode 100644 index 0000000000..42586694a9 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/MonoCompiler.cs @@ -0,0 +1,53 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; +using System.CodeDom.Compiler; +using System.IO; + +namespace ICSharpCode.Build.Tasks +{ + public class MonoCompiler + { + CompilerResults results; + + public MonoCompiler() + { + } + + public int Run(string compiler, string args, ICompilerResultsParser parser) + { + string responseFileName = Path.GetTempFileName(); + + using (StreamWriter writer = new StreamWriter(responseFileName)) { + writer.Write(args); + } + + //string outstr = String.Concat(compilerFileName, compilerparameters.NoConfig ? " /noconfig" : String.Empty, " \"@", responseFileName, "\""); + string outputFileName = String.Empty; + string errorFileName = String.Empty; + TempFileCollection tempFiles = new TempFileCollection(); + string command = String.Concat(compiler, " \"@", responseFileName, "\""); + + int returnValue = Executor.ExecWaitWithCapture(command, tempFiles, ref outputFileName, ref errorFileName); + + results = parser.Parse(tempFiles, errorFileName); + + File.Delete(responseFileName); + File.Delete(outputFileName); + File.Delete(errorFileName); + + return returnValue; + } + + public CompilerResults Results { + get { + return results; + } + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/MonoCompilerTask.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/MonoCompilerTask.cs new file mode 100644 index 0000000000..fbb30d8cc8 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/MonoCompilerTask.cs @@ -0,0 +1,370 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System; +using System.CodeDom.Compiler; + +namespace ICSharpCode.Build.Tasks +{ + /// + /// Base class task for the mono compilers mcs and gmcs. + /// + public abstract class MonoCompilerTask : MyToolTask + { + string[] additionalLibPaths; + string[] addModules; + bool allowUnsafeBlocks; + bool checkForOverflowUnderflow; + int codePage; + string debugType; + string defineConstants; + bool delaySign; + string disabledWarnings; + string documentationFile; + string emitDebugInformation; + string keyContainer; + string keyFile; + string langVersion; + ITaskItem[] linkResources; + string mainEntryPoint; + string moduleAssemblyName; + bool noConfig; + bool noLogo; + bool noStandardLib; + bool optimize; + ITaskItem outputAssembly; + ITaskItem[] references; + ITaskItem[] resources; + ITaskItem[] responseFiles; + ITaskItem[] sources; + string targetType; + bool treatWarningsAsErrors; + int warningLevel; + string win32Icon; + string win32Resource; + + public string[] AdditionalLibPaths { + get { + return additionalLibPaths; + } + set { + additionalLibPaths = value; + } + } + + public string[] AddModules { + get { + return addModules; + } + set { + addModules = value; + } + } + + public bool AllowUnsafeBlocks { + get { + return allowUnsafeBlocks; + } + set { + allowUnsafeBlocks = value; + } + } + + public bool CheckForOverflowUnderflow { + get { + return checkForOverflowUnderflow; + } + set { + checkForOverflowUnderflow = value; + } + } + + public int CodePage { + get { + return codePage; + } + set { + codePage = value; + } + } + + public string DebugType { + get { + return debugType; + } + set { + debugType = value; + } + } + + public string DefineConstants { + get { + return defineConstants; + } + set { + defineConstants = value; + } + } + + public bool DelaySign { + get { + return delaySign; + } + + set { + delaySign = value; + } + } + + public string DisabledWarnings { + get { + return disabledWarnings; + } + set { + disabledWarnings = value; + } + } + + public string DocumentationFile { + get { + return documentationFile; + } + set { + documentationFile = value; + } + } + + public string EmitDebugInformation { + get { + return emitDebugInformation; + } + set { + emitDebugInformation = value; + } + } + + public string KeyContainer { + get { + return keyContainer; + } + set { + keyContainer = value; + } + } + + public string KeyFile { + get { + return keyFile; + } + set { + keyFile = value; + } + } + + public string LangVersion { + get { + return langVersion; + } + set { + langVersion = value; + } + } + + public ITaskItem[] LinkResources { + get { + return linkResources; + } + set { + linkResources = value; + } + } + + public string MainEntryPoint { + get { + return mainEntryPoint; + } + set { + mainEntryPoint = value; + } + } + + public string ModuleAssemblyName { + get { + return moduleAssemblyName; + } + set { + moduleAssemblyName = value; + } + } + + public bool NoConfig { + get { + return noConfig; + } + set { + noConfig = value; + } + } + + public bool NoLogo { + get { + return noLogo; + } + set { + noLogo = value; + } + } + + public bool NoStandardLib { + get { + return noStandardLib; + } + set { + noStandardLib = value; + } + } + + public bool Optimize { + get { + return optimize; + } + set { + optimize = value; + } + } + public ITaskItem OutputAssembly { + get { + return outputAssembly; + } + set { + outputAssembly = value; + } + } + + public ITaskItem[] References { + get { + return references; + } + set { + references = value; + } + } + + public ITaskItem[] Resources { + get { + return resources; + } + set { + resources = value; + } + } + + public ITaskItem[] ResponseFiles { + get { + return responseFiles; + } + set { + responseFiles = value; + } + } + + public ITaskItem[] Sources { + get { + return sources; + } + set { + sources = value; + } + } + + public string TargetType { + get { + return targetType; + } + set { + targetType = value; + } + } + + public bool TreatWarningsAsErrors { + get { + return treatWarningsAsErrors; + } + set { + treatWarningsAsErrors = value; + } + } + + public int WarningLevel { + get { + return warningLevel; + } + set { + warningLevel = value; + } + } + + public string Win32Icon { + get { + return win32Icon; + } + set { + win32Icon = value; + } + } + + public string Win32Resource { + get { + return win32Resource; + } + set { + win32Resource = value; + } + } + + public override bool Execute() + { + string args = GenerateCommandLineArguments(); + + ToolPath = GenerateFullPathToTool(); + MonoCompiler compiler = new MonoCompiler(); + int returnValue = compiler.Run(ToolPath, args, GetCompilerResultsParser()); + + int errorCount = 0; + foreach (CompilerError error in compiler.Results.Errors) { + if (error.IsWarning) { + Log.LogWarning("warning", error.ErrorNumber, null, error.FileName, error.Line, error.Column, error.Line, error.Column, error.ErrorText); + } else { + errorCount++; + Log.LogError("error", error.ErrorNumber, null, error.FileName, error.Line, error.Column, error.Line, error.Column, error.ErrorText); + } + } + + if (returnValue != 0 && errorCount == 0) { + Log.LogError(String.Concat("Failed to execute compiler: ", returnValue, ": ", ToolPath)); + } + + return errorCount == 0; + } + + /// + /// Command line arguments that will be passed to the compiler. + /// + protected virtual string GenerateCommandLineArguments() + { + CompilerCommandLineArguments args = new CompilerCommandLineArguments(this); + return args.ToString(); + } + + protected virtual ICompilerResultsParser GetCompilerResultsParser() + { + return new CompilerResultsParser(); + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets b/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets index e19571fefa..47b0721a71 100644 --- a/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets @@ -4,10 +4,12 @@ $(SystemRoot)\Microsoft.NET\Framework\v1.0.3705 true + true $(SystemRoot)\Microsoft.NET\Framework\v1.1.4322 true + true @@ -18,8 +20,12 @@ + + true + + - + @@ -44,7 +50,7 @@ - + @@ -58,4 +64,8 @@ + + + + diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Mono.Gmcs.targets b/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Mono.Gmcs.targets new file mode 100644 index 0000000000..aaf730b594 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Mono.Gmcs.targets @@ -0,0 +1,63 @@ + + + + + + $(MSBuildAllProjects);$(SharpDevelopBinPath)\SharpDevelop.Build.Mono.targets + .cs + C# + + + + + + + + + + diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Mono.Mcs.targets b/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Mono.Mcs.targets new file mode 100644 index 0000000000..87eb6ed753 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Mono.Mcs.targets @@ -0,0 +1,63 @@ + + + + + + $(MSBuildAllProjects);$(SharpDevelopBinPath)\SharpDevelop.Build.Mono.targets + .cs + C# + + + + + + + + + + diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Test/AssemblyInfo.cs b/src/Libraries/ICSharpCode.Build.Tasks/Test/AssemblyInfo.cs new file mode 100644 index 0000000000..906720da13 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Test/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Test/CompilerCommandLineTestFixture.cs b/src/Libraries/ICSharpCode.Build.Tasks/Test/CompilerCommandLineTestFixture.cs new file mode 100644 index 0000000000..18c8f4baf1 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Test/CompilerCommandLineTestFixture.cs @@ -0,0 +1,273 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.Build.Tasks; +using MbUnit.Framework; +using Microsoft.Build.Utilities; +using System; +using System.Collections.Generic; + +namespace ICSharpCode.Build.Tasks.Tests +{ + [TestFixture] + public class CompilerCommandLineTestFixture + { + [Test] + public void NoArguments() + { + Mcs mcs = new Mcs(); + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0", args.ToString()); + } + + [Test] + public void OutputAssembly() + { + Mcs mcs = new Mcs(); + string outputAssembly = @"obj\debug\test.exe"; + mcs.OutputAssembly = new TaskItem(outputAssembly); + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual(@"-warn:0 -out:obj\debug\test.exe", args.ToString()); + } + + [Test] + public void OutputAssemblyWithSpace() + { + Mcs mcs = new Mcs(); + string outputAssembly = @"obj\debug\test this.exe"; + mcs.OutputAssembly = new TaskItem(outputAssembly); + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -out:\"obj\\debug\\test this.exe\"", args.ToString()); + } + + [Test] + public void WinExeTarget() + { + Mcs mcs = new Mcs(); + mcs.TargetType = "Exe"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -target:exe", args.ToString()); + } + + [Test] + public void ModuleTarget() + { + Mcs mcs = new Mcs(); + mcs.TargetType = "Module"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -target:module", args.ToString()); + } + + [Test] + public void FullDebugging() + { + Mcs mcs = new Mcs(); + mcs.DebugType = "Full"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -debug", args.ToString()); + } + + [Test] + public void Optimize() + { + Mcs mcs = new Mcs(); + mcs.Optimize = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -optimize", args.ToString()); + } + + [Test] + public void NoLogo() + { + Mcs mcs = new Mcs(); + mcs.NoLogo = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -nologo", args.ToString()); + } + + [Test] + public void Unsafe() + { + Mcs mcs = new Mcs(); + mcs.AllowUnsafeBlocks = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -unsafe", args.ToString()); + } + + [Test] + public void NoStandardLib() + { + Mcs mcs = new Mcs(); + mcs.NoStandardLib = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -nostdlib", args.ToString()); + } + + [Test] + public void DelaySign() + { + Mcs mcs = new Mcs(); + mcs.DelaySign = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -delaysign", args.ToString()); + } + + [Test] + public void DefineConstants() + { + Mcs mcs = new Mcs(); + mcs.DefineConstants = "DEBUG;TRACE"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -define:\"DEBUG;TRACE\"", args.ToString()); + } + + [Test] + public void WarnAsError() + { + Mcs mcs = new Mcs(); + mcs.TreatWarningsAsErrors = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -warnaserror", args.ToString()); + } + + [Test] + public void NoWarn() + { + Mcs mcs = new Mcs(); + mcs.DisabledWarnings = "1234,5678"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -nowarn:\"1234,5678\"", args.ToString()); + } + + [Test] + public void MainEntryPoint() + { + Mcs mcs = new Mcs(); + mcs.MainEntryPoint = "Console.MainClass.Main"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -main:Console.MainClass.Main", args.ToString()); + } + + [Test] + public void DocumentationFile() + { + Mcs mcs = new Mcs(); + mcs.DocumentationFile = @"obj\debug test\test.exe.xml"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -doc:\"obj\\debug test\\test.exe.xml\"", args.ToString()); + } + + [Test] + public void SingleSourceFile() + { + Mcs mcs = new Mcs(); + mcs.Sources = new TaskItem[] { new TaskItem("proj src\\Main.cs") }; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 \"proj src\\Main.cs\"", args.ToString()); + } + + [Test] + public void MultipleSourceFiles() + { + Mcs mcs = new Mcs(); + mcs.Sources = new TaskItem[] { new TaskItem("proj src\\Main.cs"), + new TaskItem("AssemblyInfo.cs") }; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 \"proj src\\Main.cs\" AssemblyInfo.cs", args.ToString()); + } + + [Test] + public void SingleReference() + { + Mcs mcs = new Mcs(); + mcs.References = new TaskItem[] { new TaskItem("proj refs\\Test.dll") }; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -r:\"proj refs\\Test.dll\"", args.ToString()); + } + + [Test] + public void NetModuleReference() + { + Mcs mcs = new Mcs(); + mcs.References = new TaskItem[] { new TaskItem("proj refs\\Test.dll"), + new TaskItem("proj refs\\Run.netmodule") }; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -r:\"proj refs\\Test.dll\" -addmodule:\"proj refs\\Run.netmodule\"", args.ToString()); + } + + [Test] + public void AdditionalLibPaths() + { + Mcs mcs = new Mcs(); + mcs.AdditionalLibPaths = new string[] { "proj\\My libs", "proj\\My libs2" }; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -lib:\"proj\\My libs\",\"proj\\My libs2\"", args.ToString()); + } + + [Test] + public void EmbeddedResources() + { + Mcs mcs = new Mcs(); + mcs.Resources = new TaskItem[] { new TaskItem("proj res\\Test.xml"), + new TaskItem("proj res\\Run.xml") }; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -resource:\"proj res\\Test.xml\" -resource:\"proj res\\Run.xml\"", args.ToString()); + } + + [Test] + public void Win32Resource() + { + Mcs mcs = new Mcs(); + mcs.Win32Resource = "Project Resources\\Test.res"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -win32res:\"Project Resources\\Test.res\"", args.ToString()); + } + + [Test] + public void Win32Icon() + { + Mcs mcs = new Mcs(); + mcs.Win32Icon = "Project Icons\\app.ico"; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -win32icon:\"Project Icons\\app.ico\"", args.ToString()); + } + + [Test] + public void Checked() + { + Mcs mcs = new Mcs(); + mcs.CheckForOverflowUnderflow = true; + + CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); + Assert.AreEqual("-warn:0 -checked", args.ToString()); + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Test/GeneralErrorParseTestFixture.cs b/src/Libraries/ICSharpCode.Build.Tasks/Test/GeneralErrorParseTestFixture.cs new file mode 100644 index 0000000000..545582e1f6 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Test/GeneralErrorParseTestFixture.cs @@ -0,0 +1,47 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.Build.Tasks; +using MbUnit.Framework; +using System; +using System.Text.RegularExpressions; + +namespace ICSharpCode.Build.Tasks.Tests +{ + [TestFixture] + public class GeneralMonoErrorParseTestFixture + { + Match match; + + [TestFixtureSetUp] + public void FixtureSetUp() + { + string error = "error CS1904: `CS0169' is not a valid warning number"; + + Regex regex = new Regex(CompilerResultsParser.GeneralErrorPattern, RegexOptions.Compiled); + match = regex.Match(error); + } + + [Test] + public void Error() + { + Assert.AreEqual("error", match.Result("${error}")); + } + + [Test] + public void ErrorNumber() + { + Assert.AreEqual("CS1904", match.Result("${number}")); + } + + [Test] + public void ErrorText() + { + Assert.AreEqual("`CS0169' is not a valid warning number", match.Result("${message}")); + } + } +} diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Test/ICSharpCode.Build.Tasks.Tests.csproj b/src/Libraries/ICSharpCode.Build.Tasks/Test/ICSharpCode.Build.Tasks.Tests.csproj new file mode 100644 index 0000000000..2943bf75a8 --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Test/ICSharpCode.Build.Tasks.Tests.csproj @@ -0,0 +1,56 @@ + + + Library + ICSharpCode.Build.Tasks.Tests + ICSharpCode.Build.Tasks.Tests + Debug + AnyCPU + {B7C2A664-B454-4920-AC6E-318F5274B2EF} + False + False + False + Auto + 4194304 + AnyCPU + 4096 + 4 + false + + + ..\..\..\..\bin\ + False + DEBUG;TRACE + true + Full + True + + + bin\Release\ + True + TRACE + False + None + False + + + + + + + + + + + + + + + + + + {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} + ICSharpCode.Build.Tasks + + + + \ No newline at end of file diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Test/NormalMonoErrorParseTestFixture.cs b/src/Libraries/ICSharpCode.Build.Tasks/Test/NormalMonoErrorParseTestFixture.cs new file mode 100644 index 0000000000..38a30cba7c --- /dev/null +++ b/src/Libraries/ICSharpCode.Build.Tasks/Test/NormalMonoErrorParseTestFixture.cs @@ -0,0 +1,65 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.Build.Tasks; +using MbUnit.Framework; +using System; +using System.Text.RegularExpressions; + +namespace ICSharpCode.Build.Tasks.Tests +{ + [TestFixture] + public class NormalMonoErrorParseTestFixture + { + Match match; + + [TestFixtureSetUp] + public void FixtureSetUp() + { + string error = "MyClass.cs(19,7): warning CS0169: The private field `Foo.MyClass.foo' is never used"; + + Regex regex = new Regex(CompilerResultsParser.NormalErrorPattern, RegexOptions.Compiled); + match = regex.Match(error); + } + + [Test] + public void Column() + { + Assert.AreEqual("7", match.Result("${column}")); + } + + [Test] + public void Line() + { + Assert.AreEqual("19", match.Result("${line}")); + } + + [Test] + public void FileName() + { + Assert.AreEqual("MyClass.cs", match.Result("${file}")); + } + + [Test] + public void Warning() + { + Assert.AreEqual("warning", match.Result("${error}")); + } + + [Test] + public void ErrorNumber() + { + Assert.AreEqual("CS0169", match.Result("${number}")); + } + + [Test] + public void ErrorText() + { + Assert.AreEqual("The private field `Foo.MyClass.foo' is never used", match.Result("${message}")); + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs index 87a6caf359..a3c77b2741 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs @@ -178,7 +178,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels new StringPair("", "Default (.NET 2.0)"), new StringPair("v1.0", ".NET 1.0"), new StringPair("v1.1", ".NET 1.1"), - new StringPair("v2.0", ".NET 2.0")); + new StringPair("v2.0", ".NET 2.0"), + new StringPair("Mono v1.1", "Mono 1.1"), + new StringPair("Mono v2.0", "Mono 2.0")); debugInfoBinding.CreateLocationButton("targetFrameworkLabel"); helper.Saved += delegate { // Test if SharpDevelop-Build extensions are needed diff --git a/src/Main/StartUp/Project/Resources/BitmapResources.resources b/src/Main/StartUp/Project/Resources/BitmapResources.resources index 7af98aca3d..37caf3af30 100644 Binary files a/src/Main/StartUp/Project/Resources/BitmapResources.resources and b/src/Main/StartUp/Project/Resources/BitmapResources.resources differ diff --git a/src/Main/StartUp/Project/Resources/StringResources.resources b/src/Main/StartUp/Project/Resources/StringResources.resources index 1346020a12..4497d4f09d 100644 Binary files a/src/Main/StartUp/Project/Resources/StringResources.resources and b/src/Main/StartUp/Project/Resources/StringResources.resources differ diff --git a/src/SharpDevelop.WithTests.sln b/src/SharpDevelop.WithTests.sln index 25eef3ddde..cb46ecd192 100644 --- a/src/SharpDevelop.WithTests.sln +++ b/src/SharpDevelop.WithTests.sln @@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{ ProjectSection(SolutionItems) = postProject EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks.Tests", "Libraries\ICSharpCode.Build.Tasks\Test\ICSharpCode.Build.Tasks.Tests.csproj", "{B7C2A664-B454-4920-AC6E-318F5274B2EF}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor.Test", "Libraries\ICSharpCode.TextEditor\Test\ICSharpCode.TextEditor.Test.csproj", "{6259D767-BA7C-484D-9472-68F350A20086}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" @@ -206,6 +208,7 @@ Global {83DD7E12-A705-4DBA-9D71-09C8973D9382} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {6259D767-BA7C-484D-9472-68F350A20086} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} + {B7C2A664-B454-4920-AC6E-318F5274B2EF} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {1152B71B-3C05-4598-B20D-823B5D40559E} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486}