Browse Source

Merge branch 'master' of github.com:icsharpcode/ILSpy into srm

pull/1198/head
Siegfried Pammer 7 years ago
parent
commit
5d8ddeff0e
  1. 2
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 2
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 16
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs
  4. 4
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs
  5. 879
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.mcs.il
  6. 879
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.opt.mcs.il
  7. 26
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs
  8. 1347
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.il
  9. 1243
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.opt.il
  10. 1534
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.opt.roslyn.il
  11. 1556
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.roslyn.il
  12. 1784
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs
  13. 675
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemTestCase.cs
  14. 2
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  15. 10
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpOperators.cs
  16. 38
      ICSharpCode.Decompiler/CSharp/Resolver/ReducedExtensionMethod.cs
  17. 13
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  18. 4
      ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs
  19. 5
      ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
  20. 5
      ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs
  21. 3
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  22. 62
      ICSharpCode.Decompiler/IL/ControlFlow/AwaitInCatchTransform.cs
  23. 53
      ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs
  24. 19
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs
  25. 13
      ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs
  26. 10
      ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs
  27. 5
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
  28. 2
      ICSharpCode.Decompiler/NRExtensions.cs
  29. 1704
      ICSharpCode.Decompiler/TypeSystem/CecilLoader.cs
  30. 2
      ICSharpCode.Decompiler/TypeSystem/IField.cs
  31. 13
      ICSharpCode.Decompiler/TypeSystem/IMember.cs
  32. 10
      ICSharpCode.Decompiler/TypeSystem/ISymbol.cs
  33. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs
  34. 16
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs
  35. 31
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
  36. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs
  37. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs
  38. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs
  39. 58
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultParameter.cs
  40. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedField.cs
  41. 13
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedMethod.cs
  42. 13
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedProperty.cs
  43. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs
  44. 61
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
  45. 7
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
  46. 30
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultVariable.cs
  47. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs
  48. 80
      ICSharpCode.Decompiler/TypeSystem/Implementation/ExplicitInterfaceImplementationMemberReference.cs
  49. 10
      ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
  50. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
  51. 10
      ICSharpCode.Decompiler/TypeSystem/Implementation/NestedTypeReference.cs
  52. 21
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
  53. 23
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMethod.cs
  54. 67
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializingMemberReference.cs
  55. 7
      ICSharpCode.Decompiler/TypeSystem/Implementation/TypeParameterReference.cs
  56. 56
      ICSharpCode.Decompiler/TypeSystem/ProjectReference.cs
  57. 152
      ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
  58. 12
      ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs
  59. 270
      ILSpy.AddIn/CodeElementXmlDocKeyProvider.cs
  60. 64
      ILSpy.AddIn/Commands/OpenCodeItemCommand.cs
  61. 39
      ILSpy.AddIn/Commands/OpenILSpyCommand.cs
  62. 9
      ILSpy.AddIn/Commands/OpenProjectOutputCommand.cs
  63. 28
      ILSpy.AddIn/Commands/OpenReferenceCommand.cs
  64. 2
      ILSpy.AddIn/ILSpy.AddIn.csproj
  65. 2
      ILSpy.AddIn/ILSpyAddInPackage.cs
  66. 414
      ILSpy.AddIn/Samples/ILSpyAddInSamples.cs
  67. 28
      ILSpy/Commands/DecompileAllCommand.cs

2
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -69,6 +69,8 @@ @@ -69,6 +69,8 @@
<Compile Include="TestCases\Pretty\QualifierTests.cs" />
<Compile Include="TestCases\Pretty\RefLocalsAndReturns.cs" />
<Compile Include="TestCases\Pretty\WellKnownConstants.cs" />
<Compile Include="TypeSystem\TypeSystemLoaderTests.cs" />
<Compile Include="TypeSystem\TypeSystemTestCase.cs" />
<Compile Include="VBPrettyTestRunner.cs" />
<Compile Include="TestCases\VBPretty\Async.cs" />
<Compile Include="UglyTestRunner.cs" />

2
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
public void AnonymousTypes([ValueSource("defaultOptions")] CSharpCompilerOptions cscOptions)
public void AnonymousTypes([ValueSource("defaultOptionsWithMcs")] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions);
}

16
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs

@ -57,6 +57,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -57,6 +57,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
await AwaitInCatch(Task.FromResult(1), Task.FromResult(2));
await AwaitInFinally(Task.FromResult(2), Task.FromResult(4));
await AwaitInCatchAndFinally(Task.FromResult(3), Task.FromResult(6), Task.FromResult(9));
Console.WriteLine(await AwaitInFinallyInUsing(Task.FromResult<IDisposable>(new StringWriter()), Task.FromResult(6), Task.FromResult(9)));
#endif
}
@ -264,6 +265,21 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -264,6 +265,21 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
}
Console.WriteLine("End Method");
}
public async Task<int> AwaitInFinallyInUsing(Task<IDisposable> task1, Task<int> task2, Task<int> task3)
{
using (await task1) {
Console.WriteLine("Start using");
try {
Console.WriteLine("Before return");
return await task2;
} finally {
Console.WriteLine("Start finally");
await task3;
Console.WriteLine("End finally");
}
}
}
#endif
}
}

4
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -66,7 +66,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(array[1].X);
#endif
}
#if !MCS
private void JaggedArray()
{
var array = new[] {
@ -101,7 +101,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -101,7 +101,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(array2.Length);
#endif
}
#endif
#if CS70
private void AnonymousTypeOutVar()
{

879
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.mcs.il

@ -0,0 +1,879 @@ @@ -0,0 +1,879 @@
// Metadata version: v2.0.50727
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly AnonymousTypes.mcs
{
.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.
.permissionset reqmin
bytearray (3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
53 00 65 00 74 00 22 00 0D 00 0A 00 76 00 65 00 // S.e.t.".....v.e.
72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1.
22 00 3E 00 0D 00 0A 00 3C 00 49 00 50 00 65 00 // ".>.....<.I.P.e.
72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
6E 00 3D 00 32 00 2E 00 30 00 2E 00 30 00 2E 00 // n.=.2...0...0...
30 00 2C 00 20 00 43 00 75 00 6C 00 74 00 75 00 // 0.,. .C.u.l.t.u.
72 00 65 00 3D 00 6E 00 65 00 75 00 74 00 72 00 // r.e.=.n.e.u.t.r.
61 00 6C 00 2C 00 20 00 50 00 75 00 62 00 6C 00 // a.l.,. .P.u.b.l.
69 00 63 00 4B 00 65 00 79 00 54 00 6F 00 6B 00 // i.c.K.e.y.T.o.k.
65 00 6E 00 3D 00 62 00 37 00 37 00 61 00 35 00 // e.n.=.b.7.7.a.5.
63 00 35 00 36 00 31 00 39 00 33 00 34 00 65 00 // c.5.6.1.9.3.4.e.
30 00 38 00 39 00 22 00 0D 00 0A 00 76 00 65 00 // 0.8.9.".....v.e.
72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1.
22 00 0D 00 0A 00 46 00 6C 00 61 00 67 00 73 00 // ".....F.l.a.g.s.
3D 00 22 00 53 00 6B 00 69 00 70 00 56 00 65 00 // =.".S.k.i.p.V.e.
72 00 69 00 66 00 69 00 63 00 61 00 74 00 69 00 // r.i.f.i.c.a.t.i.
6F 00 6E 00 22 00 2F 00 3E 00 0D 00 0A 00 3C 00 // o.n."./.>.....<.
2F 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // /.P.e.r.m.i.s.s.
69 00 6F 00 6E 00 53 00 65 00 74 00 3E 00 0D 00 // i.o.n.S.e.t.>...
0A 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module AnonymousTypes.mcs.dll
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.AnonymousTypes
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method AnonymousTypes::.ctor
.method private hidebysig instance void
SimpleTypes() cil managed
{
// Code size 58 (0x3a)
.maxstack 11
.locals init (class '<>__AnonType0' V_0,
class '<>__AnonType1`1'<int32> V_1,
class '<>__AnonType2`2'<int32,int32> V_2)
IL_0000: newobj instance void '<>__AnonType0'::.ctor()
IL_0005: stloc.0
IL_0006: ldc.i4.5
IL_0007: newobj instance void class '<>__AnonType1`1'<int32>::.ctor(!0)
IL_000c: stloc.1
IL_000d: ldc.i4.5
IL_000e: ldc.i4.s 10
IL_0010: newobj instance void class '<>__AnonType2`2'<int32,int32>::.ctor(!0,
!1)
IL_0015: stloc.2
IL_0016: ldloc.0
IL_0017: call void [mscorlib]System.Console::WriteLine(object)
IL_001c: ldloc.1
IL_001d: callvirt instance !0 class '<>__AnonType1`1'<int32>::get_X()
IL_0022: call void [mscorlib]System.Console::WriteLine(int32)
IL_0027: ldloc.2
IL_0028: callvirt instance !1 class '<>__AnonType2`2'<int32,int32>::get_Y()
IL_002d: ldloc.2
IL_002e: callvirt instance !0 class '<>__AnonType2`2'<int32,int32>::get_X()
IL_0033: add
IL_0034: call void [mscorlib]System.Console::WriteLine(int32)
IL_0039: ret
} // end of method AnonymousTypes::SimpleTypes
.method private hidebysig instance void
SimpleArray() cil managed
{
// Code size 57 (0x39)
.maxstack 7
.locals init (class '<>__AnonType3`3'<int32,int32,int32>[] V_0)
IL_0000: ldc.i4.2
IL_0001: newarr class '<>__AnonType3`3'<int32,int32,int32>
IL_0006: dup
IL_0007: ldc.i4.0
IL_0008: ldc.i4.5
IL_0009: ldc.i4.2
IL_000a: ldc.i4.m1
IL_000b: newobj instance void class '<>__AnonType3`3'<int32,int32,int32>::.ctor(!0,
!1,
!2)
IL_0010: stelem.ref
IL_0011: dup
IL_0012: ldc.i4.1
IL_0013: ldc.i4.3
IL_0014: ldc.i4.6
IL_0015: ldc.i4.s -6
IL_0017: newobj instance void class '<>__AnonType3`3'<int32,int32,int32>::.ctor(!0,
!1,
!2)
IL_001c: stelem.ref
IL_001d: stloc.0
IL_001e: ldloc.0
IL_001f: ldc.i4.0
IL_0020: ldelem.ref
IL_0021: callvirt instance !0 class '<>__AnonType3`3'<int32,int32,int32>::get_X()
IL_0026: call void [mscorlib]System.Console::WriteLine(int32)
IL_002b: ldloc.0
IL_002c: ldc.i4.1
IL_002d: ldelem.ref
IL_002e: callvirt instance !0 class '<>__AnonType3`3'<int32,int32,int32>::get_X()
IL_0033: call void [mscorlib]System.Console::WriteLine(int32)
IL_0038: ret
} // end of method AnonymousTypes::SimpleArray
.method private hidebysig static void InlineVarDecl<T>([out] !!T& v,
!!T 'init') cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stobj !!T
IL_0007: ret
} // end of method AnonymousTypes::InlineVarDecl
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.AnonymousTypes
.class private auto ansi sealed beforefieldinit '<>__AnonType0'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method '<>__AnonType0'::.ctor
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 15 (0xf)
.maxstack 3
.locals init (class '<>__AnonType0' V_0)
IL_0000: ldarg.1
IL_0001: isinst '<>__AnonType0'
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldnull
IL_0009: ceq
IL_000b: ldc.i4.0
IL_000c: ceq
IL_000e: ret
} // end of method '<>__AnonType0'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 40 (0x28)
.maxstack 4
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.s 13
IL_000a: shl
IL_000b: add
IL_000c: stloc.0
IL_000d: ldloc.0
IL_000e: ldloc.0
IL_000f: ldc.i4.7
IL_0010: shr
IL_0011: xor
IL_0012: stloc.0
IL_0013: ldloc.0
IL_0014: ldloc.0
IL_0015: ldc.i4.3
IL_0016: shl
IL_0017: add
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: ldloc.0
IL_001b: ldc.i4.s 17
IL_001d: shr
IL_001e: xor
IL_001f: stloc.0
IL_0020: ldloc.0
IL_0021: ldloc.0
IL_0022: ldc.i4.5
IL_0023: shl
IL_0024: add
IL_0025: stloc.0
IL_0026: ldloc.0
IL_0027: ret
} // end of method '<>__AnonType0'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldstr "{ }"
IL_0005: ret
} // end of method '<>__AnonType0'::ToString
} // end of class '<>__AnonType0'
.class private auto ansi sealed beforefieldinit '<>__AnonType1`1'<'<X>__T'>
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private initonly !'<X>__T' '<X>'
.method public hidebysig specialname rtspecialname
instance void .ctor(!'<X>__T' X) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_000d: ret
} // end of method '<>__AnonType1`1'::.ctor
.method public hidebysig specialname instance !'<X>__T'
get_X() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0006: ret
} // end of method '<>__AnonType1`1'::get_X
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 39 (0x27)
.maxstack 5
.locals init (class '<>__AnonType1`1'<!'<X>__T'> V_0)
IL_0000: ldarg.1
IL_0001: isinst class '<>__AnonType1`1'<!'<X>__T'>
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse IL_0025
IL_000d: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_0012: ldarg.0
IL_0013: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0018: ldloc.0
IL_0019: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_001e: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::Equals(!0,
!0)
IL_0023: br.s IL_0026
IL_0025: ldc.i4.0
IL_0026: ret
} // end of method '<>__AnonType1`1'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 63 (0x3f)
.maxstack 7
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0010: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::GetHashCode(!0)
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: stloc.0
IL_001d: ldloc.0
IL_001e: ldloc.0
IL_001f: ldc.i4.s 13
IL_0021: shl
IL_0022: add
IL_0023: stloc.0
IL_0024: ldloc.0
IL_0025: ldloc.0
IL_0026: ldc.i4.7
IL_0027: shr
IL_0028: xor
IL_0029: stloc.0
IL_002a: ldloc.0
IL_002b: ldloc.0
IL_002c: ldc.i4.3
IL_002d: shl
IL_002e: add
IL_002f: stloc.0
IL_0030: ldloc.0
IL_0031: ldloc.0
IL_0032: ldc.i4.s 17
IL_0034: shr
IL_0035: xor
IL_0036: stloc.0
IL_0037: ldloc.0
IL_0038: ldloc.0
IL_0039: ldc.i4.5
IL_003a: shl
IL_003b: add
IL_003c: stloc.0
IL_003d: ldloc.0
IL_003e: ret
} // end of method '<>__AnonType1`1'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 67 (0x43)
.maxstack 8
.locals init (!'<X>__T' V_0)
IL_0000: ldstr "{"
IL_0005: ldstr " X = "
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0010: box !'<X>__T'
IL_0015: brfalse IL_0033
IL_001a: ldarg.0
IL_001b: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0020: stloc.0
IL_0021: ldloca.s V_0
IL_0023: constrained. !'<X>__T'
IL_0029: callvirt instance string [mscorlib]System.Object::ToString()
IL_002e: br IL_0038
IL_0033: ldstr ""
IL_0038: ldstr " }"
IL_003d: call string [mscorlib]System.String::Concat(string,
string,
string,
string)
IL_0042: ret
} // end of method '<>__AnonType1`1'::ToString
.property !'<X>__T' X()
{
.get instance !'<X>__T' '<>__AnonType1`1'::get_X()
} // end of property '<>__AnonType1`1'::X
} // end of class '<>__AnonType1`1'
.class private auto ansi sealed beforefieldinit '<>__AnonType2`2'<'<X>__T','<Y>__T'>
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private initonly !'<X>__T' '<X>'
.field private initonly !'<Y>__T' '<Y>'
.method public hidebysig specialname rtspecialname
instance void .ctor(!'<X>__T' X,
!'<Y>__T' Y) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 21 (0x15)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_000d: ldarg.0
IL_000e: ldarg.2
IL_000f: stfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0014: ret
} // end of method '<>__AnonType2`2'::.ctor
.method public hidebysig specialname instance !'<X>__T'
get_X() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_0006: ret
} // end of method '<>__AnonType2`2'::get_X
.method public hidebysig specialname instance !'<Y>__T'
get_Y() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0006: ret
} // end of method '<>__AnonType2`2'::get_Y
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 69 (0x45)
.maxstack 9
.locals init (class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'> V_0)
IL_0000: ldarg.1
IL_0001: isinst class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse IL_0043
IL_000d: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_0012: ldarg.0
IL_0013: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_0018: ldloc.0
IL_0019: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_001e: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::Equals(!0,
!0)
IL_0023: brfalse IL_0040
IL_0028: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_002d: ldarg.0
IL_002e: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0033: ldloc.0
IL_0034: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0039: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::Equals(!0,
!0)
IL_003e: br.s IL_0041
IL_0040: ldc.i4.0
IL_0041: br.s IL_0044
IL_0043: ldc.i4.0
IL_0044: ret
} // end of method '<>__AnonType2`2'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 86 (0x56)
.maxstack 10
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_0010: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::GetHashCode(!0)
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_0021: ldarg.0
IL_0022: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0027: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::GetHashCode(!0)
IL_002c: xor
IL_002d: ldc.i4 0x1000193
IL_0032: mul
IL_0033: stloc.0
IL_0034: ldloc.0
IL_0035: ldloc.0
IL_0036: ldc.i4.s 13
IL_0038: shl
IL_0039: add
IL_003a: stloc.0
IL_003b: ldloc.0
IL_003c: ldloc.0
IL_003d: ldc.i4.7
IL_003e: shr
IL_003f: xor
IL_0040: stloc.0
IL_0041: ldloc.0
IL_0042: ldloc.0
IL_0043: ldc.i4.3
IL_0044: shl
IL_0045: add
IL_0046: stloc.0
IL_0047: ldloc.0
IL_0048: ldloc.0
IL_0049: ldc.i4.s 17
IL_004b: shr
IL_004c: xor
IL_004d: stloc.0
IL_004e: ldloc.0
IL_004f: ldloc.0
IL_0050: ldc.i4.5
IL_0051: shl
IL_0052: add
IL_0053: stloc.0
IL_0054: ldloc.0
IL_0055: ret
} // end of method '<>__AnonType2`2'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 142 (0x8e)
.maxstack 10
.locals init (!'<X>__T' V_0,
!'<Y>__T' V_1)
IL_0000: ldc.i4.6
IL_0001: newarr [mscorlib]System.String
IL_0006: dup
IL_0007: ldc.i4.0
IL_0008: ldstr "{"
IL_000d: stelem.ref
IL_000e: dup
IL_000f: ldc.i4.1
IL_0010: ldstr " X = "
IL_0015: stelem.ref
IL_0016: dup
IL_0017: ldc.i4.2
IL_0018: ldarg.0
IL_0019: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_001e: box !'<X>__T'
IL_0023: brfalse IL_0041
IL_0028: ldarg.0
IL_0029: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_002e: stloc.0
IL_002f: ldloca.s V_0
IL_0031: constrained. !'<X>__T'
IL_0037: callvirt instance string [mscorlib]System.Object::ToString()
IL_003c: br IL_0046
IL_0041: ldstr ""
IL_0046: stelem.ref
IL_0047: dup
IL_0048: ldc.i4.3
IL_0049: ldstr ", Y = "
IL_004e: stelem.ref
IL_004f: dup
IL_0050: ldc.i4.4
IL_0051: ldarg.0
IL_0052: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0057: box !'<Y>__T'
IL_005c: brfalse IL_007a
IL_0061: ldarg.0
IL_0062: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0067: stloc.1
IL_0068: ldloca.s V_1
IL_006a: constrained. !'<Y>__T'
IL_0070: callvirt instance string [mscorlib]System.Object::ToString()
IL_0075: br IL_007f
IL_007a: ldstr ""
IL_007f: stelem.ref
IL_0080: dup
IL_0081: ldc.i4.5
IL_0082: ldstr " }"
IL_0087: stelem.ref
IL_0088: call string [mscorlib]System.String::Concat(string[])
IL_008d: ret
} // end of method '<>__AnonType2`2'::ToString
.property !'<X>__T' X()
{
.get instance !'<X>__T' '<>__AnonType2`2'::get_X()
} // end of property '<>__AnonType2`2'::X
.property !'<Y>__T' Y()
{
.get instance !'<Y>__T' '<>__AnonType2`2'::get_Y()
} // end of property '<>__AnonType2`2'::Y
} // end of class '<>__AnonType2`2'
.class private auto ansi sealed beforefieldinit '<>__AnonType3`3'<'<X>__T','<Y>__T','<Z>__T'>
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private initonly !'<X>__T' '<X>'
.field private initonly !'<Y>__T' '<Y>'
.field private initonly !'<Z>__T' '<Z>'
.method public hidebysig specialname rtspecialname
instance void .ctor(!'<X>__T' X,
!'<Y>__T' Y,
!'<Z>__T' Z) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 28 (0x1c)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_000d: ldarg.0
IL_000e: ldarg.2
IL_000f: stfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0014: ldarg.0
IL_0015: ldarg.3
IL_0016: stfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_001b: ret
} // end of method '<>__AnonType3`3'::.ctor
.method public hidebysig specialname instance !'<X>__T'
get_X() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_0006: ret
} // end of method '<>__AnonType3`3'::get_X
.method public hidebysig specialname instance !'<Y>__T'
get_Y() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0006: ret
} // end of method '<>__AnonType3`3'::get_Y
.method public hidebysig specialname instance !'<Z>__T'
get_Z() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_0006: ret
} // end of method '<>__AnonType3`3'::get_Z
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 96 (0x60)
.maxstack 12
.locals init (class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'> V_0)
IL_0000: ldarg.1
IL_0001: isinst class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse IL_005e
IL_000d: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_0012: ldarg.0
IL_0013: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_0018: ldloc.0
IL_0019: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_001e: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::Equals(!0,
!0)
IL_0023: brfalse IL_005b
IL_0028: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_002d: ldarg.0
IL_002e: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0033: ldloc.0
IL_0034: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0039: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::Equals(!0,
!0)
IL_003e: brfalse IL_005b
IL_0043: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::get_Default()
IL_0048: ldarg.0
IL_0049: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_004e: ldloc.0
IL_004f: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_0054: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::Equals(!0,
!0)
IL_0059: br.s IL_005c
IL_005b: ldc.i4.0
IL_005c: br.s IL_005f
IL_005e: ldc.i4.0
IL_005f: ret
} // end of method '<>__AnonType3`3'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 109 (0x6d)
.maxstack 13
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_0010: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::GetHashCode(!0)
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_0021: ldarg.0
IL_0022: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0027: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::GetHashCode(!0)
IL_002c: xor
IL_002d: ldc.i4 0x1000193
IL_0032: mul
IL_0033: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::get_Default()
IL_0038: ldarg.0
IL_0039: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_003e: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::GetHashCode(!0)
IL_0043: xor
IL_0044: ldc.i4 0x1000193
IL_0049: mul
IL_004a: stloc.0
IL_004b: ldloc.0
IL_004c: ldloc.0
IL_004d: ldc.i4.s 13
IL_004f: shl
IL_0050: add
IL_0051: stloc.0
IL_0052: ldloc.0
IL_0053: ldloc.0
IL_0054: ldc.i4.7
IL_0055: shr
IL_0056: xor
IL_0057: stloc.0
IL_0058: ldloc.0
IL_0059: ldloc.0
IL_005a: ldc.i4.3
IL_005b: shl
IL_005c: add
IL_005d: stloc.0
IL_005e: ldloc.0
IL_005f: ldloc.0
IL_0060: ldc.i4.s 17
IL_0062: shr
IL_0063: xor
IL_0064: stloc.0
IL_0065: ldloc.0
IL_0066: ldloc.0
IL_0067: ldc.i4.5
IL_0068: shl
IL_0069: add
IL_006a: stloc.0
IL_006b: ldloc.0
IL_006c: ret
} // end of method '<>__AnonType3`3'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 199 (0xc7)
.maxstack 13
.locals init (!'<X>__T' V_0,
!'<Y>__T' V_1,
!'<Z>__T' V_2)
IL_0000: ldc.i4.8
IL_0001: newarr [mscorlib]System.String
IL_0006: dup
IL_0007: ldc.i4.0
IL_0008: ldstr "{"
IL_000d: stelem.ref
IL_000e: dup
IL_000f: ldc.i4.1
IL_0010: ldstr " X = "
IL_0015: stelem.ref
IL_0016: dup
IL_0017: ldc.i4.2
IL_0018: ldarg.0
IL_0019: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_001e: box !'<X>__T'
IL_0023: brfalse IL_0041
IL_0028: ldarg.0
IL_0029: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_002e: stloc.0
IL_002f: ldloca.s V_0
IL_0031: constrained. !'<X>__T'
IL_0037: callvirt instance string [mscorlib]System.Object::ToString()
IL_003c: br IL_0046
IL_0041: ldstr ""
IL_0046: stelem.ref
IL_0047: dup
IL_0048: ldc.i4.3
IL_0049: ldstr ", Y = "
IL_004e: stelem.ref
IL_004f: dup
IL_0050: ldc.i4.4
IL_0051: ldarg.0
IL_0052: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0057: box !'<Y>__T'
IL_005c: brfalse IL_007a
IL_0061: ldarg.0
IL_0062: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0067: stloc.1
IL_0068: ldloca.s V_1
IL_006a: constrained. !'<Y>__T'
IL_0070: callvirt instance string [mscorlib]System.Object::ToString()
IL_0075: br IL_007f
IL_007a: ldstr ""
IL_007f: stelem.ref
IL_0080: dup
IL_0081: ldc.i4.5
IL_0082: ldstr ", Z = "
IL_0087: stelem.ref
IL_0088: dup
IL_0089: ldc.i4.6
IL_008a: ldarg.0
IL_008b: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_0090: box !'<Z>__T'
IL_0095: brfalse IL_00b3
IL_009a: ldarg.0
IL_009b: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_00a0: stloc.2
IL_00a1: ldloca.s V_2
IL_00a3: constrained. !'<Z>__T'
IL_00a9: callvirt instance string [mscorlib]System.Object::ToString()
IL_00ae: br IL_00b8
IL_00b3: ldstr ""
IL_00b8: stelem.ref
IL_00b9: dup
IL_00ba: ldc.i4.7
IL_00bb: ldstr " }"
IL_00c0: stelem.ref
IL_00c1: call string [mscorlib]System.String::Concat(string[])
IL_00c6: ret
} // end of method '<>__AnonType3`3'::ToString
.property !'<X>__T' X()
{
.get instance !'<X>__T' '<>__AnonType3`3'::get_X()
} // end of property '<>__AnonType3`3'::X
.property !'<Y>__T' Y()
{
.get instance !'<Y>__T' '<>__AnonType3`3'::get_Y()
} // end of property '<>__AnonType3`3'::Y
.property !'<Z>__T' Z()
{
.get instance !'<Z>__T' '<>__AnonType3`3'::get_Z()
} // end of property '<>__AnonType3`3'::Z
} // end of class '<>__AnonType3`3'
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

