diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index 941e2d87c..32dcb0c60 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -100,6 +100,7 @@ + @@ -143,6 +144,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs index 2fc5bbc87..d95206510 100644 --- a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs @@ -219,6 +219,12 @@ namespace ICSharpCode.Decompiler.Tests await Run(); } + [Test] + public async Task Issue3465() + { + await Run(); + } + [Test] public async Task Issue3466() { @@ -319,7 +325,7 @@ namespace ICSharpCode.Decompiler.Tests var executable = await Tester.AssembleIL(ilFile, assemblerOptions).ConfigureAwait(false); var decompiled = await Tester.DecompileCSharp(executable, settings).ConfigureAwait(false); - CodeAssert.FilesAreEqual(csFile, decompiled); + CodeAssert.FilesAreEqual(csFile, decompiled, ["EXPECTED_OUTPUT"]); Tester.RepeatOnIOError(() => File.Delete(decompiled)); } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.cs new file mode 100644 index 000000000..1fc80f847 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.cs @@ -0,0 +1,23 @@ +using System; +#if EXPECTED_OUTPUT +using System.Runtime.CompilerServices; +#endif +namespace Issue3465 +{ + internal class Program + { + private static Program programNull; + + private static Program GetProgram() + { + return null; + } + + private static bool Test3465() + { + Program program = GetProgram(); + Program program2 = programNull; + return System.Runtime.CompilerServices.Unsafe.As(ref program) > System.Runtime.CompilerServices.Unsafe.As(ref program2); + } + } +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.il b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.il new file mode 100644 index 000000000..7aa0b7f6d --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.il @@ -0,0 +1,60 @@ +.class private auto ansi '' +{ +} // end of class + +.class private auto ansi beforefieldinit Issue3465.Program + extends [System.Runtime]System.Object +{ + // Fields + .field private static class Issue3465.Program programNull + + // Methods + .method private hidebysig static + class Issue3465.Program GetProgram () cil managed + { + // Method begins at RVA 0x2050 + // Header size: 1 + // Code size: 2 (0x2) + .maxstack 8 + + IL_0000: ldnull + IL_0001: ret + } // end of method Issue3465.Program::GetProgram + + .method private hidebysig static + bool Test3465 () cil managed + { + // Method begins at RVA 0x2054 + // Header size: 12 + // Code size: 7 (0x7) + .maxstack 1 + .locals init ( + [0] bool + ) + + IL_0000: call class Issue3465.Program Issue3465.Program::GetProgram() + IL_0001: ldsfld class Issue3465.Program Issue3465.Program::programNull + cgt.un + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method Program::Test3465 + + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x2067 + // Header size: 1 + // Code size: 8 (0x8) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method Issue3465.Program::.ctor + +} // end of class Issue3465.Program +