From b87cdf6bc44f68688d66bfbd457f12513846b197 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 5 Nov 2021 16:43:39 +0100 Subject: [PATCH] Fix CS73_StackAllocInitializer tests --- ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs | 10 +++++++++- .../TestCases/Pretty/CS73_StackAllocInitializers.cs | 10 +++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index 0ebda9283..5e332efa1 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -79,6 +79,14 @@ namespace ICSharpCode.Decompiler.Tests CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest, }; + static readonly CompilerOptions[] roslyn3OrNewerOptions = + { + CompilerOptions.UseRoslyn3_11_0, + CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0, + CompilerOptions.UseRoslynLatest, + CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest, + }; + static readonly CompilerOptions[] roslynLatestOnlyOptions = { CompilerOptions.UseRoslynLatest, @@ -440,7 +448,7 @@ namespace ICSharpCode.Decompiler.Tests } [Test] - public void CS73_StackAllocInitializers([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions) + public void CS73_StackAllocInitializers([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions) { RunForLibrary(cscOptions: cscOptions); } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs index dd1e0d7c6..d97fa7d14 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs @@ -193,11 +193,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public unsafe string NegativeOffsets(int a, int b, int c) { #if OPT - byte* intPtr = stackalloc byte[12]; - *(int*)intPtr = 1; - *(int*)(intPtr - 4) = 2; - *(int*)(intPtr - 8) = 3; - int* ptr = (int*)intPtr; + byte* num = stackalloc byte[12]; + *(int*)num = 1; + *(int*)(num - 4) = 2; + *(int*)(num - 8) = 3; + int* ptr = (int*)num; Console.WriteLine(*ptr); return UsePointer((byte*)ptr); #else