879
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.opt.mcs.il

@ -0,0 +1,879 @@ @@ -0,0 +1,879 @@
// Metadata version: v2.0.50727
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly AnonymousTypes.opt.mcs
{
.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.
.permissionset reqmin
bytearray (3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
53 00 65 00 74 00 22 00 0D 00 0A 00 76 00 65 00 // S.e.t.".....v.e.
72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1.
22 00 3E 00 0D 00 0A 00 3C 00 49 00 50 00 65 00 // ".>.....<.I.P.e.
72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
6E 00 3D 00 32 00 2E 00 30 00 2E 00 30 00 2E 00 // n.=.2...0...0...
30 00 2C 00 20 00 43 00 75 00 6C 00 74 00 75 00 // 0.,. .C.u.l.t.u.
72 00 65 00 3D 00 6E 00 65 00 75 00 74 00 72 00 // r.e.=.n.e.u.t.r.
61 00 6C 00 2C 00 20 00 50 00 75 00 62 00 6C 00 // a.l.,. .P.u.b.l.
69 00 63 00 4B 00 65 00 79 00 54 00 6F 00 6B 00 // i.c.K.e.y.T.o.k.
65 00 6E 00 3D 00 62 00 37 00 37 00 61 00 35 00 // e.n.=.b.7.7.a.5.
63 00 35 00 36 00 31 00 39 00 33 00 34 00 65 00 // c.5.6.1.9.3.4.e.
30 00 38 00 39 00 22 00 0D 00 0A 00 76 00 65 00 // 0.8.9.".....v.e.
72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1.
22 00 0D 00 0A 00 46 00 6C 00 61 00 67 00 73 00 // ".....F.l.a.g.s.
3D 00 22 00 53 00 6B 00 69 00 70 00 56 00 65 00 // =.".S.k.i.p.V.e.
72 00 69 00 66 00 69 00 63 00 61 00 74 00 69 00 // r.i.f.i.c.a.t.i.
6F 00 6E 00 22 00 2F 00 3E 00 0D 00 0A 00 3C 00 // o.n."./.>.....<.
2F 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // /.P.e.r.m.i.s.s.
69 00 6F 00 6E 00 53 00 65 00 74 00 3E 00 0D 00 // i.o.n.S.e.t.>...
0A 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module AnonymousTypes.opt.mcs.dll
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.AnonymousTypes
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method AnonymousTypes::.ctor
.method private hidebysig instance void
SimpleTypes() cil managed
{
// Code size 58 (0x3a)
.maxstack 11
.locals init (class '<>__AnonType0' V_0,
class '<>__AnonType1`1'<int32> V_1,
class '<>__AnonType2`2'<int32,int32> V_2)
IL_0000: newobj instance void '<>__AnonType0'::.ctor()
IL_0005: stloc.0
IL_0006: ldc.i4.5
IL_0007: newobj instance void class '<>__AnonType1`1'<int32>::.ctor(!0)
IL_000c: stloc.1
IL_000d: ldc.i4.5
IL_000e: ldc.i4.s 10
IL_0010: newobj instance void class '<>__AnonType2`2'<int32,int32>::.ctor(!0,
!1)
IL_0015: stloc.2
IL_0016: ldloc.0
IL_0017: call void [mscorlib]System.Console::WriteLine(object)
IL_001c: ldloc.1
IL_001d: callvirt instance !0 class '<>__AnonType1`1'<int32>::get_X()
IL_0022: call void [mscorlib]System.Console::WriteLine(int32)
IL_0027: ldloc.2
IL_0028: callvirt instance !1 class '<>__AnonType2`2'<int32,int32>::get_Y()
IL_002d: ldloc.2
IL_002e: callvirt instance !0 class '<>__AnonType2`2'<int32,int32>::get_X()
IL_0033: add
IL_0034: call void [mscorlib]System.Console::WriteLine(int32)
IL_0039: ret
} // end of method AnonymousTypes::SimpleTypes
.method private hidebysig instance void
SimpleArray() cil managed
{
// Code size 57 (0x39)
.maxstack 7
.locals init (class '<>__AnonType3`3'<int32,int32,int32>[] V_0)
IL_0000: ldc.i4.2
IL_0001: newarr class '<>__AnonType3`3'<int32,int32,int32>
IL_0006: dup
IL_0007: ldc.i4.0
IL_0008: ldc.i4.5
IL_0009: ldc.i4.2
IL_000a: ldc.i4.m1
IL_000b: newobj instance void class '<>__AnonType3`3'<int32,int32,int32>::.ctor(!0,
!1,
!2)
IL_0010: stelem.ref
IL_0011: dup
IL_0012: ldc.i4.1
IL_0013: ldc.i4.3
IL_0014: ldc.i4.6
IL_0015: ldc.i4.s -6
IL_0017: newobj instance void class '<>__AnonType3`3'<int32,int32,int32>::.ctor(!0,
!1,
!2)
IL_001c: stelem.ref
IL_001d: stloc.0
IL_001e: ldloc.0
IL_001f: ldc.i4.0
IL_0020: ldelem.ref
IL_0021: callvirt instance !0 class '<>__AnonType3`3'<int32,int32,int32>::get_X()
IL_0026: call void [mscorlib]System.Console::WriteLine(int32)
IL_002b: ldloc.0
IL_002c: ldc.i4.1
IL_002d: ldelem.ref
IL_002e: callvirt instance !0 class '<>__AnonType3`3'<int32,int32,int32>::get_X()
IL_0033: call void [mscorlib]System.Console::WriteLine(int32)
IL_0038: ret
} // end of method AnonymousTypes::SimpleArray
.method private hidebysig static void InlineVarDecl<T>([out] !!T& v,
!!T 'init') cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stobj !!T
IL_0007: ret
} // end of method AnonymousTypes::InlineVarDecl
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.AnonymousTypes
.class private auto ansi sealed beforefieldinit '<>__AnonType0'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method '<>__AnonType0'::.ctor
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 15 (0xf)
.maxstack 3
.locals init (class '<>__AnonType0' V_0)
IL_0000: ldarg.1
IL_0001: isinst '<>__AnonType0'
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldnull
IL_0009: ceq
IL_000b: ldc.i4.0
IL_000c: ceq
IL_000e: ret
} // end of method '<>__AnonType0'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 40 (0x28)
.maxstack 4
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.s 13
IL_000a: shl
IL_000b: add
IL_000c: stloc.0
IL_000d: ldloc.0
IL_000e: ldloc.0
IL_000f: ldc.i4.7
IL_0010: shr
IL_0011: xor
IL_0012: stloc.0
IL_0013: ldloc.0
IL_0014: ldloc.0
IL_0015: ldc.i4.3
IL_0016: shl
IL_0017: add
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: ldloc.0
IL_001b: ldc.i4.s 17
IL_001d: shr
IL_001e: xor
IL_001f: stloc.0
IL_0020: ldloc.0
IL_0021: ldloc.0
IL_0022: ldc.i4.5
IL_0023: shl
IL_0024: add
IL_0025: stloc.0
IL_0026: ldloc.0
IL_0027: ret
} // end of method '<>__AnonType0'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldstr "{ }"
IL_0005: ret
} // end of method '<>__AnonType0'::ToString
} // end of class '<>__AnonType0'
.class private auto ansi sealed beforefieldinit '<>__AnonType1`1'<'<X>__T'>
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private initonly !'<X>__T' '<X>'
.method public hidebysig specialname rtspecialname
instance void .ctor(!'<X>__T' X) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_000d: ret
} // end of method '<>__AnonType1`1'::.ctor
.method public hidebysig specialname instance !'<X>__T'
get_X() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0006: ret
} // end of method '<>__AnonType1`1'::get_X
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 39 (0x27)
.maxstack 5
.locals init (class '<>__AnonType1`1'<!'<X>__T'> V_0)
IL_0000: ldarg.1
IL_0001: isinst class '<>__AnonType1`1'<!'<X>__T'>
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse IL_0025
IL_000d: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_0012: ldarg.0
IL_0013: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0018: ldloc.0
IL_0019: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_001e: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::Equals(!0,
!0)
IL_0023: br.s IL_0026
IL_0025: ldc.i4.0
IL_0026: ret
} // end of method '<>__AnonType1`1'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 63 (0x3f)
.maxstack 7
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0010: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::GetHashCode(!0)
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: stloc.0
IL_001d: ldloc.0
IL_001e: ldloc.0
IL_001f: ldc.i4.s 13
IL_0021: shl
IL_0022: add
IL_0023: stloc.0
IL_0024: ldloc.0
IL_0025: ldloc.0
IL_0026: ldc.i4.7
IL_0027: shr
IL_0028: xor
IL_0029: stloc.0
IL_002a: ldloc.0
IL_002b: ldloc.0
IL_002c: ldc.i4.3
IL_002d: shl
IL_002e: add
IL_002f: stloc.0
IL_0030: ldloc.0
IL_0031: ldloc.0
IL_0032: ldc.i4.s 17
IL_0034: shr
IL_0035: xor
IL_0036: stloc.0
IL_0037: ldloc.0
IL_0038: ldloc.0
IL_0039: ldc.i4.5
IL_003a: shl
IL_003b: add
IL_003c: stloc.0
IL_003d: ldloc.0
IL_003e: ret
} // end of method '<>__AnonType1`1'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 67 (0x43)
.maxstack 8
.locals init (!'<X>__T' V_0)
IL_0000: ldstr "{"
IL_0005: ldstr " X = "
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0010: box !'<X>__T'
IL_0015: brfalse IL_0033
IL_001a: ldarg.0
IL_001b: ldfld !0 class '<>__AnonType1`1'<!'<X>__T'>::'<X>'
IL_0020: stloc.0
IL_0021: ldloca.s V_0
IL_0023: constrained. !'<X>__T'
IL_0029: callvirt instance string [mscorlib]System.Object::ToString()
IL_002e: br IL_0038
IL_0033: ldsfld string [mscorlib]System.String::Empty
IL_0038: ldstr " }"
IL_003d: call string [mscorlib]System.String::Concat(string,
string,
string,
string)
IL_0042: ret
} // end of method '<>__AnonType1`1'::ToString
.property !'<X>__T' X()
{
.get instance !'<X>__T' '<>__AnonType1`1'::get_X()
} // end of property '<>__AnonType1`1'::X
} // end of class '<>__AnonType1`1'
.class private auto ansi sealed beforefieldinit '<>__AnonType2`2'<'<X>__T','<Y>__T'>
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private initonly !'<X>__T' '<X>'
.field private initonly !'<Y>__T' '<Y>'
.method public hidebysig specialname rtspecialname
instance void .ctor(!'<X>__T' X,
!'<Y>__T' Y) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 21 (0x15)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_000d: ldarg.0
IL_000e: ldarg.2
IL_000f: stfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0014: ret
} // end of method '<>__AnonType2`2'::.ctor
.method public hidebysig specialname instance !'<X>__T'
get_X() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_0006: ret
} // end of method '<>__AnonType2`2'::get_X
.method public hidebysig specialname instance !'<Y>__T'
get_Y() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0006: ret
} // end of method '<>__AnonType2`2'::get_Y
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 69 (0x45)
.maxstack 9
.locals init (class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'> V_0)
IL_0000: ldarg.1
IL_0001: isinst class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse IL_0043
IL_000d: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_0012: ldarg.0
IL_0013: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_0018: ldloc.0
IL_0019: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_001e: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::Equals(!0,
!0)
IL_0023: brfalse IL_0040
IL_0028: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_002d: ldarg.0
IL_002e: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0033: ldloc.0
IL_0034: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0039: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::Equals(!0,
!0)
IL_003e: br.s IL_0041
IL_0040: ldc.i4.0
IL_0041: br.s IL_0044
IL_0043: ldc.i4.0
IL_0044: ret
} // end of method '<>__AnonType2`2'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 86 (0x56)
.maxstack 10
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_0010: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::GetHashCode(!0)
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_0021: ldarg.0
IL_0022: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0027: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::GetHashCode(!0)
IL_002c: xor
IL_002d: ldc.i4 0x1000193
IL_0032: mul
IL_0033: stloc.0
IL_0034: ldloc.0
IL_0035: ldloc.0
IL_0036: ldc.i4.s 13
IL_0038: shl
IL_0039: add
IL_003a: stloc.0
IL_003b: ldloc.0
IL_003c: ldloc.0
IL_003d: ldc.i4.7
IL_003e: shr
IL_003f: xor
IL_0040: stloc.0
IL_0041: ldloc.0
IL_0042: ldloc.0
IL_0043: ldc.i4.3
IL_0044: shl
IL_0045: add
IL_0046: stloc.0
IL_0047: ldloc.0
IL_0048: ldloc.0
IL_0049: ldc.i4.s 17
IL_004b: shr
IL_004c: xor
IL_004d: stloc.0
IL_004e: ldloc.0
IL_004f: ldloc.0
IL_0050: ldc.i4.5
IL_0051: shl
IL_0052: add
IL_0053: stloc.0
IL_0054: ldloc.0
IL_0055: ret
} // end of method '<>__AnonType2`2'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 142 (0x8e)
.maxstack 10
.locals init (!'<X>__T' V_0,
!'<Y>__T' V_1)
IL_0000: ldc.i4.6
IL_0001: newarr [mscorlib]System.String
IL_0006: dup
IL_0007: ldc.i4.0
IL_0008: ldstr "{"
IL_000d: stelem.ref
IL_000e: dup
IL_000f: ldc.i4.1
IL_0010: ldstr " X = "
IL_0015: stelem.ref
IL_0016: dup
IL_0017: ldc.i4.2
IL_0018: ldarg.0
IL_0019: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_001e: box !'<X>__T'
IL_0023: brfalse IL_0041
IL_0028: ldarg.0
IL_0029: ldfld !0 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<X>'
IL_002e: stloc.0
IL_002f: ldloca.s V_0
IL_0031: constrained. !'<X>__T'
IL_0037: callvirt instance string [mscorlib]System.Object::ToString()
IL_003c: br IL_0046
IL_0041: ldsfld string [mscorlib]System.String::Empty
IL_0046: stelem.ref
IL_0047: dup
IL_0048: ldc.i4.3
IL_0049: ldstr ", Y = "
IL_004e: stelem.ref
IL_004f: dup
IL_0050: ldc.i4.4
IL_0051: ldarg.0
IL_0052: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0057: box !'<Y>__T'
IL_005c: brfalse IL_007a
IL_0061: ldarg.0
IL_0062: ldfld !1 class '<>__AnonType2`2'<!'<X>__T',!'<Y>__T'>::'<Y>'
IL_0067: stloc.1
IL_0068: ldloca.s V_1
IL_006a: constrained. !'<Y>__T'
IL_0070: callvirt instance string [mscorlib]System.Object::ToString()
IL_0075: br IL_007f
IL_007a: ldsfld string [mscorlib]System.String::Empty
IL_007f: stelem.ref
IL_0080: dup
IL_0081: ldc.i4.5
IL_0082: ldstr " }"
IL_0087: stelem.ref
IL_0088: call string [mscorlib]System.String::Concat(string[])
IL_008d: ret
} // end of method '<>__AnonType2`2'::ToString
.property !'<X>__T' X()
{
.get instance !'<X>__T' '<>__AnonType2`2'::get_X()
} // end of property '<>__AnonType2`2'::X
.property !'<Y>__T' Y()
{
.get instance !'<Y>__T' '<>__AnonType2`2'::get_Y()
} // end of property '<>__AnonType2`2'::Y
} // end of class '<>__AnonType2`2'
.class private auto ansi sealed beforefieldinit '<>__AnonType3`3'<'<X>__T','<Y>__T','<Z>__T'>
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private initonly !'<X>__T' '<X>'
.field private initonly !'<Y>__T' '<Y>'
.field private initonly !'<Z>__T' '<Z>'
.method public hidebysig specialname rtspecialname
instance void .ctor(!'<X>__T' X,
!'<Y>__T' Y,
!'<Z>__T' Z) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 28 (0x1c)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_000d: ldarg.0
IL_000e: ldarg.2
IL_000f: stfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0014: ldarg.0
IL_0015: ldarg.3
IL_0016: stfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_001b: ret
} // end of method '<>__AnonType3`3'::.ctor
.method public hidebysig specialname instance !'<X>__T'
get_X() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_0006: ret
} // end of method '<>__AnonType3`3'::get_X
.method public hidebysig specialname instance !'<Y>__T'
get_Y() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0006: ret
} // end of method '<>__AnonType3`3'::get_Y
.method public hidebysig specialname instance !'<Z>__T'
get_Z() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_0006: ret
} // end of method '<>__AnonType3`3'::get_Z
.method public hidebysig virtual instance bool
Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 96 (0x60)
.maxstack 12
.locals init (class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'> V_0)
IL_0000: ldarg.1
IL_0001: isinst class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse IL_005e
IL_000d: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_0012: ldarg.0
IL_0013: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_0018: ldloc.0
IL_0019: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_001e: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::Equals(!0,
!0)
IL_0023: brfalse IL_005b
IL_0028: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_002d: ldarg.0
IL_002e: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0033: ldloc.0
IL_0034: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0039: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::Equals(!0,
!0)
IL_003e: brfalse IL_005b
IL_0043: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::get_Default()
IL_0048: ldarg.0
IL_0049: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_004e: ldloc.0
IL_004f: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_0054: callvirt instance bool class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::Equals(!0,
!0)
IL_0059: br.s IL_005c
IL_005b: ldc.i4.0
IL_005c: br.s IL_005f
IL_005e: ldc.i4.0
IL_005f: ret
} // end of method '<>__AnonType3`3'::Equals
.method public hidebysig virtual instance int32
GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 109 (0x6d)
.maxstack 13
.locals init (int32 V_0)
IL_0000: ldc.i4 0x811c9dc5
IL_0005: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::get_Default()
IL_000a: ldarg.0
IL_000b: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_0010: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<X>__T'>::GetHashCode(!0)
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::get_Default()
IL_0021: ldarg.0
IL_0022: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0027: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Y>__T'>::GetHashCode(!0)
IL_002c: xor
IL_002d: ldc.i4 0x1000193
IL_0032: mul
IL_0033: call class [mscorlib]System.Collections.Generic.EqualityComparer`1<!0> class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::get_Default()
IL_0038: ldarg.0
IL_0039: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_003e: callvirt instance int32 class [mscorlib]System.Collections.Generic.EqualityComparer`1<!'<Z>__T'>::GetHashCode(!0)
IL_0043: xor
IL_0044: ldc.i4 0x1000193
IL_0049: mul
IL_004a: stloc.0
IL_004b: ldloc.0
IL_004c: ldloc.0
IL_004d: ldc.i4.s 13
IL_004f: shl
IL_0050: add
IL_0051: stloc.0
IL_0052: ldloc.0
IL_0053: ldloc.0
IL_0054: ldc.i4.7
IL_0055: shr
IL_0056: xor
IL_0057: stloc.0
IL_0058: ldloc.0
IL_0059: ldloc.0
IL_005a: ldc.i4.3
IL_005b: shl
IL_005c: add
IL_005d: stloc.0
IL_005e: ldloc.0
IL_005f: ldloc.0
IL_0060: ldc.i4.s 17
IL_0062: shr
IL_0063: xor
IL_0064: stloc.0
IL_0065: ldloc.0
IL_0066: ldloc.0
IL_0067: ldc.i4.5
IL_0068: shl
IL_0069: add
IL_006a: stloc.0
IL_006b: ldloc.0
IL_006c: ret
} // end of method '<>__AnonType3`3'::GetHashCode
.method public hidebysig virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
// Code size 199 (0xc7)
.maxstack 13
.locals init (!'<X>__T' V_0,
!'<Y>__T' V_1,
!'<Z>__T' V_2)
IL_0000: ldc.i4.8
IL_0001: newarr [mscorlib]System.String
IL_0006: dup
IL_0007: ldc.i4.0
IL_0008: ldstr "{"
IL_000d: stelem.ref
IL_000e: dup
IL_000f: ldc.i4.1
IL_0010: ldstr " X = "
IL_0015: stelem.ref
IL_0016: dup
IL_0017: ldc.i4.2
IL_0018: ldarg.0
IL_0019: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_001e: box !'<X>__T'
IL_0023: brfalse IL_0041
IL_0028: ldarg.0
IL_0029: ldfld !0 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<X>'
IL_002e: stloc.0
IL_002f: ldloca.s V_0
IL_0031: constrained. !'<X>__T'
IL_0037: callvirt instance string [mscorlib]System.Object::ToString()
IL_003c: br IL_0046
IL_0041: ldsfld string [mscorlib]System.String::Empty
IL_0046: stelem.ref
IL_0047: dup
IL_0048: ldc.i4.3
IL_0049: ldstr ", Y = "
IL_004e: stelem.ref
IL_004f: dup
IL_0050: ldc.i4.4
IL_0051: ldarg.0
IL_0052: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0057: box !'<Y>__T'
IL_005c: brfalse IL_007a
IL_0061: ldarg.0
IL_0062: ldfld !1 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Y>'
IL_0067: stloc.1
IL_0068: ldloca.s V_1
IL_006a: constrained. !'<Y>__T'
IL_0070: callvirt instance string [mscorlib]System.Object::ToString()
IL_0075: br IL_007f
IL_007a: ldsfld string [mscorlib]System.String::Empty
IL_007f: stelem.ref
IL_0080: dup
IL_0081: ldc.i4.5
IL_0082: ldstr ", Z = "
IL_0087: stelem.ref
IL_0088: dup
IL_0089: ldc.i4.6
IL_008a: ldarg.0
IL_008b: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_0090: box !'<Z>__T'
IL_0095: brfalse IL_00b3
IL_009a: ldarg.0
IL_009b: ldfld !2 class '<>__AnonType3`3'<!'<X>__T',!'<Y>__T',!'<Z>__T'>::'<Z>'
IL_00a0: stloc.2
IL_00a1: ldloca.s V_2
IL_00a3: constrained. !'<Z>__T'
IL_00a9: callvirt instance string [mscorlib]System.Object::ToString()
IL_00ae: br IL_00b8
IL_00b3: ldsfld string [mscorlib]System.String::Empty
IL_00b8: stelem.ref
IL_00b9: dup
IL_00ba: ldc.i4.7
IL_00bb: ldstr " }"
IL_00c0: stelem.ref
IL_00c1: call string [mscorlib]System.String::Concat(string[])
IL_00c6: ret
} // end of method '<>__AnonType3`3'::ToString
.property !'<X>__T' X()
{
.get instance !'<X>__T' '<>__AnonType3`3'::get_X()
} // end of property '<>__AnonType3`3'::X
.property !'<Y>__T' Y()
{
.get instance !'<Y>__T' '<>__AnonType3`3'::get_Y()
} // end of property '<>__AnonType3`3'::Y
.property !'<Z>__T' Z()
{
.get instance !'<Z>__T' '<>__AnonType3`3'::get_Z()
} // end of property '<>__AnonType3`3'::Z
} // end of class '<>__AnonType3`3'
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

