From b360268d6d2b8f625e6653e5e680b54e8bfdaeb6 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 29 Aug 2026 15:46:44 +0200 Subject: [PATCH] Adjust tests: the improved stack slot type caused variable names to improve. --- .../TestCases/ILPretty/Issue684.cs | 28 +++++++++---------- .../TestCases/Pretty/AnonymousTypes.cs | 17 ----------- .../TestCases/Pretty/DeconstructionTests.cs | 8 ------ .../TestCases/Pretty/Loops.cs | 8 ------ .../TestCases/Pretty/QueryExpressions.cs | 9 ------ 5 files changed, 14 insertions(+), 56 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue684.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue684.cs index b1aba1711..9d420b2e7 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue684.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue684.cs @@ -8,35 +8,35 @@ public static class Issue684 int num = int.Parse(Console.ReadLine()); // Point of this test was to ensure the stack slot here uses an appropriate type, // (bool instead of int). Unfortunately our type fixup runs too late to affect variable names. - bool num2 = num >= 1000; - if (!num2) + bool flag = num >= 1000; + if (!flag) { - num2 = num < 2; + flag = num < 2; } - if (num2) + if (flag) { Console.WriteLine(-1); } else { int i = 2; - for (int num3 = 2; num3 <= num; num3 = i) + for (int num2 = 2; num2 <= num; num2 = i) { - Console.WriteLine(num3); - for (; i <= num; i += num3) + Console.WriteLine(num2); + for (; i <= num; i += num2) { - int num4 = 1; - array[i] = num4; + int num3 = 1; + array[i] = num3; } - i = num3; + i = num2; while (true) { - bool num5 = i <= num; - if (num5) + bool flag2 = i <= num; + if (flag2) { - num5 = array[i] != 0; + flag2 = array[i] != 0; } - if (!num5) + if (!flag2) { break; } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs index 32483e92c..8d6c928d9 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs @@ -40,11 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty private void SimpleArray() { -#if ROSLYN && OPT - var obj = new[] { -#else var array = new[] { -#endif new { X = 5, Y = 2, @@ -57,13 +53,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } }; -#if ROSLYN && OPT - Console.WriteLine(obj[0].X); - Console.WriteLine(obj[1].X); -#else Console.WriteLine(array[0].X); Console.WriteLine(array[1].X); -#endif } #if !MCS private void JaggedArray() @@ -80,19 +71,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty Z = -6 } }; -#if ROSLYN && OPT - var obj = new[] { array, array }; - - Console.WriteLine(array[0].X); - Console.WriteLine(array[1].X); - Console.WriteLine(obj.Length); -#else var array2 = new[] { array, array }; Console.WriteLine(array[0].X); Console.WriteLine(array[1].X); Console.WriteLine(array2.Length); -#endif } #endif #if CS70 diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs index 4e861fa4a..fe2cc8388 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs @@ -623,17 +623,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty // leaf instead of becoming a nested designation. public void LocalVariable_TupleInner_ElementUsedOutside() { -#if OPT - (int, (int, int)) tuple = GetTuple(); - int item = tuple.Item1; - (int, int) item2 = tuple.Item2; - Console.WriteLine(item); - Console.WriteLine(item2.Item1); -#else var (value, tuple2) = GetTuple(); Console.WriteLine(value); Console.WriteLine(tuple2.Item1); -#endif } // Same, but the escaping element is in the first position. Every leaf of the diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs index b22516ba4..f035e9a83 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs @@ -647,19 +647,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public unsafe void ForEachOverMultiDimArray3(int*[,] items) { -#if ROSLYN && OPT - foreach (int* intPtr in items) - { - Console.WriteLine(*intPtr); - Console.WriteLine(*intPtr); - } -#else foreach (int* ptr in items) { Console.WriteLine(*ptr); Console.WriteLine(*ptr); } -#endif } #endif diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs index ae87090b0..1ece4641f 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs @@ -264,21 +264,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static IEnumerable Issue1310a(bool test) { -#if ROSLYN && OPT - IEnumerable obj = (test ? (from c in Enumerable.Range(0, 255) - where char.IsLetter((char)c) - select (char)c) : (from c in Enumerable.Range(0, 255) - where char.IsDigit((char)c) - select (char)c)); - return obj.Concat(obj); -#else IEnumerable enumerable = (test ? (from c in Enumerable.Range(0, 255) where char.IsLetter((char)c) select (char)c) : (from c in Enumerable.Range(0, 255) where char.IsDigit((char)c) select (char)c)); return enumerable.Concat(enumerable); -#endif } public static Maybe Cast(Maybe a) where TB : class