From a957163aa33f031b33e1281c14cfc3e90665dffd Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 4 Mar 2018 01:38:39 +0100 Subject: [PATCH] Fix unit tests --- ICSharpCode.Decompiler.Tests/Helpers/Tester.cs | 1 + ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs | 10 +++++----- .../TestCases/Pretty/ExpressionTrees.cs | 8 ++++++++ .../TestCases/Pretty/NullPropagation.cs | 12 ++---------- .../TestCases/Pretty/UnsafeCode.cs | 4 ++++ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs index 67023233a..aa071854b 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs @@ -302,6 +302,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers // disable C# features not available in legacy compiler settings.NullPropagation = false; settings.StringInterpolation = false; + settings.UseExpressionBodyForCalculatedGetterOnlyProperties = false; } return settings; } diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index 55253f50b..ffcddb579 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -255,17 +255,17 @@ namespace ICSharpCode.Decompiler.Tests RunForLibrary(cscOptions: cscOptions); } - void RunForLibrary([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CSharpCompilerOptions cscOptions = CSharpCompilerOptions.None, DecompilerSettings decompilerSettings = null) - { - Run(testName, asmOptions | AssemblerOptions.Library, cscOptions | CSharpCompilerOptions.Library, decompilerSettings); - } - [Test] public void CS6_StringInterpolation([ValueSource("roslynOnlyOptions")] CSharpCompilerOptions cscOptions) { Run(cscOptions: cscOptions); } + void RunForLibrary([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CSharpCompilerOptions cscOptions = CSharpCompilerOptions.None, DecompilerSettings decompilerSettings = null) + { + Run(testName, asmOptions | AssemblerOptions.Library, cscOptions | CSharpCompilerOptions.Library, decompilerSettings); + } + void Run([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CSharpCompilerOptions cscOptions = CSharpCompilerOptions.None, DecompilerSettings decompilerSettings = null) { var ilFile = Path.Combine(TestCasePath, testName) + Tester.GetSuffix(cscOptions) + ".il"; diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs index e7c5397d3..9c21284d3 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs @@ -699,22 +699,30 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public int Field = 3; +#if LEGACY_CSC public static int StaticReadonlyProperty { get { return 0; } } +#else + public static int StaticReadonlyProperty => 0; +#endif public static int StaticProperty { get; set; } +#if LEGACY_CSC public int ReadonlyProperty { get { return 0; } } +#else + public int ReadonlyProperty => 0; +#endif public int Property { get; diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullPropagation.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullPropagation.cs index 1a614118b..da87140d4 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullPropagation.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullPropagation.cs @@ -32,16 +32,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { public int IntVal; public MyClass Field; - public MyStruct? Property1 { - get { - return null; - } - } - public MyStruct Property2 { - get { - return default(MyStruct); - } - } + public MyStruct? Property1 => null; + public MyStruct Property2 => default(MyStruct); public MyStruct? this[int index] { get { return null; diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs index 0d4988901..187c95cbd 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs @@ -58,11 +58,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty private UnsafeDelegate unsafeDelegate; private static UnsafeDelegate staticUnsafeDelegate; +#if LEGACY_CSC public unsafe int* NullPointer { get { return null; } } +#else + public unsafe int* NullPointer => null; +#endif unsafe static UnsafeCode() {