26
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs

@ -19,11 +19,24 @@ @@ -19,11 +19,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public class QueryExpressions
{
public class HbmParam
{
public string Name {
get;
set;
}
public string[] Text {
get;
set;
}
}
public class Customer
{
public int CustomerID;
@ -127,6 +140,19 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -127,6 +140,19 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
select b + c;
}
public object HibernateApplyGeneratorQuery()
{
return (from pi in customers.GetType().GetProperties()
let pname = pi.Name
let pvalue = pi.GetValue(customers, null)
select new HbmParam {
Name = pname,
Text = new string[1] {
(pvalue == null) ? "null" : pvalue.ToString()
}
}).ToArray();
}
public object Join()
{
return from c in customers

1347
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.il

File diff suppressed because it is too large Load Diff

1243
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.opt.il

File diff suppressed because it is too large Load Diff

1534
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.opt.roslyn.il

File diff suppressed because it is too large Load Diff

1556
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.roslyn.il

File diff suppressed because it is too large Load Diff

1784
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs

File diff suppressed because it is too large Load Diff

675
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemTestCase.cs

@ -0,0 +1,675 @@ @@ -0,0 +1,675 @@
// Copyright (c) 2010-2018 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
[assembly: ICSharpCode.Decompiler.Tests.TypeSystem.TypeTestAttribute(
42, typeof(System.Action<>), typeof(IDictionary<string, IList<NUnit.Framework.TestAttribute>>))]
[assembly: TypeForwardedTo(typeof(Func<,>))]
namespace ICSharpCode.Decompiler.Tests.TypeSystem
{
public delegate S GenericDelegate<in T, out S>(T input) where T : S where S : class;
public class SimplePublicClass
{
public void Method() { }
}
public class TypeTestAttribute : Attribute
{
public TypeTestAttribute(int a1, Type a2, Type a3) { }
}
[Params(1, StringComparison.CurrentCulture, null, 4.0, "Test")]
public class ParamsAttribute : Attribute
{
public ParamsAttribute(params object[] x) { }
[Params(Property = new string[] { "a", "b" })]
public string[] Property {
[return: Params("Attribute on return type of getter")]
get { return null; }
set { }
}
}
[Double(1)]
public class DoubleAttribute : Attribute
{
public DoubleAttribute(double val) { }
}
public unsafe class DynamicTest
{
public dynamic SimpleProperty { get; set; }
public List<dynamic> DynamicGenerics1(Action<object, dynamic[], object> param) { return null; }
public void DynamicGenerics2(Action<object, dynamic, object> param) { }
public void DynamicGenerics3(Action<int, dynamic, object> param) { }
public void DynamicGenerics4(Action<int[], dynamic, object> param) { }
public void DynamicGenerics5(Action<int*[], dynamic, object> param) { }
public void DynamicGenerics6(ref Action<object, dynamic, object> param) { }
public void DynamicGenerics7(Action<int[,][], dynamic, object> param) { }
}
public class GenericClass<A, B> where A : B
{
public void TestMethod<K, V>(string param) where V : K where K : IComparable<V> { }
public void GetIndex<T>(T element) where T : IEquatable<T> { }
public NestedEnum EnumField;
public A Property { get; set; }
public enum NestedEnum
{
EnumMember
}
}
public class PropertyTest
{
public int PropertyWithProtectedSetter { get; protected set; }
public object PropertyWithPrivateSetter { get; private set; }
public object PropertyWithoutSetter { get { return null; } }
public object PropertyWithPrivateGetter { private get; set; }
public string this[int index] { get { return "Test"; } set { } }
}
public enum MyEnum : short
{
First,
Second,
Flag1 = 0x10,
Flag2 = 0x20,
CombinedFlags = Flag1 | Flag2
}
public class Base<T>
{
public class Nested<X> { }
public virtual void GenericMethodWithConstraints<X>(T a) where X : IComparer<T>, new() { }
}
public class Derived<A, B> : Base<B>
{
public override void GenericMethodWithConstraints<Y>(B a) { }
}
public struct MyStructWithCtor
{
public MyStructWithCtor(int a) { }
}
public class MyClassWithCtor
{
private MyClassWithCtor(int a) { }
}
[Serializable]
public class NonCustomAttributes
{
[NonSerialized]
public readonly int NonSerializedField;
[DllImport("unmanaged.dll", CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DllMethod([In, Out] ref int p);
}
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode, Pack = 8)]
public struct ExplicitFieldLayoutStruct
{
[FieldOffset(0)]
public int Field0;
[FieldOffset(100)]
public int Field100;
}
public class ParameterTests
{
public void MethodWithOutParameter(out int x) { x = 0; }
public void MethodWithParamsArray(params object[] x) { }
public void MethodWithOptionalParameter(int x = 4) { }
public void MethodWithExplicitOptionalParameter([Optional] int x) { }
public void MethodWithEnumOptionalParameter(StringComparison x = StringComparison.OrdinalIgnoreCase) { }
public void MethodWithOptionalNullableParameter(int? x = null) { }
public void MethodWithOptionalLongParameter(long x = 1) { }
public void MethodWithOptionalNullableLongParameter(long? x = 1) { }
public void VarArgsMethod(__arglist) { }
}
public class VarArgsCtor
{
public VarArgsCtor(__arglist) { }
}
[ComImport(), Guid("21B8916C-F28E-11D2-A473-00C04F8EF448"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAssemblyEnum
{
[PreserveSig()]
int GetNextAssembly(uint dwFlags);
}
public class OuterGeneric<X>
{
public class Inner
{
public OuterGeneric<X> referenceToOuter;
public Inner(OuterGeneric<X> referenceToOuter) { }
}
public OuterGeneric<X>.Inner Field1;
public Inner Field2;
public OuterGeneric<OuterGeneric<X>.Inner>.Inner Field3;
}
public class ExplicitDisposableImplementation : IDisposable
{
void IDisposable.Dispose() { }
}
public interface IGenericInterface<T>
{
void Test<S>(T a, S b) where S : T;
void Test<S>(T a, ref S b);
}
public class ExplicitGenericInterfaceImplementation : IGenericInterface<string>
{
void IGenericInterface<string>.Test<T>(string a, T b) { }
void IGenericInterface<string>.Test<T>(string a, ref T b) { }
}
public interface IGenericInterfaceWithUnifiableMethods<T, S>
{
void Test(T a);
void Test(S a);
}
public class ImplementationOfUnifiedMethods : IGenericInterfaceWithUnifiableMethods<int, int>
{
public void Test(int a) { }
}
public class ExplicitGenericInterfaceImplementationWithUnifiableMethods<T, S> : IGenericInterfaceWithUnifiableMethods<T, S>
{
void IGenericInterfaceWithUnifiableMethods<T, S>.Test(T a) { }
void IGenericInterfaceWithUnifiableMethods<T, S>.Test(S a) { }
}
public partial class PartialClass
{
partial void PartialMethodWithImplementation(int a);
partial void PartialMethodWithImplementation(System.Int32 a)
{
}
partial void PartialMethodWithImplementation(string a);
partial void PartialMethodWithImplementation(System.String a)
{
}
partial void PartialMethodWithoutImplementation();
}
public class ClassWithStaticAndNonStaticMembers
{
public static event System.EventHandler Event1 { add { } remove { } }
public event System.EventHandler Event2 { add { } remove { } }
#pragma warning disable 67
public static event System.EventHandler Event3;
public event System.EventHandler Event4;
public static int Prop1 { get { return 0; } set { } }
public int Prop2 { get { return 0; } set { } }
public static int Prop3 { get; set; }
public int Prop4 { get; set; }
}
public interface IInterfaceWithProperty
{
int Prop { get; set; }
}
public class ClassWithVirtualProperty
{
public virtual int Prop { get; protected set; }
}
public class ClassThatOverridesAndSealsVirtualProperty : ClassWithVirtualProperty
{
public sealed override int Prop { get; protected set; }
}
public class ClassThatOverridesGetterOnly : ClassWithVirtualProperty
{
public override int Prop { get { return 1; } }
}
public class ClassThatOverridesSetterOnly : ClassThatOverridesGetterOnly
{
public override int Prop { protected set { } }
}
public class ClassThatImplementsProperty : IInterfaceWithProperty
{
public int Prop { get; set; }
}
public class ClassThatImplementsPropertyExplicitly : IInterfaceWithProperty
{
int IInterfaceWithProperty.Prop { get; set; }
}
public interface IInterfaceWithIndexers
{
int this[int x] { get; set; }
int this[string x] { get; set; }
int this[int x, int y] { get; set; }
}
public interface IGenericInterfaceWithIndexer<T>
{
int this[T x] { get; set; }
}
public class ClassThatImplementsIndexers : IInterfaceWithIndexers, IGenericInterfaceWithIndexer<int>
{
public int this[int x] { get { return 0; } set { } }
public int this[string x] { get { return 0; } set { } }
public int this[int x, int y] { get { return 0; } set { } }
}
public class ClassThatImplementsIndexersExplicitly : IInterfaceWithIndexers, IGenericInterfaceWithIndexer<int>
{
int IInterfaceWithIndexers.this[int x] { get { return 0; } set { } }
int IGenericInterfaceWithIndexer<int>.this[int x] { get { return 0; } set { } }
int IInterfaceWithIndexers.this[string x] { get { return 0; } set { } }
int IInterfaceWithIndexers.this[int x, int y] { get { return 0; } set { } }
}
public interface IHasEvent
{
event EventHandler Event;
}
public class ClassThatImplementsEvent : IHasEvent
{
public event EventHandler Event;
}
public class ClassThatImplementsEventWithCustomAccessors : IHasEvent
{
public event EventHandler Event { add { } remove { } }
}
public class ClassThatImplementsEventExplicitly : IHasEvent
{
event EventHandler IHasEvent.Event { add { } remove { } }
}
public interface IShadowTestBase
{
void Method();
int this[int i] { get; set; }
int Prop { get; set; }
event EventHandler Evt;
}
public interface IShadowTestDerived : IShadowTestBase
{
new void Method();
new int this[int i] { get; set; }
new int Prop { get; set; }
new event EventHandler Evt;
}
public static class StaticClass { }
public abstract class AbstractClass { }
public class IndexerNonDefaultName
{
[IndexerName("Foo")]
public int this[int index] {
get { return 0; }
}
}
public class ClassWithMethodThatHasNullableDefaultParameter
{
public void Foo(int? bar = 42) { }
}
public class AccessibilityTest
{
public void Public() { }
internal void Internal() { }
protected internal void ProtectedInternal() { }
internal protected void InternalProtected() { }
protected void Protected() { }
private void Private() { }
void None() { }
}
public class ConstantFieldTest
{
public const byte Cb = 42;
public const sbyte Csb = 42;
public const char Cc = '\x42';
public const short Cs = 42;
public const ushort Cus = 42;
public const int Ci = 42;
public const uint Cui = 42;
public const long Cl = 42;
public const ulong Cul = 42;
public const double Cd = 42;
public const float Cf = 42;
public const decimal Cm = 42;
public const string S = "hello, world";
public const string NullString = null;
public const MyEnum EnumFromThisAssembly = MyEnum.Second;
public const StringComparison EnumFromAnotherAssembly = StringComparison.OrdinalIgnoreCase;
public const MyEnum DefaultOfEnum = default(MyEnum);
public const int SOsb = sizeof(sbyte);
public const int SOb = sizeof(byte);
public const int SOs = sizeof(short);
public const int SOus = sizeof(ushort);
public const int SOi = sizeof(int);
public const int SOui = sizeof(uint);
public const int SOl = sizeof(long);
public const int SOul = sizeof(ulong);
public const int SOc = sizeof(char);
public const int SOf = sizeof(float);
public const int SOd = sizeof(double);
public const int SObl = sizeof(bool);
public const int SOe = sizeof(MyEnum);
public const byte CNewb = new byte();
public const sbyte CNewsb = new sbyte();
public const char CNewc = new char();
public const short CNews = new short();
public const ushort CNewus = new ushort();
public const int CNewi = new int();
public const uint CNewui = new uint();
public const long CNewl = new long();
public const ulong CNewul = new ulong();
public const double CNewd = new double();
public const float CNewf = new float();
public const decimal CNewm = new decimal();
}
public interface IExplicitImplementationTests
{
void M(int a);
int P { get; set; }
event Action E;
int this[int x] { get; set; }
}
public class ExplicitImplementationTests : IExplicitImplementationTests
{
public void M(int a) { }
public int P { get; set; }
public event Action E;
public int this[int x] { get { return 0; } set { } }
void IExplicitImplementationTests.M(int a) { }
int IExplicitImplementationTests.P { get; set; }
event Action IExplicitImplementationTests.E { add { } remove { } }
int IExplicitImplementationTests.this[int x] { get { return 0; } set { } }
}
[TypeTest(C, typeof(Inner), typeof(int)), My]
public class ClassWithAttributesUsingNestedMembers
{
sealed class MyAttribute : Attribute { }
const int C = 42;
class Inner
{
}
[TypeTest(C, typeof(Inner), typeof(int)), My]
public int P { get; set; }
[TypeTest(C, typeof(Inner), typeof(int)), My]
class AttributedInner
{
}
[TypeTest(C, typeof(Inner), typeof(int)), My]
class AttributedInner2
{
sealed class MyAttribute : Attribute { }
const int C = 43;
class Inner { }
}
}
public class ClassWithAttributeOnTypeParameter<[Double(2)] T> { }
[Guid("790C6E0B-9194-4cc9-9426-A48A63185696"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComImport]
public interface IMarshalAsTests
{
[DispId(48)]
void AliasComponent([MarshalAs(UnmanagedType.BStr)] [In] string bstrSrcApplicationIDOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrCLSIDOrProgID, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDestApplicationIDOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrNewProgId, [MarshalAs(UnmanagedType.BStr)] [In] string bstrNewClsid);
[DispId(33)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool AreApplicationInstancesPaused([MarshalAs(UnmanagedType.LPStruct)] [In] object pVarApplicationInstanceID);
[DispId(19)]
void BackupREGDB([MarshalAs(UnmanagedType.BStr)] [In] string bstrBackupFilePath);
[DispId(2)]
[return: MarshalAs(UnmanagedType.Interface)]
object Connect([MarshalAs(UnmanagedType.BStr)] [In] string connectStr);
[DispId(45)]
void CopyApplications([MarshalAs(UnmanagedType.BStr)] [In] string bstrSourcePartitionIDOrName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarApplicationID, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDestinationPartitionIDOrName);
[DispId(46)]
void CopyComponents([MarshalAs(UnmanagedType.BStr)] [In] string bstrSourceApplicationIDOrName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarCLSIDOrProgID, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDestinationApplicationIDOrName);
[DispId(36)]
void CreateServiceForApplication([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrServiceName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrStartType, [MarshalAs(UnmanagedType.BStr)] [In] string bstrErrorControl, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDependencies, [MarshalAs(UnmanagedType.BStr)] [In] string bstrRunAs, [MarshalAs(UnmanagedType.BStr)] [In] string bstrPassword, [MarshalAs(UnmanagedType.VariantBool)] [In] bool bDesktopOk);
[DispId(40)]
void CurrentPartition([MarshalAs(UnmanagedType.BStr)] [In] string bstrPartitionIDOrName);
[DispId(41)]
[return: MarshalAs(UnmanagedType.BStr)]
string CurrentPartitionID();
[DispId(42)]
[return: MarshalAs(UnmanagedType.BStr)]
string CurrentPartitionName();
[DispId(37)]
void DeleteServiceForApplication([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName);
[DispId(34)]
[return: MarshalAs(UnmanagedType.BStr)]
string DumpApplicationInstance([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationInstanceID, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDirectory, [MarshalAs(UnmanagedType.I4)] [In] int lMaxImages);
[DispId(9)]
void ExportApplication([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationFile, [In] int lOptions);
[DispId(54)]
void ExportPartition([MarshalAs(UnmanagedType.BStr)] [In] string bstrPartitionIDOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrPartitionFileName, [MarshalAs(UnmanagedType.I4)] [In] int lOptions);
[DispId(44)]
void FlushPartitionCache();
[DispId(28)]
[return: MarshalAs(UnmanagedType.BStr)]
string GetApplicationInstanceIDFromProcessID([MarshalAs(UnmanagedType.I4)] [In] int lProcessID);
[DispId(1)]
[return: MarshalAs(UnmanagedType.Interface)]
object GetCollection([MarshalAs(UnmanagedType.BStr)] [In] string bstrCollName);
[DispId(5)]
[return: MarshalAs(UnmanagedType.Interface)]
object GetCollectionByQuery([MarshalAs(UnmanagedType.BStr)] [In] string collName, [MarshalAs(UnmanagedType.SafeArray)] [In] ref object[] aQuery);
[DispId(27)]
[return: MarshalAs(UnmanagedType.Interface)]
object GetCollectionByQuery2([MarshalAs(UnmanagedType.BStr)] [In] string bstrCollectionName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarQueryStrings);
[DispId(57)]
[return: MarshalAs(UnmanagedType.I4)]
int GetComponentVersionCount([MarshalAs(UnmanagedType.BStr)] [In] string bstrCLSIDOrProgID);
[DispId(26)]
void GetEventClassesForIID([In] string bstrIID, [MarshalAs(UnmanagedType.SafeArray)] [In] [Out] ref object[] varCLSIDS, [MarshalAs(UnmanagedType.SafeArray)] [In] [Out] ref object[] varProgIDs, [MarshalAs(UnmanagedType.SafeArray)] [In] [Out] ref object[] varDescriptions);
[DispId(17)]
void GetMultipleComponentsInfo([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [In] object varFileNames, [MarshalAs(UnmanagedType.SafeArray)] out object[] varCLSIDS, [MarshalAs(UnmanagedType.SafeArray)] out object[] varClassNames, [MarshalAs(UnmanagedType.SafeArray)] out object[] varFileFlags, [MarshalAs(UnmanagedType.SafeArray)] out object[] varComponentFlags);
[DispId(38)]
[return: MarshalAs(UnmanagedType.BStr)]
string GetPartitionID([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName);
[DispId(39)]
[return: MarshalAs(UnmanagedType.BStr)]
string GetPartitionName([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName);
[DispId(43)]
[return: MarshalAs(UnmanagedType.BStr)]
string GlobalPartitionID();
[DispId(6)]
void ImportComponent([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrCLSIDOrProgId);
[DispId(52)]
void ImportComponents([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarCLSIDOrProgID, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarComponentType);
[DispId(50)]
void ImportUnconfiguredComponents([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarCLSIDOrProgID, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarComponentType);
[DispId(10)]
void InstallApplication([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationFile, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDestinationDirectory, [In] int lOptions, [MarshalAs(UnmanagedType.BStr)] [In] string bstrUserId, [MarshalAs(UnmanagedType.BStr)] [In] string bstrPassword, [MarshalAs(UnmanagedType.BStr)] [In] string bstrRSN);
[DispId(7)]
void InstallComponent([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDLL, [MarshalAs(UnmanagedType.BStr)] [In] string bstrTLB, [MarshalAs(UnmanagedType.BStr)] [In] string bstrPSDLL);
[DispId(25)]
void InstallEventClass([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDLL, [MarshalAs(UnmanagedType.BStr)] [In] string bstrTLB, [MarshalAs(UnmanagedType.BStr)] [In] string bstrPSDLL);
[DispId(16)]
void InstallMultipleComponents([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [In] ref object[] fileNames, [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [In] ref object[] CLSIDS);
[DispId(24)]
void InstallMultipleEventClasses([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName, [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [In] ref object[] fileNames, [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [In] ref object[] CLSIDS);
[DispId(55)]
void InstallPartition([MarshalAs(UnmanagedType.BStr)] [In] string bstrFileName, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDestDirectory, [MarshalAs(UnmanagedType.I4)] [In] int lOptions, [MarshalAs(UnmanagedType.BStr)] [In] string bstrUserID, [MarshalAs(UnmanagedType.BStr)] [In] string bstrPassword, [MarshalAs(UnmanagedType.BStr)] [In] string bstrRSN);
[DispId(53)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool Is64BitCatalogServer();
[DispId(35)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool IsApplicationInstanceDumpSupported();
[DispId(49)]
[return: MarshalAs(UnmanagedType.Interface)]
object IsSafeToDelete([MarshalAs(UnmanagedType.BStr)] [In] string bstrDllName);
[DispId(3)]
int MajorVersion();
[DispId(4)]
int MinorVersion();
[DispId(47)]
void MoveComponents([MarshalAs(UnmanagedType.BStr)] [In] string bstrSourceApplicationIDOrName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarCLSIDOrProgID, [MarshalAs(UnmanagedType.BStr)] [In] string bstrDestinationApplicationIDOrName);
[DispId(30)]
void PauseApplicationInstances([MarshalAs(UnmanagedType.LPStruct)] [In] object pVarApplicationInstanceID);
[DispId(51)]
void PromoteUnconfiguredComponents([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationIDOrName, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarCLSIDOrProgID, [MarshalAs(UnmanagedType.LPStruct)] [In] object pVarComponentType);
[DispId(21)]
void QueryApplicationFile([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationFile, [MarshalAs(UnmanagedType.BStr)] out string bstrApplicationName, [MarshalAs(UnmanagedType.BStr)] out string bstrApplicationDescription, [MarshalAs(UnmanagedType.VariantBool)] out bool bHasUsers, [MarshalAs(UnmanagedType.VariantBool)] out bool bIsProxy, [MarshalAs(UnmanagedType.SafeArray)] out object[] varFileNames);
[DispId(56)]
[return: MarshalAs(UnmanagedType.IDispatch)]
object QueryApplicationFile2([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplicationFile);
[DispId(32)]
void RecycleApplicationInstances([MarshalAs(UnmanagedType.LPStruct)] [In] object pVarApplicationInstanceID, [MarshalAs(UnmanagedType.I4)] [In] int lReasonCode);
[DispId(18)]
void RefreshComponents();
[DispId(12)]
void RefreshRouter();
[DispId(14)]
void Reserved1();
[DispId(15)]
void Reserved2();
[DispId(20)]
void RestoreREGDB([MarshalAs(UnmanagedType.BStr)] [In] string bstrBackupFilePath);
[DispId(31)]
void ResumeApplicationInstances([MarshalAs(UnmanagedType.LPStruct)] [In] object pVarApplicationInstanceID);
[DispId(23)]
int ServiceCheck([In] int lService);
[DispId(8)]
void ShutdownApplication([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName);
[DispId(29)]
void ShutdownApplicationInstances([MarshalAs(UnmanagedType.LPStruct)] [In] object pVarApplicationInstanceID);
[DispId(22)]
void StartApplication([MarshalAs(UnmanagedType.BStr)] [In] string bstrApplIdOrName);
[DispId(13)]
void StartRouter();
[DispId(11)]
void StopRouter();
}
}

2
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -1311,7 +1311,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1311,7 +1311,7 @@ namespace ICSharpCode.Decompiler.CSharp
// A = inputType.GetSize()
// B = inputStackType.GetSize()
// C = inst.TargetType.GetSize().
// We know that C <= B (otherwise this wouldn't be the truncation case).
// We know that C < B (otherwise this wouldn't be the truncation case).
// 1) If C < B < A, we just combine the two truncations into one.
// 2) If C < B = A, there's no input conversion, just the truncation
// 3) If C <= A < B, all the extended bits get removed again by the truncation.

10
ICSharpCode.Decompiler/CSharp/Resolver/CSharpOperators.cs

@ -214,16 +214,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -214,16 +214,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
get { return compilation.MainAssembly; }
}
ISymbolReference ISymbol.ToReference()
{
throw new NotSupportedException();
}
IMemberReference IMember.ToReference()
{
throw new NotSupportedException();
}
TypeParameterSubstitution IMember.Substitution {
get {
return TypeParameterSubstitution.Identity;

38
ICSharpCode.Decompiler/CSharp/Resolver/ReducedExtensionMethod.cs

@ -66,44 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -66,44 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
#region IMember implementation
[Serializable]
public sealed class ReducedExtensionMethodMemberReference : IMemberReference
{
readonly IMethod baseMethod;
public ReducedExtensionMethodMemberReference (IMethod baseMethod)
{
this.baseMethod = baseMethod;
}
public IMember Resolve(ITypeResolveContext context)
{
return new ReducedExtensionMethod ((IMethod)baseMethod.ToReference ().Resolve (context));
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
public ITypeReference DeclaringTypeReference {
get {
return baseMethod.ToReference ().DeclaringTypeReference;
}
}
}
public IMemberReference ToReference()
{
return new ReducedExtensionMethodMemberReference (baseMethod);
}
ISymbolReference ISymbol.ToReference()
{
return ToReference();
}
public IMember MemberDefinition {
get {
return baseMethod.MemberDefinition;

13
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -549,26 +549,25 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -549,26 +549,25 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
if (!UseSpecialConstants) {
// +Infty, -Infty and NaN, cannot be represented in their encoded form.
// Use an equivalent arithmetic expression instead.
var resolver = this.resolver ?? new CSharpResolver(type.GetDefinition().Compilation);
if (info.Type == KnownTypeCode.Double) {
switch ((double)constant) {
case double.NegativeInfinity: // (-1.0 / 0.0)
var left = new PrimitiveExpression(-1.0).WithoutILInstruction().WithRR(new ConstantResolveResult(type, -1.0));
var right = new PrimitiveExpression(0.0).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0));
expression = new BinaryOperatorExpression(left, BinaryOperatorType.Divide, right).WithoutILInstruction()
.WithRR(resolver.ResolveBinaryOperator(BinaryOperatorType.Divide, left.ResolveResult, right.ResolveResult));
.WithRR(new ConstantResolveResult(type, double.NegativeInfinity));
return true;
case double.PositiveInfinity: // (1.0 / 0.0)
left = new PrimitiveExpression(1.0).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 1.0));
right = new PrimitiveExpression(0.0).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0));
expression = new BinaryOperatorExpression(left, BinaryOperatorType.Divide, right).WithoutILInstruction()
.WithRR(resolver.ResolveBinaryOperator(BinaryOperatorType.Divide, left.ResolveResult, right.ResolveResult));
.WithRR(new ConstantResolveResult(type, double.PositiveInfinity));
return true;
case double.NaN: // (0.0 / 0.0)
left = new PrimitiveExpression(0.0).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0));
right = new PrimitiveExpression(0.0).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0));
expression = new BinaryOperatorExpression(left, BinaryOperatorType.Divide, right).WithoutILInstruction()
.WithRR(resolver.ResolveBinaryOperator(BinaryOperatorType.Divide, left.ResolveResult, right.ResolveResult));
.WithRR(new ConstantResolveResult(type, double.NaN));
return true;
}
}
@ -578,19 +577,19 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -578,19 +577,19 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
var left = new PrimitiveExpression(-1.0f).WithoutILInstruction().WithRR(new ConstantResolveResult(type, -1.0f));
var right = new PrimitiveExpression(0.0f).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0f));
expression = new BinaryOperatorExpression(left, BinaryOperatorType.Divide, right).WithoutILInstruction()
.WithRR(resolver.ResolveBinaryOperator(BinaryOperatorType.Divide, left.ResolveResult, right.ResolveResult));
.WithRR(new ConstantResolveResult(type, float.NegativeInfinity));
return true;
case float.PositiveInfinity: // (1.0f / 0.0f)
left = new PrimitiveExpression(1.0f).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 1.0f));
right = new PrimitiveExpression(0.0f).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0f));
expression = new BinaryOperatorExpression(left, BinaryOperatorType.Divide, right).WithoutILInstruction()
.WithRR(resolver.ResolveBinaryOperator(BinaryOperatorType.Divide, left.ResolveResult, right.ResolveResult));
.WithRR(new ConstantResolveResult(type, float.PositiveInfinity));
return true;
case float.NaN: // (0.0f / 0.0f)
left = new PrimitiveExpression(0.0f).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0f));
right = new PrimitiveExpression(0.0f).WithoutILInstruction().WithRR(new ConstantResolveResult(type, 0.0f));
expression = new BinaryOperatorExpression(left, BinaryOperatorType.Divide, right).WithoutILInstruction()
.WithRR(resolver.ResolveBinaryOperator(BinaryOperatorType.Divide, left.ResolveResult, right.ResolveResult));
.WithRR(new ConstantResolveResult(type, float.NaN));
return true;
}
}

4
ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

@ -198,8 +198,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -198,8 +198,8 @@ namespace ICSharpCode.Decompiler.CSharp
}
return this;
}
if (targetType.Kind == TypeKind.Unknown) {
return this; // don't attempt to insert cast to '?'
if (targetType.Kind == TypeKind.Unknown || targetType.Kind == TypeKind.Void) {
return this; // don't attempt to insert cast to '?' or 'void' as these are not valid.
}
if (Expression is UnaryOperatorExpression uoe && uoe.Operator == UnaryOperatorType.NullConditional && targetType.IsReferenceType == true) {
// "(T)(x?).AccessChain" is invalid, but "((T)x)?.AccessChain" is valid and equivalent

5
ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs

@ -201,11 +201,6 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -201,11 +201,6 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
{
return null;
}
public ISymbolReference ToReference()
{
return new MergedNamespaceReference(ExternAlias, ((INamespace)this).FullName);
}
}
}
}

5
ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs

@ -68,10 +68,5 @@ namespace ICSharpCode.Decompiler.Documentation @@ -68,10 +68,5 @@ namespace ICSharpCode.Decompiler.Documentation
}
return null;
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
}
}

3
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -507,7 +507,6 @@ @@ -507,7 +507,6 @@
<Compile Include="TypeSystem\Implementation\DefaultUnresolvedTypeParameter.cs" />
<Compile Include="TypeSystem\Implementation\DefaultVariable.cs" />
<Compile Include="TypeSystem\Implementation\DummyTypeParameter.cs" />
<Compile Include="TypeSystem\Implementation\ExplicitInterfaceImplementationMemberReference.cs" />
<Compile Include="TypeSystem\Implementation\GetClassTypeReference.cs" />
<Compile Include="TypeSystem\Implementation\GetMembersHelper.cs" />
<Compile Include="TypeSystem\Implementation\KnownTypeCache.cs" />
@ -523,7 +522,6 @@ @@ -523,7 +522,6 @@
<Compile Include="TypeSystem\Implementation\SpecializedMember.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedMethod.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedProperty.cs" />
<Compile Include="TypeSystem\Implementation\SpecializingMemberReference.cs" />
<Compile Include="TypeSystem\Implementation\TypeParameterReference.cs" />
<Compile Include="TypeSystem\Implementation\TypeWithElementType.cs" />
<Compile Include="TypeSystem\Implementation\UnknownType.cs" />
@ -552,7 +550,6 @@ @@ -552,7 +550,6 @@
<Compile Include="TypeSystem\ParameterizedType.cs" />
<Compile Include="TypeSystem\ParameterListComparer.cs" />
<Compile Include="TypeSystem\PointerType.cs" />
<Compile Include="TypeSystem\ProjectReference.cs" />
<Compile Include="TypeSystem\ReflectionHelper.cs" />
<Compile Include="TypeSystem\ReflectionNameParseException.cs" />
<Compile Include="TypeSystem\SimpleTypeResolveContext.cs" />

62
ICSharpCode.Decompiler/IL/ControlFlow/AwaitInCatchTransform.cs

@ -139,8 +139,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -139,8 +139,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false;
if (!catchBlock.Instructions.Last().MatchBranch(out var jumpTableStartBlock))
return false;
if (catchBlock.Instructions.Count > 2) {
objectVariableStore = (StLoc)catchBlock.Instructions[catchBlock.Instructions.Count - 3];
if (catchBlock.Instructions.Count > 2 && catchBlock.Instructions[catchBlock.Instructions.Count - 3] is StLoc stloc) {
objectVariableStore = stloc;
}
var identifierVariableAssignment = catchBlock.Instructions.SecondToLastOrDefault();
if (!identifierVariableAssignment.MatchStLoc(out identifierVariable, out var value) || !value.MatchLdcI4(out id))
@ -221,17 +221,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -221,17 +221,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var tempStore = globalCopyVar.LoadInstructions[0].Parent as StLoc;
if (tempStore == null || !MatchExceptionCaptureBlock(tempStore, out var exitOfFinally, out var afterFinally, out var blocksToRemove))
continue;
if (afterFinally.Instructions.Count < 2)
continue;
int offset = 0;
if (afterFinally.Instructions[0].MatchLdLoc(out var identifierVariable)) {
if (identifierVariable.LoadCount != 1 || identifierVariable.StoreCount != 1)
continue;
offset = 1;
}
if (!afterFinally.Instructions[offset].MatchStLoc(out var globalCopyVarSplitted, out var ldnull) || !ldnull.MatchLdNull())
continue;
if (globalCopyVarSplitted.StoreCount != 1 || globalCopyVarSplitted.LoadCount != 0)
if (!MatchAfterFinallyBlock(ref afterFinally, blocksToRemove, out bool removeFirstInstructionInAfterFinally))
continue;
var cfg = new ControlFlowGraph(container, context.CancellationToken);
var exitOfFinallyNode = cfg.GetNode(exitOfFinally);
@ -269,9 +259,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -269,9 +259,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
}
var finallyContainer = new BlockContainer();
entryPointOfFinally.Remove();
if (offset == 1)
if (removeFirstInstructionInAfterFinally)
afterFinally.Instructions.RemoveAt(0);
changedContainers.Add(container);
var outer = BlockContainer.FindClosestContainer(container.Parent);
if (outer != null) changedContainers.Add(outer);
finallyContainer.Blocks.Add(entryPointOfFinally);
exitOfFinally.Instructions.RemoveRange(tempStore.ChildIndex, 3);
exitOfFinally.Instructions.Add(new Leave(finallyContainer));
@ -366,5 +358,47 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -366,5 +358,47 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
blocksToRemove.Add(captureBlock);
return true;
}
static bool MatchAfterFinallyBlock(ref Block afterFinally, List<Block> blocksToRemove, out bool removeFirstInstructionInAfterFinally)
{
removeFirstInstructionInAfterFinally = false;
if (afterFinally.Instructions.Count < 2)
return false;
ILVariable globalCopyVarSplitted;
switch (afterFinally.Instructions[0]) {
case IfInstruction ifInst:
if (ifInst.Condition.MatchCompEquals(out var load, out var ldone) && ldone.MatchLdcI4(1) && load.MatchLdLoc(out var variable)) {
if (!ifInst.TrueInst.MatchBranch(out var targetBlock))
return false;
blocksToRemove.Add(afterFinally);
afterFinally = targetBlock;
return true;
} else if (ifInst.Condition.MatchCompNotEquals(out load, out ldone) && ldone.MatchLdcI4(1) && load.MatchLdLoc(out variable)) {
if (!afterFinally.Instructions[1].MatchBranch(out var targetBlock))
return false;
blocksToRemove.Add(afterFinally);
afterFinally = targetBlock;
return true;
}
return false;
case LdLoc ldLoc:
if (ldLoc.Variable.LoadCount != 1 || ldLoc.Variable.StoreCount != 1)
return false;
if (!afterFinally.Instructions[1].MatchStLoc(out globalCopyVarSplitted, out var ldnull) || !ldnull.MatchLdNull())
return false;
removeFirstInstructionInAfterFinally = true;
break;
case StLoc stloc:
globalCopyVarSplitted = stloc.Variable;
if (!stloc.Value.MatchLdNull())
return false;
break;
default:
return false;
}
if (globalCopyVarSplitted.StoreCount != 1 || globalCopyVarSplitted.LoadCount != 0)
return false;
return true;
}
}
}

53
ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs

@ -134,34 +134,35 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -134,34 +134,35 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!IsDelegateConstruction(value))
return null;
var targetMethod = ((IInstructionWithMethodOperand)value.Arguments[1]).Method;
if (IsAnonymousMethod(decompilationContext.CurrentTypeDefinition, targetMethod)) {
target = value.Arguments[0];
var methodDefinition = (Mono.Cecil.MethodDefinition)context.TypeSystem.GetCecil(targetMethod);
var localTypeSystem = context.TypeSystem.GetSpecializingTypeSystem(targetMethod.Substitution);
var ilReader = new ILReader(localTypeSystem);
ilReader.UseDebugSymbols = context.Settings.UseDebugSymbols;
var function = ilReader.ReadIL(methodDefinition.Body, context.CancellationToken);
function.DelegateType = value.Method.DeclaringType;
function.CheckInvariant(ILPhase.Normal);
var contextPrefix = targetMethod.Name;
foreach (ILVariable v in function.Variables.Where(v => v.Kind != VariableKind.Parameter)) {
v.Name = contextPrefix + v.Name;
}
if (!IsAnonymousMethod(decompilationContext.CurrentTypeDefinition, targetMethod))
return null;
target = value.Arguments[0];
var methodDefinition = (Mono.Cecil.MethodDefinition)context.TypeSystem.GetCecil(targetMethod);
if (methodDefinition == null)
return null;
var localTypeSystem = context.TypeSystem.GetSpecializingTypeSystem(targetMethod.Substitution);
var ilReader = new ILReader(localTypeSystem);
ilReader.UseDebugSymbols = context.Settings.UseDebugSymbols;
var function = ilReader.ReadIL(methodDefinition.Body, context.CancellationToken);
function.DelegateType = value.Method.DeclaringType;
function.CheckInvariant(ILPhase.Normal);
var nestedContext = new ILTransformContext(function, localTypeSystem, context.Settings) {
CancellationToken = context.CancellationToken,
DecompileRun = context.DecompileRun
};
function.RunTransforms(CSharpDecompiler.GetILTransforms().TakeWhile(t => !(t is DelegateConstruction)), nestedContext);
function.AcceptVisitor(new ReplaceDelegateTargetVisitor(target, function.Variables.SingleOrDefault(v => v.Index == -1 && v.Kind == VariableKind.Parameter)));
// handle nested lambdas
((IILTransform)new DelegateConstruction()).Run(function, nestedContext);
function.AddILRange(target.ILRange);
function.AddILRange(value.Arguments[1].ILRange);
return function;
var contextPrefix = targetMethod.Name;
foreach (ILVariable v in function.Variables.Where(v => v.Kind != VariableKind.Parameter)) {
v.Name = contextPrefix + v.Name;
}
return null;
var nestedContext = new ILTransformContext(function, localTypeSystem, context.Settings) {
CancellationToken = context.CancellationToken,
DecompileRun = context.DecompileRun
};
function.RunTransforms(CSharpDecompiler.GetILTransforms().TakeWhile(t => !(t is DelegateConstruction)), nestedContext);
function.AcceptVisitor(new ReplaceDelegateTargetVisitor(target, function.Variables.SingleOrDefault(v => v.Index == -1 && v.Kind == VariableKind.Parameter)));
// handle nested lambdas
((IILTransform)new DelegateConstruction()).Run(function, nestedContext);
function.AddILRange(target.ILRange);
function.AddILRange(value.Arguments[1].ILRange);
return function;
}
/// <summary>

19
ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
bool modified = false;
int i = 0;
while (i < block.Instructions.Count) {
if (InlineOneIfPossible(block, i, aggressive: IsCatchWhenBlock(block), context: context)) {
if (InlineOneIfPossible(block, i, aggressive: IsCatchWhenBlock(block) || IsInConstructorInitializer(i, block), context: context)) {
modified = true;
i = Math.Max(0, i - 1);
// Go back one step
@ -62,6 +62,23 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -62,6 +62,23 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return modified;
}
static bool IsInConstructorInitializer(int i, Block block)
{
var inst = block.Instructions[i];
var topLevelBlock = inst.Ancestors.OfType<Block>().LastOrDefault();
var function = topLevelBlock.Ancestors.OfType<ILFunction>().FirstOrDefault(f => f.Parent == null);
if (topLevelBlock == null || function == null || !function.Method.IsConstructor)
return false;
var topLevelInst = inst.Ancestors.FirstOrDefault(instr => instr.Parent == topLevelBlock);
var ctorCall = function.Descendants.OfType<CallInstruction>().FirstOrDefault(call => !(call is NewObj)
&& call.Method.IsConstructor
&& call.Method.DeclaringType.IsReferenceType == true
&& call.Parent is Block);
if (topLevelInst == null || ctorCall == null)
return false;
return topLevelInst.ILRange.InclusiveEnd < ctorCall.ILRange.Start;
}
static bool IsCatchWhenBlock(Block block)
{
var container = BlockContainer.FindClosestContainer(block);

13
ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
@ -91,5 +92,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -91,5 +92,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
return false;
}
static bool IsDefinedInCurrentOrOuterClass(IMethod method, ITypeDefinition declaringTypeDefinition)
{
while (declaringTypeDefinition != null) {
if (method.DeclaringTypeDefinition == declaringTypeDefinition)
return true;
declaringTypeDefinition = declaringTypeDefinition.DeclaringTypeDefinition;
}
return false;
}
}
}

10
ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs

@ -50,11 +50,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -50,11 +50,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
IType instType;
switch (initInst) {
case NewObj newObjInst:
if (newObjInst.ILStackWasEmpty && v.Kind == VariableKind.Local && !context.Function.Method.IsConstructor) {
if (newObjInst.ILStackWasEmpty && v.Kind == VariableKind.Local && !context.Function.Method.IsConstructor && !context.Function.Method.IsCompilerGeneratedOrIsInCompilerGeneratedClass()) {
// on statement level (no other expressions on IL stack),
// prefer to keep local variables (but not stack slots),
// unless we are in a constructor (where inlining object initializers might be critical
// for the base ctor call)
// for the base ctor call) or a compiler-generated delegate method, which might be used in a query expression.
return false;
}
// Do not try to transform display class usages or delegate construction.
@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
switch (body.Instructions[i + pos]) {
case CallInstruction call:
if (!(call is CallVirt || call is Call)) continue;
var newCall = (CallInstruction)call.Clone();
var newCall = call;
var newTarget = newCall.Arguments[0];
foreach (var load in newTarget.Descendants.OfType<IInstructionWithVariableOperand>())
if ((load is LdLoc || load is LdLoca) && load.Variable == v)
@ -127,14 +127,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -127,14 +127,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms
initializerBlock.Instructions.Add(newCall);
break;
case StObj stObj:
var newStObj = (StObj)stObj.Clone();
var newStObj = stObj;
foreach (var load in newStObj.Target.Descendants.OfType<IInstructionWithVariableOperand>())
if ((load is LdLoc || load is LdLoca) && load.Variable == v)
load.Variable = finalSlot;
initializerBlock.Instructions.Add(newStObj);
break;
case StLoc stLoc:
var newStLoc = (StLoc)stLoc.Clone();
var newStLoc = stLoc;
initializerBlock.Instructions.Add(newStLoc);
break;
}

5
ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

@ -809,11 +809,12 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -809,11 +809,12 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType);
if (!MatchArgumentList(invocation.Arguments[1], out var arguments))
return (null, SpecialType.UnknownType);
ArrayType arrayType = new ArrayType(context.BlockContext.TypeSystem.Compilation, type);
if (arguments.Count == 0)
return (null, SpecialType.UnknownType);
return (new NewArr(type, new LdcI4(0)), arrayType);
var block = (Block)invocation.Arguments[1];
var function = lambdaStack.Peek();
var variable = function.RegisterVariable(VariableKind.InitializerTarget, new ArrayType(context.BlockContext.TypeSystem.Compilation, type));
var variable = function.RegisterVariable(VariableKind.InitializerTarget, arrayType);
Block initializer = new Block(BlockKind.ArrayInitializer);
int i = 0;
initializer.Instructions.Add(new StLoc(variable, new NewArr(type, new LdcI4(arguments.Count))));

2
ICSharpCode.Decompiler/NRExtensions.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.Decompiler @@ -68,7 +68,7 @@ namespace ICSharpCode.Decompiler
public static bool HasGeneratedName(this IType type)
{
return type.Name.StartsWith("<", StringComparison.Ordinal);
return type.Name.StartsWith("<", StringComparison.Ordinal) || type.Name.Contains("<");
}
public static bool IsAnonymousType(this IType type)

1704
ICSharpCode.Decompiler/TypeSystem/CecilLoader.cs

File diff suppressed because it is too large Load Diff

2
ICSharpCode.Decompiler/TypeSystem/IField.cs

@ -85,7 +85,5 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -85,7 +85,5 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// If this is true, then ConstantValue contains the size of the buffer.
/// </summary>
bool IsFixed { get; }
new IMemberReference ToReference(); // solve ambiguity between IMember.ToReference() and IVariable.ToReference()
}
}

13
ICSharpCode.Decompiler/TypeSystem/IMember.cs

@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
IMember CreateResolved(ITypeResolveContext context);
}
public interface IMemberReference : ISymbolReference
public interface IMemberReference
{
/// <summary>
/// Gets the declaring type reference for the member.
@ -100,7 +100,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -100,7 +100,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.
/// </returns>
new IMember Resolve(ITypeResolveContext context);
IMember Resolve(ITypeResolveContext context);
}
/// <summary>
@ -159,15 +159,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -159,15 +159,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </summary>
bool IsOverridable { get; }
/// <summary>
/// Creates a member reference that can be used to rediscover this member in another compilation.
/// </summary>
/// <remarks>
/// If this member is specialized using open generic types, the resulting member reference will need to be looked up in an appropriate generic context.
/// Otherwise, the main resolve context of a compilation is sufficient.
/// </remarks>
new IMemberReference ToReference();
/// <summary>
/// Gets the substitution belonging to this specialized member.
/// Returns TypeParameterSubstitution.Identity for not specialized members.

10
ICSharpCode.Decompiler/TypeSystem/ISymbol.cs

@ -84,15 +84,5 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -84,15 +84,5 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the short name of the symbol.
/// </summary>
string Name { get; }
/// <summary>
/// Creates a symbol reference that can be used to rediscover this symbol in another compilation.
/// </summary>
ISymbolReference ToReference();
}
public interface ISymbolReference
{
ISymbol Resolve(ITypeResolveContext context);
}
}

2
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs

@ -60,8 +60,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -60,8 +60,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public IReadOnlyList<IAttribute> Attributes { get; protected set; }
public abstract ISymbolReference ToReference();
public bool IsStatic { get { return unresolved.IsStatic; } }
public bool IsAbstract { get { return unresolved.IsAbstract; } }
public bool IsSealed { get { return unresolved.IsSealed; } }

16
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs

@ -113,22 +113,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -113,22 +113,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public abstract IMember Specialize(TypeParameterSubstitution substitution);
IMemberReference IMember.ToReference()
{
return (IMemberReference)ToReference();
}
public override ISymbolReference ToReference()
{
var declType = this.DeclaringType;
var declTypeRef = declType != null ? declType.ToTypeReference() : SpecialType.UnknownType;
if (IsExplicitInterfaceImplementation && ImplementedInterfaceMembers.Count == 1) {
return new ExplicitInterfaceImplementationMemberReference(declTypeRef, ImplementedInterfaceMembers[0].ToReference());
} else {
return new DefaultMemberReference(this.SymbolKind, declTypeRef, this.Name);
}
}
internal IMethod GetAccessor(ref IMethod accessorField, IUnresolvedMethod unresolvedAccessor)
{
if (unresolvedAccessor == null)

31
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs

@ -364,41 +364,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -364,41 +364,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
return this == other; // use reference equality for type parameters
}
public virtual ISymbolReference ToReference()
{
if (owner == null)
return TypeParameterReference.Create(ownerType, index);
return new OwnedTypeParameterReference(owner.ToReference(), index);
}
public override string ToString()
{
return this.ReflectionName + " (owner=" + owner + ")";
}
}
public sealed class OwnedTypeParameterReference : ISymbolReference
{
ISymbolReference owner;
int index;
public OwnedTypeParameterReference(ISymbolReference owner, int index)
{
if (owner == null)
throw new ArgumentNullException("owner");
this.owner = owner;
this.index = index;
}
public ISymbol Resolve(ITypeResolveContext context)
{
var entity = owner.Resolve(context) as IEntity;
if (entity is ITypeDefinition)
return ((ITypeDefinition)entity).TypeParameters[index];
if (entity is IMethod)
return ((IMethod)entity).TypeParameters[index];
return null;
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs

@ -152,11 +152,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -152,11 +152,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return Resolve(ExtendContextForType(context, this.DeclaringTypeDefinition), this.SymbolKind, this.Name, interfaceTypeReference);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return ((IUnresolvedMember)this).Resolve(context);
}
protected static ITypeResolveContext ExtendContextForType(ITypeResolveContext assemblyContext, IUnresolvedTypeDefinition typeDef)
{
if (typeDef == null)

5
ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs

@ -47,10 +47,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -47,10 +47,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
else
return null;
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return ((IMemberReference)this).Resolve(context);
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs

@ -99,11 +99,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -99,11 +99,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return null;
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return ((IMemberReference)this).Resolve(context);
}
int ISupportsInterning.GetHashCodeForInterning()
{
return (int)symbolKind ^ typeReference.GetHashCode() ^ name.GetHashCode() ^ parameterTypes.GetHashCode();

58
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultParameter.cs

@ -133,63 +133,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -133,63 +133,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
return b.ToString();
}
public ISymbolReference ToReference()
{
if (owner == null)
return new ParameterReference(type.ToTypeReference(), name, isRef, isOut, isParams, isOptional, defaultValue);
return new OwnedParameterReference(owner.ToReference(), owner.Parameters.IndexOf(this));
}
}
sealed class OwnedParameterReference : ISymbolReference
{
readonly IMemberReference memberReference;
readonly int index;
public OwnedParameterReference(IMemberReference member, int index)
{
if (member == null)
throw new ArgumentNullException("member");
this.memberReference = member;
this.index = index;
}
public ISymbol Resolve(ITypeResolveContext context)
{
IParameterizedMember member = memberReference.Resolve(context) as IParameterizedMember;
if (member != null && index >= 0 && index < member.Parameters.Count)
return member.Parameters[index];
else
return null;
}
}
public sealed class ParameterReference : ISymbolReference
{
readonly ITypeReference type;
readonly string name;
readonly bool isRef, isOut, isParams, isOptional;
readonly object defaultValue;
public ParameterReference(ITypeReference type, string name, bool isRef, bool isOut, bool isParams, bool isOptional, object defaultValue)
{
if (type == null)
throw new ArgumentNullException("type");
if (name == null)
throw new ArgumentNullException("name");
this.type = type;
this.name = name;
this.isRef = isRef;
this.isOut = isOut;
this.isParams = isParams;
this.isOptional = isOptional;
this.defaultValue = defaultValue;
}
public ISymbol Resolve(ITypeResolveContext context)
{
return new DefaultParameter(type.Resolve(context), name, isRef: isRef, isOut: isOut, isParams: isParams, isOptional: isOptional, defaultValue: defaultValue);
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedField.cs

@ -81,10 +81,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -81,10 +81,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
substitution = new TypeParameterSubstitution(substitution.ClassTypeArguments, EmptyList<IType>.Instance);
return new SpecializedField(this, substitution);
}
IMemberReference IField.ToReference()
{
return (IMemberReference)ToReference();
}
}
}

