diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index e5c09c9c1..284b51401 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -736,7 +736,7 @@ namespace ICSharpCode.Decompiler.Tests var decompiled = await Tester.DecompileCSharp(exeFile, decompilerSettings ?? Tester.GetSettings(cscOptions)).ConfigureAwait(false); // 3. Compile - CodeAssert.FilesAreEqual(csFile, decompiled, Tester.GetPreprocessorSymbols(cscOptions).ToArray()); + CodeAssert.FilesAreEqual(csFile, decompiled, Tester.GetPreprocessorSymbols(cscOptions).Append("EXPECTED_OUTPUT").ToArray()); Tester.RepeatOnIOError(() => File.Delete(decompiled)); } } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/VariableNaming.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/VariableNaming.cs index 642a9576e..497a36c06 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/VariableNaming.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/VariableNaming.cs @@ -60,5 +60,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty #pragma warning restore CS0219 } #endif + + private static void NestedForLoopTest(int sizeX, int sizeY, int[] array) + { + for (int y = 0; y < sizeY; y++) + { + for (int x = 0; x < sizeX; x++) + { + array[y * sizeX + x] = 0; + } + } +#if !EXPECTED_OUTPUT || (LEGACY_CSC && !OPT) + for (int y = 0; y < sizeY; y++) + { + for (int x = 0; x < sizeX; x++) + { + array[y * sizeX + x] = 1; + } + } +#else + for (int i = 0; i < sizeY; i++) + { + for (int j = 0; j < sizeX; j++) + { + array[i * sizeX + j] = 1; + } + } +#endif + } } } diff --git a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs index 9b832955c..c43f30eb1 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs @@ -295,6 +295,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms // special case for loop counters, // we don't want them to be named i, i2, ..., but i, j, ... newName = GenerateNameForVariable(v); + nameWithoutNumber = newName; + newIndex = 1; } else {