diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index d581a3ffd..50bc5be58 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -96,6 +96,7 @@ + @@ -138,6 +139,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs index abdc031fa..57fa18c7c 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 Issue3504() + { + await Run(); + } + [Test] public async Task Issue2260SwitchString() { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3504.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3504.cs new file mode 100644 index 000000000..c5d8238f0 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3504.cs @@ -0,0 +1,9 @@ +using System; + +internal class Issue3504 +{ + private void Method(Console console) + { + console.WriteLine("Hello."); + } +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3504.il b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3504.il new file mode 100644 index 000000000..6637e6f9e --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue3504.il @@ -0,0 +1,36 @@ +.class private auto ansi beforefieldinit Issue3504 + extends [System.Runtime]System.Object +{ + // Methods + .method private hidebysig + instance void Method (class [System.Console]System.Console console) cil managed + { + // Method begins at RVA 0x2050 + // Header size: 1 + // Code size: 13 (0xd) + .maxstack 8 + + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldstr "Hello." + IL_0007: call instance void [System.Console]System.Console::WriteLine(string) + IL_000b: nop + IL_000c: ret + } // end of method Issue3504::Method + + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x205e + // 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 Issue3504::.ctor + +} // end of class Issue3504 + diff --git a/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs b/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs index bc7ff1bb4..ec0cdca4e 100644 --- a/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs +++ b/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs @@ -535,6 +535,8 @@ namespace ICSharpCode.Decompiler.TypeSystem { if (m.TypeParameters.Count != signature.GenericParameterCount) continue; + if (signature.Header.IsInstance != !m.IsStatic) + continue; if (CompareSignatures(m.Parameters, parameterTypes) && CompareTypes(m.ReturnType, signature.ReturnType)) { method = m;