13
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedMethod.cs

@ -228,19 +228,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -228,19 +228,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
public override ISymbolReference ToReference()
{
var declType = this.DeclaringType;
var declTypeRef = declType != null ? declType.ToTypeReference() : SpecialType.UnknownType;
if (IsExplicitInterfaceImplementation && ImplementedInterfaceMembers.Count == 1) {
return new ExplicitInterfaceImplementationMemberReference(declTypeRef, ImplementedInterfaceMembers[0].ToReference());
} else {
return new DefaultMemberReference(
this.SymbolKind, declTypeRef, this.Name, this.TypeParameters.Count,
this.Parameters.Select(p => p.Type.ToTypeReference()).ToList());
}
}
public override IMember Specialize(TypeParameterSubstitution substitution)
{
if (TypeParameterSubstitution.Identity.Equals(substitution))

13
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedProperty.cs

@ -84,19 +84,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -84,19 +84,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return unresolved.IsIndexer; }
}
public override ISymbolReference ToReference()
{
var declType = this.DeclaringType;
var declTypeRef = declType != null ? declType.ToTypeReference() : SpecialType.UnknownType;
if (IsExplicitInterfaceImplementation && ImplementedInterfaceMembers.Count == 1) {
return new ExplicitInterfaceImplementationMemberReference(declTypeRef, ImplementedInterfaceMembers[0].ToReference());
} else {
return new DefaultMemberReference(
this.SymbolKind, declTypeRef, this.Name, 0,
this.Parameters.Select(p => p.Type.ToTypeReference()).ToList());
}
}
public override IMember Specialize(TypeParameterSubstitution substitution)
{
if (TypeParameterSubstitution.Identity.Equals(substitution)

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs

@ -633,11 +633,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -633,11 +633,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
ISymbolReference ISymbol.ToReference()
{
return (ISymbolReference)ToTypeReference();
}
public IEnumerable<IType> GetNestedTypes(Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
const GetMemberOptions opt = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions;

61
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs

@ -559,68 +559,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -559,68 +559,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
else
return null;
}
public ISymbolReference ToReference()
{
return new NamespaceReference(new DefaultAssemblyReference(assembly.AssemblyName), ns.FullName);
}
}
}
}
public sealed class NamespaceReference : ISymbolReference
{
IAssemblyReference assemblyReference;
string fullName;
public NamespaceReference(IAssemblyReference assemblyReference, string fullName)
{
if (assemblyReference == null)
throw new ArgumentNullException("assemblyReference");
this.assemblyReference = assemblyReference;
this.fullName = fullName;
}
public ISymbol Resolve(ITypeResolveContext context)
{
IAssembly assembly = assemblyReference.Resolve(context);
INamespace parent = assembly.RootNamespace;
string[] parts = fullName.Split('.');
int i = 0;
while (i < parts.Length && parent != null) {
parent = parent.GetChildNamespace(parts[i]);
i++;
}
return parent;
}
}
public sealed class MergedNamespaceReference : ISymbolReference
{
string externAlias;
string fullName;
public MergedNamespaceReference(string externAlias, string fullName)
{
this.externAlias = externAlias;
this.fullName = fullName;
}
public ISymbol Resolve(ITypeResolveContext context)
{
string[] parts = fullName.Split('.');
INamespace parent = context.Compilation.GetNamespaceForExternAlias(externAlias);
int i = 0;
while (i < parts.Length && parent != null) {
parent = parent.GetChildNamespace(parts[i]);
i++;
}
return parent;
}
}
}

