diff --git a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs index 9c0d78bbe..3ea81232a 100644 --- a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs @@ -46,16 +46,16 @@ namespace ICSharpCode.Decompiler.Tests } } - static readonly CompilerOptions[] defaultOptions = + static readonly CompilerOptions[] noMonoOptions = { CompilerOptions.None, CompilerOptions.Optimize, CompilerOptions.UseRoslyn, - CompilerOptions.Optimize | CompilerOptions.UseRoslyn + CompilerOptions.Optimize | CompilerOptions.UseRoslyn, }; - static readonly CompilerOptions[] defaultOptionsWithMcs = -{ + static readonly CompilerOptions[] defaultOptions = + { CompilerOptions.None, CompilerOptions.Optimize, CompilerOptions.UseRoslyn, @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.Tests } [Test] - public void HelloWorld([ValueSource("defaultOptionsWithMcs")] CompilerOptions options) + public void HelloWorld([ValueSource("defaultOptions")] CompilerOptions options) { RunCS(options: options); } @@ -115,6 +115,9 @@ namespace ICSharpCode.Decompiler.Tests [Test] public void Switch([ValueSource("defaultOptions")] CompilerOptions options) { + if (options.HasFlag(CompilerOptions.UseMcs)) { + Assert.Ignore("Decompiler bug with mono!"); + } RunCS(options: options); } @@ -127,6 +130,9 @@ namespace ICSharpCode.Decompiler.Tests [Test] public void Loops([ValueSource("defaultOptions")] CompilerOptions options) { + if (options.HasFlag(CompilerOptions.UseMcs)) { + Assert.Ignore("Decompiler bug with mono!"); + } RunCS(options: options); } @@ -161,7 +167,7 @@ namespace ICSharpCode.Decompiler.Tests } [Test] - public void UndocumentedExpressions([ValueSource("defaultOptions")] CompilerOptions options) + public void UndocumentedExpressions([ValueSource("noMonoOptions")] CompilerOptions options) { RunCS(options: options); } @@ -223,6 +229,9 @@ namespace ICSharpCode.Decompiler.Tests [Test] public void UnsafeCode([ValueSource("defaultOptions")] CompilerOptions options) { + if (options.HasFlag(CompilerOptions.UseMcs)) { + Assert.Ignore("Decompiler bug with mono!"); + } RunCS(options: options); } @@ -247,6 +256,9 @@ namespace ICSharpCode.Decompiler.Tests [Test] public void YieldReturn([ValueSource("defaultOptions")] CompilerOptions options) { + if (options.HasFlag(CompilerOptions.UseMcs)) { + Assert.Ignore("Decompiler bug with mono!"); + } RunCS(options: options); } @@ -259,12 +271,18 @@ namespace ICSharpCode.Decompiler.Tests [Test] public void LINQRaytracer([ValueSource("defaultOptions")] CompilerOptions options) { + if (options.HasFlag(CompilerOptions.UseMcs)) { + Assert.Ignore("Decompiler bug with mono!"); + } RunCS(options: options); } [Test] public void MiniJSON([ValueSource("defaultOptions")] CompilerOptions options) { + if (options.HasFlag(CompilerOptions.UseMcs)) { + Assert.Ignore("Decompiler bug with mono!"); + } RunCS(options: options); } diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs index 069e3bfe3..ce5c206ec 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs @@ -172,12 +172,15 @@ namespace ICSharpCode.Decompiler.Tests.Helpers } if (flags.HasFlag(CompilerOptions.UseRoslyn)) { preprocessorSymbols.Add("ROSLYN"); + preprocessorSymbols.Add("CS60"); + preprocessorSymbols.Add("CS70"); + preprocessorSymbols.Add("CS71"); + preprocessorSymbols.Add("CS72"); + } else if (flags.HasFlag(CompilerOptions.UseMcs)) { + preprocessorSymbols.Add("MCS"); } else { preprocessorSymbols.Add("LEGACY_CSC"); } - if (flags.HasFlag(CompilerOptions.UseMcs)) { - preprocessorSymbols.Add("MONO_MCS"); - } return preprocessorSymbols; } @@ -239,6 +242,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers } else { otherOptions += "-platform:anycpu "; } + if (preprocessorSymbols.Count > 0) { + otherOptions += " \"-d:" + string.Join(";", preprocessorSymbols) + "\" "; + } ProcessStartInfo info = new ProcessStartInfo(mcsPath); info.Arguments = $"{otherOptions}-out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}"; @@ -246,6 +252,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers info.RedirectStandardOutput = true; info.UseShellExecute = false; + Console.WriteLine($"\"{info.FileName}\" {info.Arguments}"); + Process process = Process.Start(info); var outputTask = process.StandardOutput.ReadToEndAsync(); diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index 6c34c8efb..be8d28eb7 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -31,6 +31,10 @@ true + + TRACE;DEBUG;NET46;ROSLYN;CS60;CS70 + + diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs index 751f14d41..c6bacb282 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -40,14 +39,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness StreamCopyToWithConfigureAwait(new MemoryStream(new byte[1024]), 16); await AwaitInForEach(Enumerable.Range(0, 100).Select(i => Task.FromResult(i))); await TaskMethodWithoutAwaitButWithExceptionHandling(); -#if !LEGACY_CSC +#if CS60 await AwaitCatch(Task.FromResult(1)); await AwaitFinally(Task.FromResult(2)); #endif await NestedAwait(Task.FromResult(Task.FromResult(5))); await AwaitWithStack(Task.FromResult(3)); await AwaitWithStack2(Task.FromResult(4)); -#if !LEGACY_CSC +#if CS60 await AwaitInCatch(Task.FromResult(1), Task.FromResult(2)); await AwaitInFinally(Task.FromResult(2), Task.FromResult(4)); #endif @@ -113,7 +112,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness } } -#if !LEGACY_CSC +#if CS60 public async Task AwaitCatch(Task task) { try { @@ -155,7 +154,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness } } -#if !LEGACY_CSC +#if CS60 public async Task AwaitInCatch(Task task1, Task task2) { try { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Capturing.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Capturing.cs index 2d5820e6a..1c57ddb13 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Capturing.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Capturing.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs index 7893c9e0a..6ab6661a7 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs @@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness static void UnsignedShiftRightInstanceField() { -#if !LEGACY_CSC +#if CS70 ref int f = ref new CompoundAssignment().instanceField; Test(X(), f = (int)((uint)f >> 2)); #endif diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/ExpressionTrees.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/ExpressionTrees.cs index 09ef4a7cd..36947bd68 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/ExpressionTrees.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/ExpressionTrees.cs @@ -1,9 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs index f76e44372..69b9a67f6 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs @@ -609,7 +609,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness return "Test"; } -#if !LEGACY_CSC +#if CS60 public static void SimpleDictInitializer() { InitializerTests.X(InitializerTests.Y(), new InitializerTests.Data { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs index 96a3ab4e2..da2685955 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs @@ -19,10 +19,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs index 79e13f89d..fc98ddf41 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs @@ -17,10 +17,6 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness { @@ -74,13 +70,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness #region params with nulls static void TestParamsMethod() { - TestCall(1, null, (TypeAccessException)null); + TestCall(1, null, (NullReferenceException)null); TestCall(2, null, (AccessViolationException)null); TestCall(3, null); TestCall(3, null, null, null); } - static void TestCall(int v, Type p1, TypeAccessException p2) + static void TestCall(int v, Type p1, NullReferenceException p2) { Console.WriteLine("TestCall without params"); } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs index 1878456bb..9b673da66 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs @@ -55,9 +55,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness public static void SimpleUsingNullStatement() { Console.WriteLine("before using"); + // Mono has a compiler bug and introduces an assembly reference to [gmcs] here... +#if !MCS using (null) { Console.WriteLine("using (null)"); } +#endif Console.WriteLine("after using"); } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs index ff1d34741..859cd59aa 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -#if !LEGACY_CSC +#if CS60 using System.IO; #endif using System.Threading; @@ -64,7 +64,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty return false; } -#if !LEGACY_CSC +#if CS60 public bool SimpleTryCatchExceptionWithNameAndCondition() { try { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs index f96939cb1..462c9fe16 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs @@ -349,7 +349,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } -#if !LEGACY_CSC +#if CS60 public static void SimpleDictInitializer() { InitializerTests.X(InitializerTests.Y(), new Data { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs index a531888f0..9e3cdf345 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs @@ -40,6 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } #if LEGACY_CSC + // roslyn optimizes out the try-finally; mcs has a compiler bug on using(null-literal) public void SimpleUsingNullStatement() { using (null) { diff --git a/ILSpy-tests b/ILSpy-tests index 2c480d5f5..4ed264306 160000 --- a/ILSpy-tests +++ b/ILSpy-tests @@ -1 +1 @@ -Subproject commit 2c480d5f589e3f2acb96cd3efa67f608af25a05c +Subproject commit 4ed2643065a15d4440971fe2a5409cdeba6aaeac