Browse Source

#1080: Add test case

pull/1087/head
Siegfried Pammer 7 years ago
parent
commit
daa48fbd3a
  1. 1
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 6
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 54
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue1080.cs
  4. 115
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue1080.opt.roslyn.il
  5. 125
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue1080.roslyn.il
  6. 1
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  7. 2
      ILSpy/Properties/launchSettings.json

1
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -65,6 +65,7 @@ @@ -65,6 +65,7 @@
<Compile Include="Semantics\OverloadResolutionTests.cs" />
<Compile Include="DataFlowTest.cs" />
<Compile Include="TestCases\Correctness\RefLocalsAndReturns.cs" />
<Compile Include="TestCases\Pretty\Issue1080.cs" />
<Compile Include="TestCases\Pretty\RefLocalsAndReturns.cs" />
<Compile Include="TestCases\Pretty\WellKnownConstants.cs" />
<Compile Include="VBPrettyTestRunner.cs" />

6
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -273,6 +273,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -273,6 +273,12 @@ namespace ICSharpCode.Decompiler.Tests
RunForLibrary(cscOptions: cscOptions);
}
[Test]
public void Issue1080([ValueSource(nameof(roslynOnlyOptions))] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions);
}
void RunForLibrary([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CSharpCompilerOptions cscOptions = CSharpCompilerOptions.None, DecompilerSettings decompilerSettings = null)
{
Run(testName, asmOptions | AssemblerOptions.Library, cscOptions | CSharpCompilerOptions.Library, decompilerSettings);

54
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue1080.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
using ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA;
using ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB;
using ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080
{
internal static class ExtensionsTest
{
private static void Dummy(ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2 intf)
{
}
private static void Test(object obj)
{
ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2 type = obj as ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2;
if (type != null) {
ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions.Extension(type);
}
}
}
}
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB
{
internal interface Type2 : Type1
{
}
}
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA
{
internal interface Type2 : ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2, Type1
{
}
}
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC
{
internal static class Extensions
{
public static void Extension(this Type1 obj)
{
}
}
}
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB
{
internal interface Type1
{
}
internal static class Extensions
{
public static void Extension(this Type1 obj)
{
}
}
}

115
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue1080.opt.roslyn.il

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly Issue1080
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module Issue1080.dll
// MVID: {4B5AAFB9-5929-4193-B624-4F81D8D3C1BB}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x038A0000
// =============== CLASS MEMBERS DECLARATION ===================
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.ExtensionsTest
extends [mscorlib]System.Object
{
.method private hidebysig static void Dummy(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2 intf) cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method ExtensionsTest::Dummy
.method private hidebysig static void Test(object obj) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2 V_0)
IL_0000: ldarg.0
IL_0001: isinst ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0010
IL_000a: ldloc.0
IL_000b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions::Extension(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1)
IL_0010: ret
} // end of method ExtensionsTest::Test
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.ExtensionsTest
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig static void Extension(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1 obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Extensions::Extension
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions
.class interface private abstract auto ansi ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2,
ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
{
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2
.class interface private abstract auto ansi ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
{
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
.class interface private abstract auto ansi ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
{
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Extensions
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig static void Extension(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1 obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Extensions::Extension
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Extensions
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

125
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue1080.roslyn.il

@ -0,0 +1,125 @@ @@ -0,0 +1,125 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly Issue1080
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module Issue1080.dll
// MVID: {C55AD4DD-F921-48E6-8863-FBA5C2E3280E}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x04C30000
// =============== CLASS MEMBERS DECLARATION ===================
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.ExtensionsTest
extends [mscorlib]System.Object
{
.method private hidebysig static void Dummy(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2 intf) cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method ExtensionsTest::Dummy
.method private hidebysig static void Test(object obj) cil managed
{
// Code size 24 (0x18)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2 V_0,
bool V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: isinst ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2
IL_0007: stloc.0
IL_0008: ldloc.0
IL_0009: ldnull
IL_000a: cgt.un
IL_000c: stloc.1
IL_000d: ldloc.1
IL_000e: brfalse.s IL_0017
IL_0010: ldloc.0
IL_0011: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions::Extension(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1)
IL_0016: nop
IL_0017: ret
} // end of method ExtensionsTest::Test
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.ExtensionsTest
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig static void Extension(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1 obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Extensions::Extension
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceC.Extensions
.class interface private abstract auto ansi ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2,
ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
{
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.Type2
.class interface private abstract auto ansi ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
{
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
.class interface private abstract auto ansi ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1
{
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type2
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Extensions
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig static void Extension(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Type1 obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Extensions::Extension
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Issue1080.SpaceA.SpaceB.Extensions
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

1
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -638,7 +638,6 @@ namespace ICSharpCode.Decompiler.CSharp @@ -638,7 +638,6 @@ namespace ICSharpCode.Decompiler.CSharp
public static void CollectNamespacesForDecompilation(IEnumerable<IMemberDefinition> memberDefinitions, HashSet<string> namespaces)
{
var visitedItems = new HashSet<MemberReference>();
foreach (var def in memberDefinitions) {
switch (def) {
case TypeDefinition typeDef:

2
ILSpy/Properties/launchSettings.json

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
"profiles": {
"ILSpy": {
"commandName": "Executable",
"executablePath": "$(OutDir)$(AssemblyName)$(TargetExt)",
"executablePath": "C:\\Users\\Siegfried\\Projects\\ILSpy master\\ILSpy\\bin\\Debug\\net46\\ILSpy.exe",
"commandLineArgs": "/separate"
}
}

Loading…
Cancel
Save