7
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedParameter.cs

@ -252,13 +252,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -252,13 +252,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
return DefaultParameter.ToString(this);
}
public ISymbolReference ToReference()
{
if (Owner == null)
return new ParameterReference(Type.ToTypeReference(), Name, IsRef, IsOut, IsParams, true, ConstantValue);
return new OwnedParameterReference(Owner.ToReference(), Owner.Parameters.IndexOf(this));
}
}
}
}

30
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultVariable.cs

@ -67,35 +67,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -67,35 +67,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public SymbolKind SymbolKind {
get { return SymbolKind.Variable; }
}
public ISymbolReference ToReference()
{
return new VariableReference(type.ToTypeReference(), name, isConst, constantValue);
}
}
public sealed class VariableReference : ISymbolReference
{
ITypeReference variableTypeReference;
string name;
bool isConst;
object constantValue;
public VariableReference(ITypeReference variableTypeReference, string name, bool isConst, object constantValue)
{
if (variableTypeReference == null)
throw new ArgumentNullException("variableTypeReference");
if (name == null)
throw new ArgumentNullException("name");
this.variableTypeReference = variableTypeReference;
this.name = name;
this.isConst = isConst;
this.constantValue = constantValue;
}
public ISymbol Resolve(ITypeResolveContext context)
{
return new DefaultVariable(variableTypeReference.Resolve(context), name, isConst, constantValue);
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs

@ -237,10 +237,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -237,10 +237,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool ITypeParameter.HasValueTypeConstraint {
get { return false; }
}
public ISymbolReference ToReference()
{
return new TypeParameterReference(ownerType, index);
}
}
}

