From 9ee029a4986ac69d1e12413c94ca3d63c37341f4 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 19 Jul 2025 11:22:28 +0200 Subject: [PATCH] #3518: Add test --- .../ICSharpCode.Decompiler.Tests.csproj | 2 + .../ILPrettyTestRunner.cs | 6 ++ .../TestCases/ILPretty/Issue3513.cs | 22 ++++++ .../TestCases/ILPretty/Issue3513.il | 68 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.cs create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.il diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index 2c3e9f93f..301ff4f4c 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -100,6 +100,7 @@ + @@ -142,6 +143,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs index 57fa18c7c..f55e8f729 100644 --- a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs @@ -299,6 +299,12 @@ namespace ICSharpCode.Decompiler.Tests await Run(); } + [Test] + public async Task Issue3513() + { + await Run(); + } + async Task Run([CallerMemberName] string testName = null, DecompilerSettings settings = null, AssemblerOptions assemblerOptions = AssemblerOptions.Library) { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.cs new file mode 100644 index 000000000..e1e7f2d65 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.cs @@ -0,0 +1,22 @@ +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.DisableOptimizations)] +[assembly: My(/*Could not decode attribute arguments.*/)] +[assembly: AssemblyVersion("0.0.0.0")] + +public class MyAttribute : Attribute +{ + [NullableContext(1)] + public MyAttribute(string x, Type t) + { + } +} + +public class ABCD`1 +{ +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.il b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.il new file mode 100644 index 000000000..13cf25e68 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3513.il @@ -0,0 +1,68 @@ +.assembly _ +{ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( + 01 00 08 00 00 00 00 00 + ) + .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( + 01 00 01 00 54 02 16 57 72 61 70 4e 6f 6e 45 78 + 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 + ) + .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( + 01 00 07 01 00 00 00 00 + ) + .custom instance void MyAttribute::.ctor(string, class [System.Runtime]System.Type) = ( + 01 00 04 61 73 64 66 0E 41 42 43 44 60 31 3C 73 74 72 69 6E 67 3E 00 00 + ) + .hash algorithm 0x00008004 // SHA1 + .ver 0:0:0:0 +} + +.class private auto ansi '' +{ +} // end of class + +.class public auto ansi beforefieldinit MyAttribute + extends [System.Runtime]System.Attribute +{ + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor ( + string x, + class [System.Runtime]System.Type t + ) cil managed + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( + 01 00 01 00 00 + ) + // Method begins at RVA 0x2050 + // Code size 9 (0x9) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() + IL_0006: nop + IL_0007: nop + IL_0008: ret + } // end of method MyAttribute::.ctor + +} // end of class MyAttribute + +.class public auto ansi beforefieldinit 'ABCD`1' + extends [System.Runtime]System.Object +{ + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x205a + // 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 ABCD::.ctor + +} // end of class ABCD +