diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index c13352fec..c43c7db0d 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -101,6 +101,7 @@
+
@@ -145,6 +146,7 @@
+
diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
index 4bfbfb812..1f02fcd73 100644
--- a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
@@ -225,6 +225,12 @@ namespace ICSharpCode.Decompiler.Tests
await Run();
}
+ [Test]
+ public async Task Issue3465()
+ {
+ await Run();
+ }
+
[Test]
public async Task Issue3466()
{
@@ -325,7 +331,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..8f0aa9432
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3465.cs
@@ -0,0 +1,22 @@
+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();
+ return System.Runtime.CompilerServices.Unsafe.As(ref program) > System.Runtime.CompilerServices.Unsafe.As(ref programNull);
+ }
+ }
+}
\ 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
+
diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
index 91010db44..4c038c621 100644
--- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
+++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
@@ -1110,6 +1110,21 @@ namespace ICSharpCode.Decompiler.CSharp
left = left.ConvertTo(inputType, this);
right = right.ConvertTo(inputType, this);
}
+ else if (inst.InputType == StackType.O)
+ {
+ // Unsafe.As