80
ICSharpCode.Decompiler/TypeSystem/Implementation/ExplicitInterfaceImplementationMemberReference.cs

@ -1,80 +0,0 @@ @@ -1,80 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
/// <summary>
/// References a member that is an explicit interface implementation.
/// </summary>
/// <remarks>
/// Resolving an ExplicitInterfaceImplementationMemberReference requires a context
/// that provides enough information for resolving the declaring type reference
/// and the interface member reference.
/// Note that the interface member reference is resolved in '<c>context.WithCurrentTypeDefinition(declaringType.GetDefinition())</c>'
/// - this is done to ensure that open generics in the interface member reference resolve to the type parameters of the
/// declaring type.
/// </remarks>
[Serializable]
public sealed class ExplicitInterfaceImplementationMemberReference : IMemberReference
{
ITypeReference typeReference;
IMemberReference interfaceMemberReference;
public ExplicitInterfaceImplementationMemberReference(ITypeReference typeReference, IMemberReference interfaceMemberReference)
{
if (typeReference == null)
throw new ArgumentNullException("typeReference");
if (interfaceMemberReference == null)
throw new ArgumentNullException("interfaceMemberReference");
this.typeReference = typeReference;
this.interfaceMemberReference = interfaceMemberReference;
}
public ITypeReference DeclaringTypeReference {
get { return typeReference; }
}
public IMember Resolve(ITypeResolveContext context)
{
IType declaringType = typeReference.Resolve(context);
IMember interfaceMember = interfaceMemberReference.Resolve(context.WithCurrentTypeDefinition(declaringType.GetDefinition()));
if (interfaceMember == null)
return null;
IEnumerable<IMember> members;
if (interfaceMember.SymbolKind == SymbolKind.Accessor) {
members = declaringType.GetAccessors(
m => m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
} else {
members = declaringType.GetMembers(
m => m.SymbolKind == interfaceMember.SymbolKind && m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
}
return members.FirstOrDefault(m => m.ImplementedInterfaceMembers.Count == 1 && interfaceMember.Equals(m.ImplementedInterfaceMembers[0]));
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
}
}

10
ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// Type Reference used when the fully qualified type name is known.
/// </summary>
[Serializable]
public sealed class GetClassTypeReference : ITypeReference, ISymbolReference, ISupportsInterning
public sealed class GetClassTypeReference : ITypeReference, ISupportsInterning
{
readonly IAssemblyReference assembly;
readonly FullTypeName fullTypeName;
@ -124,14 +124,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -124,14 +124,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return type ?? new UnknownType(fullTypeName, isReferenceType);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
var type = Resolve(context);
if (type is ITypeDefinition)
return (ISymbol)type;
return null;
}
public override string ToString()
{
return fullTypeName.ToString() + (assembly != null ? ", " + assembly.ToString() : null);

5
ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs

@ -155,10 +155,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -155,10 +155,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return string.Format(CultureInfo.InvariantCulture, "[MergedNamespace {0}{1} (from {2} assemblies)]",
externAlias != null ? externAlias + "::" : null, this.FullName, this.namespaces.Length);
}
public ISymbolReference ToReference()
{
return new MergedNamespaceReference(externAlias, FullName);
}
}
}

10
ICSharpCode.Decompiler/TypeSystem/Implementation/NestedTypeReference.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// Type reference used to reference nested types.
/// </summary>
[Serializable]
public sealed class NestedTypeReference : ITypeReference, ISymbolReference, ISupportsInterning
public sealed class NestedTypeReference : ITypeReference, ISupportsInterning
{
readonly ITypeReference declaringTypeRef;
readonly string name;
@ -78,14 +78,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -78,14 +78,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return new UnknownType(null, name, additionalTypeParameterCount);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
var type = Resolve(context);
if (type is ITypeDefinition)
return (ISymbol)type;
return null;
}
public override string ToString()
{
if (additionalTypeParameterCount == 0)

21
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs

@ -58,27 +58,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -58,27 +58,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.substitution = TypeParameterSubstitution.Compose(newSubstitution, this.substitution);
}
public virtual IMemberReference ToReference()
{
return new SpecializingMemberReference(
baseMember.ToReference(),
ToTypeReference(substitution.ClassTypeArguments),
null);
}
ISymbolReference ISymbol.ToReference()
{
return ToReference();
}
internal static IList<ITypeReference> ToTypeReference(IReadOnlyList<IType> typeArguments)
{
if (typeArguments == null)
return null;
else
return typeArguments.Select(t => t.ToTypeReference()).ToArray();
}
internal IMethod WrapAccessor(ref IMethod cachingField, IMethod accessorDefinition)
{
if (accessorDefinition == null)

23
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMethod.cs

@ -147,29 +147,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -147,29 +147,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
accessorOwner = value;
}
}
public override IMemberReference ToReference()
{
// Pass the MethodTypeArguments to the SpecializingMemberReference only if
// the generic method itself is parameterized, not if the generic method is only
// specialized with class type arguments.
// This is necessary due to this part of the ToReference() contract:
// If this member is specialized using open generic types, the resulting member reference will need to be looked up in an appropriate generic context.
// Otherwise, the main resolve context of a compilation is sufficient.
// ->
// This means that if the method itself isn't specialized,
// we must not include TypeParameterReferences for the specialized type parameters
// in the resulting member reference.
if (isParameterized) {
return new SpecializingMemberReference(
baseMember.ToReference(),
ToTypeReference(base.Substitution.ClassTypeArguments),
ToTypeReference(base.Substitution.MethodTypeArguments));
} else {
return base.ToReference();
}
}
public override bool Equals(object obj)
{

67
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializingMemberReference.cs

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
[Serializable]
public sealed class SpecializingMemberReference : IMemberReference
{
IMemberReference memberDefinitionReference;
IList<ITypeReference> classTypeArgumentReferences;
IList<ITypeReference> methodTypeArgumentReferences;
public SpecializingMemberReference(IMemberReference memberDefinitionReference, IList<ITypeReference> classTypeArgumentReferences = null, IList<ITypeReference> methodTypeArgumentReferences = null)
{
if (memberDefinitionReference == null)
throw new ArgumentNullException("memberDefinitionReference");
this.memberDefinitionReference = memberDefinitionReference;
this.classTypeArgumentReferences = classTypeArgumentReferences;
this.methodTypeArgumentReferences = methodTypeArgumentReferences;
}
public IMember Resolve(ITypeResolveContext context)
{
var memberDefinition = memberDefinitionReference.Resolve(context);
if (memberDefinition == null)
return null;
return memberDefinition.Specialize(
new TypeParameterSubstitution(
classTypeArgumentReferences != null ? classTypeArgumentReferences.Resolve(context) : null,
methodTypeArgumentReferences != null ? methodTypeArgumentReferences.Resolve(context) : null
)
);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
public ITypeReference DeclaringTypeReference {
get {
if (classTypeArgumentReferences != null)
return new ParameterizedTypeReference(memberDefinitionReference.DeclaringTypeReference, classTypeArgumentReferences);
else
return memberDefinitionReference.DeclaringTypeReference;
}
}
}
}

7
ICSharpCode.Decompiler/TypeSystem/Implementation/TypeParameterReference.cs

@ -23,7 +23,7 @@ using ICSharpCode.Decompiler.Util; @@ -23,7 +23,7 @@ using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
[Serializable]
public sealed class TypeParameterReference : ITypeReference, ISymbolReference
public sealed class TypeParameterReference : ITypeReference
{
static readonly TypeParameterReference[] classTypeParameterReferences = new TypeParameterReference[8];
static readonly TypeParameterReference[] methodTypeParameterReferences = new TypeParameterReference[8];
@ -80,11 +80,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -80,11 +80,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context) as ISymbol;
}
public override string ToString()
{
if (ownerType == SymbolKind.Method)

56
ICSharpCode.Decompiler/TypeSystem/ProjectReference.cs

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.Decompiler.TypeSystem
{
/// <summary>
/// References another project content in the same solution.
/// Using the <see cref="ProjectReference"/> class requires that you
/// </summary>
[Serializable]
public class ProjectReference : IAssemblyReference
{
readonly string projectFileName;
/// <summary>
/// Creates a new reference to the specified project (must be part of the same solution).
/// </summary>
/// <param name="projectFileName">Full path to the file name. Must be identical to <see cref="IProjectContent.ProjectFileName"/> of the target project; do not use a relative path.</param>
public ProjectReference(string projectFileName)
{
this.projectFileName = projectFileName;
}
public IAssembly Resolve(ITypeResolveContext context)
{
var solution = context.Compilation.SolutionSnapshot;
var pc = solution.GetProjectContent(projectFileName);
if (pc != null)
return pc.Resolve(context);
else
return null;
}
public override string ToString()
{
return string.Format("[ProjectReference {0}]", projectFileName);
}
}
}

152
ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs

@ -208,69 +208,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -208,69 +208,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
#endregion
#region Import
/// <summary>
/// Imports a symbol from another compilation.
/// </summary>
public static ISymbol Import(this ICompilation compilation, ISymbol symbol)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (symbol == null)
return null;
switch (symbol.SymbolKind) {
case SymbolKind.TypeParameter:
return (ITypeParameter)Import(compilation, (IType)symbol);
case SymbolKind.Variable:
IVariable v = (IVariable)symbol;
return new DefaultVariable(
Import(compilation, v.Type),
v.Name, v.IsConst, v.ConstantValue
);
case SymbolKind.Parameter:
IParameter p = (IParameter)symbol;
if (p.Owner != null) {
int index = p.Owner.Parameters.IndexOf(p);
var owner = (IParameterizedMember)Import(compilation, p.Owner);
if (owner == null || index < 0 || index >= owner.Parameters.Count)
return null;
return owner.Parameters[index];
} else {
return new DefaultParameter(
Import(compilation, p.Type),
p.Name, null,
null, p.IsRef, p.IsOut, p.IsParams
);
}
case SymbolKind.Namespace:
return Import(compilation, (INamespace)symbol);
default:
if (symbol is IEntity)
return Import(compilation, (IEntity)symbol);
throw new NotSupportedException("Unsupported symbol kind: " + symbol.SymbolKind);
}
}
/// <summary>
/// Imports a type from another compilation.
/// </summary>
public static IType Import(this ICompilation compilation, IType type)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (type == null)
return null;
var compilationProvider = type as ICompilationProvider;
if (compilationProvider != null && compilationProvider.Compilation == compilation)
return type;
IEntity typeParameterOwner = GetTypeParameterOwner(type);
IEntity importedTypeParameterOwner = compilation.Import(typeParameterOwner);
if (importedTypeParameterOwner != null) {
return type.ToTypeReference().Resolve(new SimpleTypeResolveContext(importedTypeParameterOwner));
} else {
return type.ToTypeReference().Resolve(compilation.TypeResolveContext);
}
}
/// <summary>
/// Imports a type from another compilation.
/// </summary>
@ -284,95 +221,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -284,95 +221,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
return typeDefinition;
return typeDefinition.ToTypeReference().Resolve(compilation.TypeResolveContext).GetDefinition();
}
/// <summary>
/// Imports an entity from another compilation.
/// </summary>
public static IEntity Import(this ICompilation compilation, IEntity entity)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (entity == null)
return null;
if (entity.Compilation == compilation)
return entity;
if (entity is IMember)
return ((IMember)entity).ToReference().Resolve(compilation.TypeResolveContext);
else if (entity is ITypeDefinition)
return ((ITypeDefinition)entity).ToTypeReference().Resolve(compilation.TypeResolveContext).GetDefinition();
else
throw new NotSupportedException("Unknown entity type");
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IMember Import(this ICompilation compilation, IMember member)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (member == null)
return null;
if (member.Compilation == compilation)
return member;
return member.ToReference().Resolve(compilation.TypeResolveContext);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IMethod Import(this ICompilation compilation, IMethod method)
{
return (IMethod)compilation.Import((IMember)method);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IField Import(this ICompilation compilation, IField field)
{
return (IField)compilation.Import((IMember)field);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IEvent Import(this ICompilation compilation, IEvent ev)
{
return (IEvent)compilation.Import((IMember)ev);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IProperty Import(this ICompilation compilation, IProperty property)
{
return (IProperty)compilation.Import((IMember)property);
}
/// <summary>
/// Imports a namespace from another compilation.
/// </summary>
/// <remarks>
/// This method may return null if the namespace does not exist in the target compilation.
/// </remarks>
public static INamespace Import(this ICompilation compilation, INamespace ns)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (ns == null)
return null;
if (ns.ParentNamespace == null) {
// root namespace
return compilation.GetNamespaceForExternAlias(ns.ExternAlias);
} else {
INamespace parent = Import(compilation, ns.ParentNamespace);
if (parent != null)
return parent.GetChildNamespace(ns.Name);
else
return null;
}
}
#endregion
#region GetDelegateInvokeMethod

12
ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs

@ -164,11 +164,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -164,11 +164,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
#region IMember implementation
public IMemberReference ToReference()
{
throw new NotImplementedException();
}
IMember IMember.Specialize(TypeParameterSubstitution substitution)
{
return Specialize(substitution);
@ -213,12 +208,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -213,12 +208,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
#endregion
#region ISymbol implementation
ISymbolReference ISymbol.ToReference()
{
return ToReference();
}
public SymbolKind SymbolKind {
get { return baseMethod.SymbolKind; }
}

270
ILSpy.AddIn/CodeElementXmlDocKeyProvider.cs

@ -1,270 +0,0 @@ @@ -1,270 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.Decompiler.CSharp.Syntax;
namespace ICSharpCode.ILSpy.AddIn
{
/// <summary>
/// Provides XML documentation tags for Visual Studio CodeElements.
/// </summary>
/// <remarks>
/// Used to support the "/navigateTo" command line option when opening ILSpy. Must match
/// the logic of ICSharpCode.ILSpy.XmlDoc.XmlDocKeyProvider, which does the same thing for
/// a Mono.Cecil.MemberReference. See "ID string format" in Appendix A of the C# language
/// specification for formatting requirements, and Samples/ILSpyAddInSamples.cs for examples.
/// </remarks>
public static class CodeElementXmlDocKeyProvider
{
#region GetKey
public static string GetKey(EnvDTE.CodeElement member)
{
StringBuilder b = new StringBuilder();
if ((member.Kind == EnvDTE.vsCMElement.vsCMElementDelegate) ||
(member.Kind == EnvDTE.vsCMElement.vsCMElementEnum) ||
(member.Kind == EnvDTE.vsCMElement.vsCMElementInterface) ||
(member.Kind == EnvDTE.vsCMElement.vsCMElementStruct) ||
(member.Kind == EnvDTE.vsCMElement.vsCMElementClass)) {
b.Append("T:");
AppendTypeName(b, member.FullName, true, false);
}
else if (member.Kind == EnvDTE.vsCMElement.vsCMElementNamespace){
b.Append("N:");
b.Append(member.FullName);
}
else {
if (member.Kind == EnvDTE.vsCMElement.vsCMElementVariable)
b.Append("F:");
else if (member.Kind == EnvDTE.vsCMElement.vsCMElementProperty)
b.Append("P:");
else if (member.Kind == EnvDTE.vsCMElement.vsCMElementEvent)
b.Append("E:");
else if (member.Kind == EnvDTE.vsCMElement.vsCMElementFunction)
b.Append("M:");
int nameIndex = member.FullName.LastIndexOf(member.Name);
string typeName = member.FullName.Substring(0, nameIndex - 1);
string memberName = member.FullName.Substring(nameIndex);
// Name substitutions for special cases.
if (member.Kind == EnvDTE.vsCMElement.vsCMElementFunction) {
EnvDTE80.CodeFunction2 mr = (EnvDTE80.CodeFunction2)member;
if (mr.FunctionKind == EnvDTE.vsCMFunction.vsCMFunctionConstructor) {
memberName = memberName.Replace(member.Name, "#ctor");
}
else if (mr.FunctionKind == EnvDTE.vsCMFunction.vsCMFunctionDestructor) {
memberName = memberName.Replace(member.Name, "Finalize");
}
else if (mr.FunctionKind == EnvDTE.vsCMFunction.vsCMFunctionOperator) {
if (memberName.StartsWith("implicit operator")) {
memberName = "op_Implicit";
}
else if (memberName.StartsWith("explicit operator")) {
memberName = "op_Explicit";
}
else {
// NRefactory has a handy mapping we can make use of, just need to extract the operator symbol first.
string[] memberNameWords = member.Name.Split(' ');
if (memberNameWords.Length >= 2) {
string operatorSymbol = memberNameWords[1];
string operatorName = OperatorDeclaration.GetName(OperatorDeclaration.GetOperatorType(operatorSymbol));
if (operatorName != null) {
memberName = memberName.Replace(member.Name, operatorName);
}
}
}
}
}
else if (member.Kind == EnvDTE.vsCMElement.vsCMElementProperty) {
if (member.Name == "this") {
memberName = memberName.Replace(member.Name, "Item");
}
}
string[] genericTypeParameters = AppendTypeName(b, typeName, true, false);
b.Append('.');
string[] genericMethodParameters = AppendTypeName(b, memberName.Replace('.', '#'), true, true);
EnvDTE.CodeElements parameters;
EnvDTE.CodeTypeRef explicitReturnType = null;
if (member.Kind == EnvDTE.vsCMElement.vsCMElementProperty) {
parameters = ((EnvDTE.CodeProperty)member).Getter.Parameters;
}
else if (member.Kind == EnvDTE.vsCMElement.vsCMElementFunction) {
EnvDTE80.CodeFunction2 mr = (EnvDTE80.CodeFunction2)member;
parameters = mr.Parameters;
if (memberName == "op_Implicit" || memberName == "op_Explicit") {
explicitReturnType = mr.Type;
}
}
else {
parameters = null;
}
if (parameters != null && parameters.Count > 0) {
b.Append('(');
int i = 0;
foreach (EnvDTE80.CodeParameter2 parameter in parameters) {
if (i > 0) b.Append(',');
AppendParameterTypeName(b, parameter, genericTypeParameters, genericMethodParameters);
++i;
}
b.Append(')');
}
if (explicitReturnType != null) {
b.Append('~');
AppendTypeName(b, explicitReturnType.AsFullName, true, false);
}
}
return b.ToString();
}
static string[] AppendTypeName(StringBuilder b, string typeName, bool appendGenericParameterCount, bool isMethod)
{
List<string> allGenericParameters = new List<string>();
StringBuilder genericParameterName = new StringBuilder();
bool inGenericParameters = false;
int genericParameterCount = 0;
foreach (char ch in typeName) {
if (inGenericParameters) {
switch (ch) {
case ',':
++genericParameterCount;
allGenericParameters.Add(genericParameterName.ToString());
genericParameterName.Clear();
break;
case '>':
++genericParameterCount;
allGenericParameters.Add(genericParameterName.ToString());
genericParameterName.Clear();
if (appendGenericParameterCount) {
b.Append(genericParameterCount);
}
inGenericParameters = false;
break;
case ' ':
break;
default:
genericParameterName.Append(ch);
break;
}
}
else {
switch (ch) {
case '<':
if (appendGenericParameterCount) {
b.Append('`');
if (isMethod) {
b.Append('`');
}
}
inGenericParameters = true;
genericParameterCount = 0;
break;
case '[':
case ']':
break;
default:
b.Append(ch);
break;
}
}
}
return allGenericParameters.ToArray();
}
private static void AppendParameterTypeName(StringBuilder b, EnvDTE80.CodeParameter2 parameter, string[] genericTypeParameters, string[] genericMethodParameters)
{
EnvDTE80.CodeTypeRef2 parameterTypeRef = (EnvDTE80.CodeTypeRef2)parameter.Type;
string parameterTypeString = parameterTypeRef.AsFullName;
int substringStart = 0;
for (int i = 0; i < parameterTypeString.Length; ++i) {
char ch = parameterTypeString[i];
switch (ch) {
case '<':
AppendParameterTypeSubstring(b, parameterTypeString, substringStart, i, genericTypeParameters, genericMethodParameters);
substringStart = i + 1;
b.Append('{');
break;
case '>':
AppendParameterTypeSubstring(b, parameterTypeString, substringStart, i, genericTypeParameters, genericMethodParameters);
substringStart = i + 1;
b.Append('}');
break;
case '[':
AppendParameterTypeSubstring(b, parameterTypeString, substringStart, i, genericTypeParameters, genericMethodParameters);
b.Append('[');
// Skip ahead to the closing bracket, counting commas to determine array rank.
int rank = 1;
do {
++i;
ch = parameterTypeString[i];
if (ch == ',') {
++rank;
}
}
while (ch != ']');
substringStart = i + 1;
// For multi-dimensional arrays, add "0:" default array bounds. Note that non-standard bounds are not possible via C# declaration.
if (rank > 1) {
for (int r = 0; r < rank; ++r) {
if (r != 0) {
b.Append(',');
}
b.Append("0:");
}
}
b.Append(']');
break;
case ',':
AppendParameterTypeSubstring(b, parameterTypeString, substringStart, i, genericTypeParameters, genericMethodParameters);
substringStart = i + 1;
// Skip space after comma if present. (e.g. System.Collections.Generic.KeyValuePair`2{System.String,System.String}.)
if (parameterTypeString[substringStart] == ' ') {
++substringStart;
}
b.Append(',');
break;
}
}
AppendParameterTypeSubstring(b, parameterTypeString, substringStart, parameterTypeString.Length, genericTypeParameters, genericMethodParameters);
// Append ref / out indicator if needed.
if ((parameter.ParameterKind == EnvDTE80.vsCMParameterKind.vsCMParameterKindRef) ||
(parameter.ParameterKind == EnvDTE80.vsCMParameterKind.vsCMParameterKindOut)) {
b.Append('@');
}
// Note there is no need to append a '*' for pointers, as this is included in the full name of the type.
// Multi-dimensional and jagged arrays are handled above during string parsing.
}
private static void AppendParameterTypeSubstring(StringBuilder b, string parameterTypeString, int substringStart, int substringStop, string[] genericTypeParameters, string[] genericMethodParameters)
{
if (substringStart < substringStop) {
string substring = parameterTypeString.Substring(substringStart, substringStop - substringStart);
int indexOfGenericTypeParameter = Array.IndexOf(genericTypeParameters, substring);
int indexOfGenericMethodParameter = Array.IndexOf(genericMethodParameters, substring);
if (indexOfGenericTypeParameter >= 0) {
b.Append("`");
b.Append(indexOfGenericTypeParameter);
}
else if (indexOfGenericMethodParameter >= 0) {
b.Append("``");
b.Append(indexOfGenericMethodParameter);
}
else {
b.Append(substring);
}
}
}
#endregion
}
}

64
ILSpy.AddIn/Commands/OpenCodeItemCommand.cs

@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.Shell;
namespace ICSharpCode.ILSpy.AddIn.Commands
@ -27,55 +30,24 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -27,55 +30,24 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
}
}
protected override void OnExecute(object sender, EventArgs e)
protected override async void OnExecute(object sender, EventArgs e)
{
var document = owner.DTE.ActiveDocument;
var selection = (EnvDTE.TextPoint)((EnvDTE.TextSelection)document.Selection).ActivePoint;
// Search code elements in desired order, working from innermost to outermost.
// Should eventually find something, and if not we'll just open the assembly itself.
var codeElement = GetSelectedCodeElement(selection,
EnvDTE.vsCMElement.vsCMElementFunction,
EnvDTE.vsCMElement.vsCMElementEvent,
EnvDTE.vsCMElement.vsCMElementVariable, // There is no vsCMElementField, fields are just variables outside of function scope.
EnvDTE.vsCMElement.vsCMElementProperty,
EnvDTE.vsCMElement.vsCMElementDelegate,
EnvDTE.vsCMElement.vsCMElementEnum,
EnvDTE.vsCMElement.vsCMElementInterface,
EnvDTE.vsCMElement.vsCMElementStruct,
EnvDTE.vsCMElement.vsCMElementClass,
EnvDTE.vsCMElement.vsCMElementNamespace);
if (codeElement != null) {
OpenCodeItemInILSpy(codeElement);
}
else {
OpenProjectInILSpy(document.ProjectItem.ContainingProject);
}
}
private EnvDTE.CodeElement GetSelectedCodeElement(EnvDTE.TextPoint selection, params EnvDTE.vsCMElement[] elementTypes)
{
foreach (var elementType in elementTypes) {
var codeElement = selection.CodeElement[elementType];
if (codeElement != null) {
return codeElement;
}
}
return null;
}
private void OpenProjectInILSpy(EnvDTE.Project project, params string[] arguments)
{
var roslynProject = owner.Workspace.CurrentSolution.Projects.FirstOrDefault(p => p.FilePath == project.FileName);
OpenAssembliesInILSpy(new[] { roslynProject.OutputFilePath }, arguments);
}
private void OpenCodeItemInILSpy(EnvDTE.CodeElement codeElement)
{
string codeElementKey = CodeElementXmlDocKeyProvider.GetKey(codeElement);
OpenProjectInILSpy(codeElement.ProjectItem.ContainingProject, "/navigateTo:" + codeElementKey);
var id = owner.Workspace.CurrentSolution.GetDocumentIdsWithFilePath(document.FullName).FirstOrDefault();
if (id == null) return;
var roslynDocument = owner.Workspace.CurrentSolution.GetDocument(id);
var ast = await roslynDocument.GetSyntaxRootAsync().ConfigureAwait(false);
var model = await roslynDocument.GetSemanticModelAsync().ConfigureAwait(false);
var node = ast.FindNode(new Microsoft.CodeAnalysis.Text.TextSpan(selection.AbsoluteCharOffset, 1));
if (node == null)
return;
var symbol = model.GetSymbolInfo(node).Symbol;
if (symbol == null)
return;
var refs = GetReferences(roslynDocument.Project).Select(fn => fn.Value).Where(f => File.Exists(f)).ToArray();
OpenAssembliesInILSpy(refs, "/navigateTo:" + symbol.GetDocumentationCommentId());
}
internal static void Register(ILSpyAddInPackage owner)

39
ILSpy.AddIn/Commands/OpenILSpyCommand.cs

@ -7,6 +7,7 @@ using System.Linq; @@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Shell;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.AddIn.Commands
{
@ -40,6 +41,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -40,6 +41,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
foreach (string assemblyFileName in assemblyFileNames) {
if (!File.Exists(assemblyFileName)) {
owner.ShowMessage("Could not find assembly '{0}', please ensure the project and all references were built correctly!", assemblyFileName);
return;
}
}
@ -50,6 +52,43 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -50,6 +52,43 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
System.Diagnostics.Process.Start(GetILSpyPath(), commandLineArguments);
}
protected string GetProjectOutputPath(EnvDTE.Project project, Microsoft.CodeAnalysis.Project roslynProject)
{
string outputFileName = Path.GetFileName(roslynProject.OutputFilePath);
//get the directory path based on the project file.
string projectPath = Path.GetDirectoryName(project.FullName);
//get the output path based on the active configuration
string projectOutputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
//combine the project path and output path to get the bin path
return Path.Combine(projectPath, projectOutputPath, outputFileName);
}
protected Dictionary<string, string> GetReferences(Microsoft.CodeAnalysis.Project parentProject)
{
var dict = new Dictionary<string, string>();
foreach (var reference in parentProject.MetadataReferences) {
using (var assemblyDef = AssemblyDefinition.ReadAssembly(reference.Display)) {
if (IsReferenceAssembly(assemblyDef)) {
dict.Add(assemblyDef.Name.Name, GacInterop.FindAssemblyInNetGac(assemblyDef.Name));
} else {
dict.Add(assemblyDef.Name.Name, reference.Display);
}
}
}
foreach (var projectReference in parentProject.ProjectReferences) {
var roslynProject = owner.Workspace.CurrentSolution.GetProject(projectReference.ProjectId);
var project = owner.DTE.Solution.Projects.OfType<EnvDTE.Project>().FirstOrDefault(p => p.FileName == roslynProject.FilePath);
if (roslynProject != null && project != null)
dict.Add(roslynProject.AssemblyName, GetProjectOutputPath(project, roslynProject));
}
return dict;
}
protected bool IsReferenceAssembly(AssemblyDefinition assemblyDef)
{
return assemblyDef.CustomAttributes.Any(ca => ca.AttributeType.FullName == "System.Runtime.CompilerServices.ReferenceAssemblyAttribute");
}
}
class OpenILSpyCommand : ILSpyCommand

9
ILSpy.AddIn/Commands/OpenProjectOutputCommand.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
namespace ICSharpCode.ILSpy.AddIn.Commands
@ -17,7 +18,13 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -17,7 +18,13 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
if (owner.DTE.SelectedItems.Count != 1) return;
var project = owner.DTE.SelectedItems.Item(1).Project;
var roslynProject = owner.Workspace.CurrentSolution.Projects.FirstOrDefault(p => p.FilePath == project.FileName);
OpenAssembliesInILSpy(new[] { roslynProject.OutputFilePath });
string outputFileName = Path.GetFileName(roslynProject.OutputFilePath);
//get the directory path based on the project file.
string projectPath = Path.GetDirectoryName(project.FullName);
//get the output path based on the active configuration
string projectOutputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
//combine the project path and output path to get the bin path
OpenAssembliesInILSpy(new[] { Path.Combine(projectPath, projectOutputPath, outputFileName) });
}
internal static void Register(ILSpyAddInPackage owner)

28
ILSpy.AddIn/Commands/OpenReferenceCommand.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
if (references.TryGetValue(reference.Name, out var path))
OpenAssembliesInILSpy(new[] { path });
else
owner.ShowMessage("Could not find reference '{0}'.", reference.Name);
owner.ShowMessage("Could not find reference '{0}', please ensure the project and all references were built correctly!", reference.Name);
} else {
dynamic referenceObject = item.Object;
var values = GetProperties(referenceObject.Properties, "Type", "FusionName", "ResolvedPath");
@ -47,34 +47,10 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -47,34 +47,10 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
OpenAssembliesInILSpy(new string[] { GacInterop.FindAssemblyInNetGac(AssemblyNameReference.Parse(values[1])) });
return;
}
owner.ShowMessage("Could not find reference '{0}'.", referenceObject.Name);
owner.ShowMessage("Could not find reference '{0}', please ensure the project and all references were built correctly!", referenceObject.Name);
}
}
private Dictionary<string, string> GetReferences(Microsoft.CodeAnalysis.Project roslynProject)
{
var dict = new Dictionary<string, string>();
foreach (var reference in roslynProject.MetadataReferences) {
using (var assemblyDef = AssemblyDefinition.ReadAssembly(reference.Display)) {
if (IsReferenceAssembly(assemblyDef)) {
dict.Add(assemblyDef.Name.Name, GacInterop.FindAssemblyInNetGac(assemblyDef.Name));
} else {
dict.Add(assemblyDef.Name.Name, reference.Display);
}
}
}
foreach (var projectReference in roslynProject.ProjectReferences) {
var project = owner.Workspace.CurrentSolution.GetProject(projectReference.ProjectId);
dict.Add(project.AssemblyName, project.OutputFilePath);
}
return dict;
}
private bool IsReferenceAssembly(AssemblyDefinition assemblyDef)
{
return assemblyDef.CustomAttributes.Any(ca => ca.AttributeType.FullName == "System.Runtime.CompilerServices.ReferenceAssemblyAttribute");
}
private string[] GetProperties(Properties properties, params string[] names)
{
string[] values = new string[names.Length];

2
ILSpy.AddIn/ILSpy.AddIn.csproj

@ -62,7 +62,6 @@ @@ -62,7 +62,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CodeElementXmlDocKeyProvider.cs" />
<Compile Include="Commands\OpenCodeItemCommand.cs" />
<Compile Include="Commands\OpenILSpyCommand.cs" />
<Compile Include="Commands\OpenProjectOutputCommand.cs" />
@ -77,7 +76,6 @@ @@ -77,7 +76,6 @@
<Compile Include="ILSpyAddInPackage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PkgCmdID.cs" />
<None Include="Samples\ILSpyAddInSamples.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>

2
ILSpy.AddIn/ILSpyAddInPackage.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.ILSpy.AddIn @@ -84,7 +84,7 @@ namespace ICSharpCode.ILSpy.AddIn
OpenILSpyCommand.Register(this);
OpenProjectOutputCommand.Register(this);
OpenReferenceCommand.Register(this);
OpenCodeItemCommand.Register(this);
//OpenCodeItemCommand.Register(this);
}
#endregion

414
ILSpy.AddIn/Samples/ILSpyAddInSamples.cs

@ -1,414 +0,0 @@ @@ -1,414 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
/// Sample source file indicating a wide variety of code elements that should work
/// with the "Open code in ILSpy" Visual Studio add-in feature. Each code element is
/// commented with the string generated by CodeElementXmlDocKeyProvider.GetKey and
/// used with the ILSpy /navigateTo command line option.
///
/// Note that this code is not compiled or used in the project in any way, it is
/// only provided for reference.
// N:ILSpy.AddIn.Tests
namespace ILSpy.AddIn.Tests
{
// T:ILSpy.AddIn.Tests.SomeClass
public class SomeClass
{
// E:ILSpy.AddIn.Tests.SomeClass.OnEvent
public event Action OnEvent;
// F:ILSpy.AddIn.Tests.SomeClass.mField
private int mField;
// P:ILSpy.AddIn.Tests.SomeClass.Property
private int Property
{
get
{
return mField;
}
set
{
mField = value;
}
}
// P:ILSpy.AddIn.Tests.SomeClass.Item(System.Int32,System.Int32)
public int this[int x, int y]
{
get { return x + y + mField; }
}
// M:ILSpy.AddIn.Tests.SomeClass.#ctor
public SomeClass()
{
mField = 0;
}
// M:ILSpy.AddIn.Tests.SomeClass.#ctor(System.Int32)
public SomeClass(int x)
{
mField = x;
}
// M:ILSpy.AddIn.Tests.SomeClass.#ctor(System.Int32,System.Int32)
public SomeClass(int x, int y)
{
mField = x + y;
}
// M:ILSpy.AddIn.Tests.SomeClass.Method
public int Method()
{
return mField;
}
// M:ILSpy.AddIn.Tests.SomeClass.MethodWithGenericParameter(System.IEquatable{System.String})
public void MethodWithGenericParameter(IEquatable<string> x)
{
}
// M:ILSpy.AddIn.Tests.SomeClass.MethodWithGenericParameter(System.IEquatable{System.String},System.Int32)
public void MethodWithGenericParameter(IEquatable<string> x, int y)
{
}
// M:ILSpy.AddIn.Tests.SomeClass.GenericMethod``1(``0)
public int GenericMethod<T>(T x)
{
return mField + x.GetHashCode();
}
// M:ILSpy.AddIn.Tests.SomeClass.GenericOverloadedMethod``1(System.Int32,``0)
public int GenericOverloadedMethod<T1>(int x, T1 y)
{
return mField + x + y.GetHashCode();
}
// M:ILSpy.AddIn.Tests.SomeClass.GenericOverloadedMethod``2(System.Int32,``0,``1)
public int GenericOverloadedMethod<T1, T2>(int x, T1 y, T2 z)
{
return mField + x + y.GetHashCode() + z.GetHashCode();
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedMethod
public int OverloadedMethod()
{
return mField * mField;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedMethod(System.Int32)
public int OverloadedMethod(int m)
{
return mField * m;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedMethod(System.Int32,System.Int32)
public int OverloadedMethod(int m1, int m2)
{
return mField * m1 * m2;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1
public int OverloadedGenericMethod<T>()
{
return mField * mField;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(System.Int32)
public int OverloadedGenericMethod<T>(int m)
{
return mField * m;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(System.Int32,System.Int32)
public int OverloadedGenericMethod<T>(int m1, int m2)
{
return mField * m1 * m2;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(System.Int32,System.Int32,System.Collections.IEnumerable)
public int OverloadedGenericMethod<T>(int m1, int m2, IEnumerable m3)
{
return mField * m1 * m2;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(System.Int32,System.Int32,System.Collections.Generic.IEnumerable{``0})
public int OverloadedGenericMethod<T>(int m1, int m2, IEnumerable<T> m3)
{
return mField * m1 * m2;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(System.Int32,System.Int32,System.Collections.Generic.IEnumerable{System.String})
public int OverloadedGenericMethod<T>(int m1, int m2, IEnumerable<string> m3)
{
return mField * m1 * m2;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(System.Collections.Generic.IEnumerable{System.Collections.Generic.IEnumerable{ILSpy.AddIn.Tests.SomeGenericClass{System.String,``0}}})
public int OverloadedGenericMethod<T>(IEnumerable<IEnumerable<SomeGenericClass<string, T>>> m3)
{
return mField;
}
// M:ILSpy.AddIn.Tests.SomeClass.OverloadedGenericMethod``1(ILSpy.AddIn.Tests.SomeGenericClass{``0,ILSpy.AddIn.Tests.SomeGenericClass{``0,``0}}.NestedGeneric{System.String,``0})
public void OverloadedGenericMethod<T>(SomeGenericClass<T, SomeGenericClass<T, T>>.NestedGeneric<string, T> wow)
{
}
// T:ILSpy.AddIn.Tests.SomeClass.NestedEnum
public enum NestedEnum
{
// F:ILSpy.AddIn.Tests.SomeClass.NestedEnum.First
First = 1,
Second = 2,
Third = 3
}
// T:ILSpy.AddIn.Tests.SomeClass.NestedInterface
public interface NestedInterface
{
// P:ILSpy.AddIn.Tests.SomeClass.NestedInterface.SomeProperty
int SomeProperty { get; }
// M:ILSpy.AddIn.Tests.SomeClass.NestedInterface.SomeMethod
int SomeMethod();
}
// T:ILSpy.AddIn.Tests.SomeClass.NestedClass
public class NestedClass : NestedInterface
{
// F:ILSpy.AddIn.Tests.SomeClass.NestedClass.mX
private int mX;
// M:ILSpy.AddIn.Tests.SomeClass.NestedClass.#ctor(System.Int32)
public NestedClass(int x)
{
mX = x;
}
// M:ILSpy.AddIn.Tests.SomeClass.NestedClass.#ctor(ILSpy.AddIn.Tests.SomeClass.NestedEnum)
public NestedClass(NestedEnum x)
{
mX = (int)x;
}
// P:ILSpy.AddIn.Tests.SomeClass.NestedClass.SomeProperty
public int SomeProperty
{
get { return mX; }
}
// M:ILSpy.AddIn.Tests.SomeClass.NestedClass.SomeMethod
public int SomeMethod()
{
return mX * mX;
}
}
// T:ILSpy.AddIn.Tests.SomeClass.NestedStruct
public struct NestedStruct : NestedInterface
{
// F:ILSpy.AddIn.Tests.SomeClass.NestedStruct.X
public int X;
// F:ILSpy.AddIn.Tests.SomeClass.NestedStruct.Y
public int Y;
// P:ILSpy.AddIn.Tests.SomeClass.NestedStruct.SomeProperty
public int SomeProperty
{
get { return X + Y; }
}
// M:ILSpy.AddIn.Tests.SomeClass.NestedStruct.SomeMethod
public int SomeMethod()
{
return X * Y;
}
}
}
// T:ILSpy.AddIn.Tests.SomeGenericClass`2
public class SomeGenericClass<T1, T2>
{
// F:ILSpy.AddIn.Tests.SomeGenericClass`2.mField1
T1 mField1;
// F:ILSpy.AddIn.Tests.SomeGenericClass`2.mField2
T2 mField2;
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.#ctor(`0,`1)
public SomeGenericClass(T1 a, T2 b)
{
mField1 = a;
mField2 = b;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.#ctor(`0)
public SomeGenericClass(T1 a)
{
mField1 = a;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.#ctor
public SomeGenericClass()
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.Finalize
~SomeGenericClass()
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassMethod(`0,`1)
public void GenericClassMethod(T1 a, T2 b)
{
mField1 = a;
mField2 = b;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassMethod(System.Int32*)
unsafe public void GenericClassMethod(int* x)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassMethod(System.Int32*[])
unsafe public void GenericClassMethod(int*[] x)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassMethod(`0[]@)
unsafe public void GenericClassMethod(out T1[] x)
{
x = null;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassMethod(System.Int32@)
public void GenericClassMethod(ref int a)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``1(``0@)
public T3 GenericClassGenericMethod<T3>(ref T3 x)
{
return x;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``1
public T3 GenericClassGenericMethod<T3>()
{
return default(T3);
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``1(System.Int32)
public void GenericClassGenericMethod<T3>(int x)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``2(`0,``1,System.Int32,`1@)
public T4 GenericClassGenericMethod<T3, T4>(T1 x, T4 y, int z, out T2 result)
{
mField1 = x;
string foo = y.ToString() + z.ToString();
result = mField2;
return y;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``2(`0,``0,System.Int32[])
public T3 GenericClassGenericMethod<T3, T4>(T1 x, T3 y, int[] z)
{
mField1 = x;
string foo = y.ToString() + z.ToString();
return y;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.ArrayMethod(`0[],System.Int32[])
public void ArrayMethod(T1[] x, int[] y)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.ArrayMethod(`0[0:,0:],System.Int32[0:,0:])
public void ArrayMethod(T1[,] x, int[,] y)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.ArrayMethod(System.Int32[0:,0:],System.Int32[0:,0:])
public void ArrayMethod(int[,] x, int[,] y)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.ArrayMethod(`0[][],System.Int32[][])
public void ArrayMethod(T1[][] x, int[][] y)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``2(`0,``0,ILSpy.AddIn.Tests.SomeClass)
public T3 GenericClassGenericMethod<T3, T4>(T1 x, T3 y, SomeClass z)
{
return y;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``2(`0,``0,ILSpy.AddIn.Tests.SomeClass[]@)
public T3 GenericClassGenericMethod<T3, T4>(T1 x, T3 y, out SomeClass[] z)
{
z = null;
return y;
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.GenericClassGenericMethod``2(System.Int32[],ILSpy.AddIn.Tests.SomeGenericClass{``0[],``1[0:,0:,0:]}[0:,0:,0:])
public void GenericClassGenericMethod<T3, T4>(int[] x, SomeGenericClass<T3[], T4[,,]>[,,] y)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.op_Addition(ILSpy.AddIn.Tests.SomeGenericClass{`0,`1},ILSpy.AddIn.Tests.SomeGenericClass{`0,`1})
public static SomeGenericClass<T1, T2> operator +(SomeGenericClass<T1, T2> a, SomeGenericClass<T1, T2> b)
{
return new SomeGenericClass<T1, T2>();
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.op_Explicit(ILSpy.AddIn.Tests.SomeGenericClass{`0,`1})~ILSpy.AddIn.Tests.SomeGenericClass`2.NestedGeneric`2
public static explicit operator NestedGeneric<T1, T2>(SomeGenericClass<T1, T2> sgc)
{
return new NestedGeneric<T1, T2>();
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.op_Implicit(ILSpy.AddIn.Tests.SomeGenericClass{`0,`1})~ILSpy.AddIn.Tests.SomeGenericClass`2.NestedGeneric`2
public static implicit operator NestedGeneric<T2, T1>(SomeGenericClass<T1, T2> sgc)
{
return new NestedGeneric<T2, T1>();
}
// T:ILSpy.AddIn.Tests.SomeGenericClass`2.NestedGeneric`2
public class NestedGeneric<T3, T4>
{
// T:ILSpy.AddIn.Tests.SomeGenericClass`2.NestedGeneric`2.NestedDelegate
public delegate int NestedDelegate(T3 x, IEnumerable<T4> y);
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.NestedGeneric`2.NestedGenericMethod``1(`0,``0)
public void NestedGenericMethod<T5>(T1 x, T5 y)
{
}
// M:ILSpy.AddIn.Tests.SomeGenericClass`2.NestedGeneric`2.NestedGenericMethod``3(`0,`3,``0[],System.Collections.Generic.IEnumerable{``2})
public void NestedGenericMethod<T5, T6, T7>(T1 x, T4 y, T5[] z, IEnumerable<T7> w)
{
}
}
}
}
// T:SpaceFreeClass
class SpaceFreeClass
{
// F:SpaceFreeClass.mField
int mField;
// M:SpaceFreeClass.Method
private void Method()
{
}
}

28
ILSpy/Commands/DecompileAllCommand.cs

@ -20,7 +20,9 @@ @@ -20,7 +20,9 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.TextView;
namespace ICSharpCode.ILSpy
@ -64,6 +66,32 @@ namespace ICSharpCode.ILSpy @@ -64,6 +66,32 @@ namespace ICSharpCode.ILSpy
}, ct)).Then(output => MainWindow.Instance.TextView.ShowText(output)).HandleExceptions();
}
}
[ExportMainMenuCommand(Menu = "_File", Header = "DEBUG -- Decompile 100x", MenuCategory = "Open", MenuOrder = 2.6)]
sealed class Decompile100TimesCommand : SimpleCommand
{
public override void Execute(object parameter)
{
const int numRuns = 100;
var language = MainWindow.Instance.CurrentLanguage;
var nodes = MainWindow.Instance.SelectedNodes.ToArray();
var options = new DecompilationOptions();
MainWindow.Instance.TextView.RunWithCancellation(ct => Task<AvalonEditTextOutput>.Factory.StartNew(() => {
options.CancellationToken = ct;
Stopwatch w = Stopwatch.StartNew();
for (int i = 0; i < numRuns; ++i) {
foreach (var node in nodes) {
node.Decompile(language, new PlainTextOutput(), options);
}
}
w.Stop();
AvalonEditTextOutput output = new AvalonEditTextOutput();
double msPerRun = w.Elapsed.TotalMilliseconds / numRuns;
output.Write($"Average time: {msPerRun.ToString("f1")}ms\n");
return output;
}, ct)).Then(output => MainWindow.Instance.TextView.ShowText(output)).HandleExceptions();
}
}
}
#endif
Loading…
Cancel
Save