Browse Source

Extend test cases

pull/3497/head
Siegfried Pammer 1 week ago
parent
commit
4203a681d8
  1. 4
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 17
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.Expected.cs
  3. 15
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.cs
  4. 68
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.Expected.cs
  5. 27
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.cs
  6. 98
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.il
  7. 77
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.net40.roslyn.il
  8. 81
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.opt.il
  9. 58
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.opt.net40.roslyn.il
  10. 66
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.opt.roslyn.il
  11. 85
      ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.roslyn.il
  12. 3
      ICSharpCode.Decompiler.Tests/UglyTestRunner.cs

4
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -152,8 +152,8 @@
<Compile Include="TestCases\Pretty\Issue3442.cs" /> <Compile Include="TestCases\Pretty\Issue3442.cs" />
<Compile Include="TestCases\Pretty\Issue3483.cs" /> <Compile Include="TestCases\Pretty\Issue3483.cs" />
<Compile Include="TestCases\Pretty\PointerArithmetic.cs" /> <Compile Include="TestCases\Pretty\PointerArithmetic.cs" />
<Compile Include="TestCases\Ugly\NoGenericTypeInstantiation.cs" /> <Compile Include="TestCases\Ugly\NoNewOfT.cs" />
<None Include="TestCases\Ugly\NoGenericTypeInstantiation.Expected.cs" /> <None Include="TestCases\Ugly\NoNewOfT.Expected.cs" />
<Compile Include="TestCases\Pretty\ParamsCollections.cs" /> <Compile Include="TestCases\Pretty\ParamsCollections.cs" />
<None Include="TestCases\VBPretty\VBAutomaticEvents.vb" /> <None Include="TestCases\VBPretty\VBAutomaticEvents.vb" />
<Compile Include="TestCases\VBPretty\VBAutomaticEvents.cs" /> <Compile Include="TestCases\VBPretty\VBAutomaticEvents.cs" />

17
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.Expected.cs

@ -1,17 +0,0 @@
using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly
{
internal class NoGenericTypeInstantiation<TOnType> where TOnType : new()
{
public static TOnType CreateTOnType()
{
return Activator.CreateInstance<TOnType>();
}
public static TOnMethod CreateTOnMethod<TOnMethod>() where TOnMethod : new()
{
return Activator.CreateInstance<TOnMethod>();
}
}
}

15
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.cs

@ -1,15 +0,0 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly
{
internal class NoGenericTypeInstantiation<TOnType> where TOnType : new()
{
public static TOnType CreateTOnType()
{
return new TOnType();
}
public static TOnMethod CreateTOnMethod<TOnMethod>() where TOnMethod : new()
{
return new TOnMethod();
}
}
}

68
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.Expected.cs

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly
{
internal class NoNewOfT<TOnType> where TOnType : new()
{
public static TOnType CreateTOnType()
{
#if !ROSLYN
#if OPT
if (default(TOnType) != null)
{
return default(TOnType);
}
return Activator.CreateInstance<TOnType>();
#else
return (default(TOnType) == null) ? Activator.CreateInstance<TOnType>() : default(TOnType);
#endif
#else
return Activator.CreateInstance<TOnType>();
#endif
}
public static T CreateUnconstrainedT<T>() where T : new()
{
#if !ROSLYN
#if OPT
if (default(T) != null)
{
return default(T);
}
return Activator.CreateInstance<T>();
#else
return (default(T) == null) ? Activator.CreateInstance<T>() : default(T);
#endif
#else
return Activator.CreateInstance<T>();
#endif
}
public static T CreateClassT<T>() where T : class, new()
{
return Activator.CreateInstance<T>();
}
public static T CollectionInitializer<T>() where T : IList<int>, new()
{
#if ROSLYN
T result = Activator.CreateInstance<T>();
result.Add(1);
result.Add(2);
result.Add(3);
result.Add(4);
result.Add(5);
return result;
#else
T val = ((default(T) == null) ? Activator.CreateInstance<T>() : default(T));
val.Add(1);
val.Add(2);
val.Add(3);
val.Add(4);
val.Add(5);
return val;
#endif
}
}
}

27
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.cs

@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly
{
internal class NoNewOfT<TOnType> where TOnType : new()
{
public static TOnType CreateTOnType()
{
return new TOnType();
}
public static T CreateUnconstrainedT<T>() where T : new()
{
return new T();
}
public static T CreateClassT<T>() where T : class, new()
{
return new T();
}
public static T CollectionInitializer<T>() where T : IList<int>, new()
{
return new T() { 1, 2, 3, 4, 5 };
}
}
}

98
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.il → ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.il

@ -9,7 +9,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly tmppi3wbt .assembly tmpvpdwr1
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .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
@ -19,8 +19,8 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module tmppi3wbt.tmp .module tmpvpdwr1.tmp
// MVID: {4130db71-37be-40af-9724-d988f7189866} // MVID: {8447adbb-757d-4626-b7b7-846d745d90d0}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
@ -31,7 +31,7 @@
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1<.ctor TOnType> .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1<.ctor TOnType>
extends [mscorlib]System.Object extends [mscorlib]System.Object
{ {
.method public hidebysig static !TOnType .method public hidebysig static !TOnType
@ -60,24 +60,23 @@
IL_0025: ldloc.0 IL_0025: ldloc.0
IL_0026: ret IL_0026: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnType } // end of method NoNewOfT`1::CreateTOnType
.method public hidebysig static !!TOnMethod .method public hidebysig static !!T CreateUnconstrainedT<.ctor T>() cil managed
CreateTOnMethod<.ctor TOnMethod>() cil managed
{ {
// Code size 39 (0x27) // Code size 39 (0x27)
.maxstack 1 .maxstack 1
.locals init (!!TOnMethod V_0, .locals init (!!T V_0,
!!TOnMethod V_1) !!T V_1)
IL_0000: nop IL_0000: nop
IL_0001: ldloca.s V_1 IL_0001: ldloca.s V_1
IL_0003: initobj !!TOnMethod IL_0003: initobj !!T
IL_0009: ldloc.1 IL_0009: ldloc.1
IL_000a: box !!TOnMethod IL_000a: box !!T
IL_000f: brfalse.s IL_001c IL_000f: brfalse.s IL_001c
IL_0011: ldloca.s V_1 IL_0011: ldloca.s V_1
IL_0013: initobj !!TOnMethod IL_0013: initobj !!T
IL_0019: ldloc.1 IL_0019: ldloc.1
IL_001a: br.s IL_0021 IL_001a: br.s IL_0021
@ -88,7 +87,76 @@
IL_0025: ldloc.0 IL_0025: ldloc.0
IL_0026: ret IL_0026: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnMethod } // end of method NoNewOfT`1::CreateUnconstrainedT
.method public hidebysig static !!T CreateClassT<class .ctor T>() cil managed
{
// Code size 11 (0xb)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method NoNewOfT`1::CreateClassT
.method public hidebysig static !!T CollectionInitializer<.ctor (class [mscorlib]System.Collections.Generic.IList`1<int32>) T>() cil managed
{
// Code size 106 (0x6a)
.maxstack 2
.locals init (!!T V_0,
!!T V_1,
!!T V_2)
IL_0000: nop
IL_0001: ldloca.s V_2
IL_0003: initobj !!T
IL_0009: ldloc.2
IL_000a: box !!T
IL_000f: brfalse.s IL_001c
IL_0011: ldloca.s V_2
IL_0013: initobj !!T
IL_0019: ldloc.2
IL_001a: br.s IL_0021
IL_001c: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0021: nop
IL_0022: stloc.0
IL_0023: ldloc.0
IL_0024: box !!T
IL_0029: ldc.i4.1
IL_002a: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_002f: nop
IL_0030: ldloc.0
IL_0031: box !!T
IL_0036: ldc.i4.2
IL_0037: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_003c: nop
IL_003d: ldloc.0
IL_003e: box !!T
IL_0043: ldc.i4.3
IL_0044: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0049: nop
IL_004a: ldloc.0
IL_004b: box !!T
IL_0050: ldc.i4.4
IL_0051: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0056: nop
IL_0057: ldloc.0
IL_0058: box !!T
IL_005d: ldc.i4.5
IL_005e: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0063: nop
IL_0064: ldloc.0
IL_0065: stloc.1
IL_0066: br.s IL_0068
IL_0068: ldloc.1
IL_0069: ret
} // end of method NoNewOfT`1::CollectionInitializer
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed instance void .ctor() cil managed
@ -98,9 +166,9 @@
IL_0000: ldarg.0 IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret IL_0006: ret
} // end of method NoGenericTypeInstantiation`1::.ctor } // end of method NoNewOfT`1::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1 } // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1
// ============================================================= // =============================================================

77
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.net40.roslyn.il → ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.net40.roslyn.il

@ -9,7 +9,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly tmphku2gd .assembly tmpyccvci
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .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
@ -23,8 +23,8 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module tmphku2gd.tmp .module tmpyccvci.tmp
// MVID: {1307db53-f6c4-45d3-a995-8cb116ea8821} // MVID: {ff6a33b6-7f19-447b-b168-f5c528dc4b6f}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 ) .custom instance void System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
@ -134,7 +134,7 @@
} // end of class System.Runtime.CompilerServices.RequiredMemberAttribute } // end of class System.Runtime.CompilerServices.RequiredMemberAttribute
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1<.ctor TOnType> .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1<.ctor TOnType>
extends [mscorlib]System.Object extends [mscorlib]System.Object
{ {
.method public hidebysig static !TOnType .method public hidebysig static !TOnType
@ -150,14 +150,13 @@
IL_0009: ldloc.0 IL_0009: ldloc.0
IL_000a: ret IL_000a: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnType } // end of method NoNewOfT`1::CreateTOnType
.method public hidebysig static !!TOnMethod .method public hidebysig static !!T CreateUnconstrainedT<.ctor T>() cil managed
CreateTOnMethod<.ctor TOnMethod>() cil managed
{ {
// Code size 11 (0xb) // Code size 11 (0xb)
.maxstack 1 .maxstack 1
.locals init (!!TOnMethod V_0) .locals init (!!T V_0)
IL_0000: nop IL_0000: nop
IL_0001: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>() IL_0001: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0 IL_0006: stloc.0
@ -165,7 +164,63 @@
IL_0009: ldloc.0 IL_0009: ldloc.0
IL_000a: ret IL_000a: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnMethod } // end of method NoNewOfT`1::CreateUnconstrainedT
.method public hidebysig static !!T CreateClassT<class .ctor T>() cil managed
{
// Code size 11 (0xb)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method NoNewOfT`1::CreateClassT
.method public hidebysig static !!T CollectionInitializer<.ctor (class [mscorlib]System.Collections.Generic.IList`1<int32>) T>() cil managed
{
// Code size 88 (0x58)
.maxstack 2
.locals init (!!T V_0,
!!T V_1)
IL_0000: nop
IL_0001: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: ldc.i4.1
IL_000a: constrained. !!T
IL_0010: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0015: nop
IL_0016: ldloca.s V_0
IL_0018: ldc.i4.2
IL_0019: constrained. !!T
IL_001f: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0024: nop
IL_0025: ldloca.s V_0
IL_0027: ldc.i4.3
IL_0028: constrained. !!T
IL_002e: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0033: nop
IL_0034: ldloca.s V_0
IL_0036: ldc.i4.4
IL_0037: constrained. !!T
IL_003d: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0042: nop
IL_0043: ldloca.s V_0
IL_0045: ldc.i4.5
IL_0046: constrained. !!T
IL_004c: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0051: nop
IL_0052: ldloc.0
IL_0053: stloc.1
IL_0054: br.s IL_0056
IL_0056: ldloc.1
IL_0057: ret
} // end of method NoNewOfT`1::CollectionInitializer
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed instance void .ctor() cil managed
@ -176,9 +231,9 @@
IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop IL_0006: nop
IL_0007: ret IL_0007: ret
} // end of method NoGenericTypeInstantiation`1::.ctor } // end of method NoNewOfT`1::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1 } // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1
// ============================================================= // =============================================================

81
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.opt.il → ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.opt.il

@ -9,7 +9,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly tmp4sutck .assembly tmp1ekgox
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .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
@ -19,8 +19,8 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module tmp4sutck.tmp .module tmp1ekgox.tmp
// MVID: {8529154b-7a90-417c-b54f-0d5c900533db} // MVID: {67ce32bd-0144-4136-a198-2fc9f941f624}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
@ -31,7 +31,7 @@
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1<.ctor TOnType> .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1<.ctor TOnType>
extends [mscorlib]System.Object extends [mscorlib]System.Object
{ {
.method public hidebysig static !TOnType .method public hidebysig static !TOnType
@ -54,29 +54,80 @@
IL_001a: call !!0 [mscorlib]System.Activator::CreateInstance<!TOnType>() IL_001a: call !!0 [mscorlib]System.Activator::CreateInstance<!TOnType>()
IL_001f: ret IL_001f: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnType } // end of method NoNewOfT`1::CreateTOnType
.method public hidebysig static !!TOnMethod .method public hidebysig static !!T CreateUnconstrainedT<.ctor T>() cil managed
CreateTOnMethod<.ctor TOnMethod>() cil managed
{ {
// Code size 32 (0x20) // Code size 32 (0x20)
.maxstack 1 .maxstack 1
.locals init (!!TOnMethod V_0, .locals init (!!T V_0,
!!TOnMethod V_1) !!T V_1)
IL_0000: ldloca.s V_0 IL_0000: ldloca.s V_0
IL_0002: initobj !!TOnMethod IL_0002: initobj !!T
IL_0008: ldloc.0 IL_0008: ldloc.0
IL_0009: box !!TOnMethod IL_0009: box !!T
IL_000e: brfalse.s IL_001a IL_000e: brfalse.s IL_001a
IL_0010: ldloca.s V_1 IL_0010: ldloca.s V_1
IL_0012: initobj !!TOnMethod IL_0012: initobj !!T
IL_0018: ldloc.1 IL_0018: ldloc.1
IL_0019: ret IL_0019: ret
IL_001a: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>() IL_001a: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_001f: ret IL_001f: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnMethod } // end of method NoNewOfT`1::CreateUnconstrainedT
.method public hidebysig static !!T CreateClassT<class .ctor T>() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0005: ret
} // end of method NoNewOfT`1::CreateClassT
.method public hidebysig static !!T CollectionInitializer<.ctor (class [mscorlib]System.Collections.Generic.IList`1<int32>) T>() cil managed
{
// Code size 95 (0x5f)
.maxstack 2
.locals init (!!T V_0,
!!T V_1,
!!T V_2)
IL_0000: ldloca.s V_1
IL_0002: initobj !!T
IL_0008: ldloc.1
IL_0009: box !!T
IL_000e: brfalse.s IL_001b
IL_0010: ldloca.s V_2
IL_0012: initobj !!T
IL_0018: ldloc.2
IL_0019: br.s IL_0020
IL_001b: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0020: stloc.0
IL_0021: ldloc.0
IL_0022: box !!T
IL_0027: ldc.i4.1
IL_0028: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_002d: ldloc.0
IL_002e: box !!T
IL_0033: ldc.i4.2
IL_0034: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0039: ldloc.0
IL_003a: box !!T
IL_003f: ldc.i4.3
IL_0040: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0045: ldloc.0
IL_0046: box !!T
IL_004b: ldc.i4.4
IL_004c: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0051: ldloc.0
IL_0052: box !!T
IL_0057: ldc.i4.5
IL_0058: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_005d: ldloc.0
IL_005e: ret
} // end of method NoNewOfT`1::CollectionInitializer
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed instance void .ctor() cil managed
@ -86,9 +137,9 @@
IL_0000: ldarg.0 IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret IL_0006: ret
} // end of method NoGenericTypeInstantiation`1::.ctor } // end of method NoNewOfT`1::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1 } // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1
// ============================================================= // =============================================================

58
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.opt.net40.roslyn.il → ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.opt.net40.roslyn.il

@ -9,7 +9,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly tmp2yw4m4 .assembly tmp4xstme
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .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
@ -23,8 +23,8 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module tmp2yw4m4.tmp .module tmp4xstme.tmp
// MVID: {1cd5c846-415a-403b-98cb-2fd0dd281694} // MVID: {a031faef-fcb2-420c-9cd3-6e9b01e7f81e}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 ) .custom instance void System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
@ -128,7 +128,7 @@
} // end of class System.Runtime.CompilerServices.RequiredMemberAttribute } // end of class System.Runtime.CompilerServices.RequiredMemberAttribute
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1<.ctor TOnType> .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1<.ctor TOnType>
extends [mscorlib]System.Object extends [mscorlib]System.Object
{ {
.method public hidebysig static !TOnType .method public hidebysig static !TOnType
@ -138,16 +138,54 @@
.maxstack 8 .maxstack 8
IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!TOnType>() IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!TOnType>()
IL_0005: ret IL_0005: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnType } // end of method NoNewOfT`1::CreateTOnType
.method public hidebysig static !!TOnMethod .method public hidebysig static !!T CreateUnconstrainedT<.ctor T>() cil managed
CreateTOnMethod<.ctor TOnMethod>() cil managed
{ {
// Code size 6 (0x6) // Code size 6 (0x6)
.maxstack 8 .maxstack 8
IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>() IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0005: ret IL_0005: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnMethod } // end of method NoNewOfT`1::CreateUnconstrainedT
.method public hidebysig static !!T CreateClassT<class .ctor T>() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0005: ret
} // end of method NoNewOfT`1::CreateClassT
.method public hidebysig static !!T CollectionInitializer<.ctor (class [mscorlib]System.Collections.Generic.IList`1<int32>) T>() cil managed
{
// Code size 78 (0x4e)
.maxstack 2
.locals init (!!T V_0)
IL_0000: call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: ldc.i4.1
IL_0009: constrained. !!T
IL_000f: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0014: ldloca.s V_0
IL_0016: ldc.i4.2
IL_0017: constrained. !!T
IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0022: ldloca.s V_0
IL_0024: ldc.i4.3
IL_0025: constrained. !!T
IL_002b: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0030: ldloca.s V_0
IL_0032: ldc.i4.4
IL_0033: constrained. !!T
IL_0039: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_003e: ldloca.s V_0
IL_0040: ldc.i4.5
IL_0041: constrained. !!T
IL_0047: callvirt instance void class [mscorlib]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_004c: ldloc.0
IL_004d: ret
} // end of method NoNewOfT`1::CollectionInitializer
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed instance void .ctor() cil managed
@ -157,9 +195,9 @@
IL_0000: ldarg.0 IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret IL_0006: ret
} // end of method NoGenericTypeInstantiation`1::.ctor } // end of method NoNewOfT`1::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1 } // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1
// ============================================================= // =============================================================

66
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.opt.roslyn.il → ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.opt.roslyn.il

@ -7,9 +7,9 @@
.assembly extern System.Runtime .assembly extern System.Runtime
{ {
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 8:0:0:0 .ver 10:0:0:0
} }
.assembly tmpbfpzzx .assembly tmpauzspg
{ {
.custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
@ -18,17 +18,15 @@
// --- The following custom attribute is added automatically, do not uncomment ------- // --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 ) // .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01 00 18 2E 4E 45 54 43 6F 72 65 41 70 70 2C 56 // ....NETCoreApp,V .custom instance void [System.Runtime]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01 00 19 2E 4E 45 54 43 6F 72 65 41 70 70 2C 56 // ....NETCoreApp,V
65 72 73 69 6F 6E 3D 76 38 2E 30 01 00 54 0E 14 // ersion=v8.0..T.. 65 72 73 69 6F 6E 3D 76 31 30 2E 30 00 00 ) // ersion=v10.0..
46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C 61 79 // FrameworkDisplay
4E 61 6D 65 00 ) // Name.
.permissionset reqmin .permissionset reqmin
= {[System.Runtime]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} = {[System.Runtime]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module tmpbfpzzx.tmp .module tmpauzspg.tmp
// MVID: {5d4ee8e5-8c47-4519-bd9e-e6d2d3628bfc} // MVID: {6d3a3b63-d01c-49f7-9515-565421f78266}
.custom instance void [System.Runtime]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 ) .custom instance void [System.Runtime]System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
@ -40,7 +38,7 @@
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1<.ctor TOnType> .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1<.ctor TOnType>
extends [System.Runtime]System.Object extends [System.Runtime]System.Object
{ {
.method public hidebysig static !TOnType .method public hidebysig static !TOnType
@ -50,16 +48,54 @@
.maxstack 8 .maxstack 8
IL_0000: call !!0 [System.Runtime]System.Activator::CreateInstance<!TOnType>() IL_0000: call !!0 [System.Runtime]System.Activator::CreateInstance<!TOnType>()
IL_0005: ret IL_0005: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnType } // end of method NoNewOfT`1::CreateTOnType
.method public hidebysig static !!TOnMethod .method public hidebysig static !!T CreateUnconstrainedT<.ctor T>() cil managed
CreateTOnMethod<.ctor TOnMethod>() cil managed
{ {
// Code size 6 (0x6) // Code size 6 (0x6)
.maxstack 8 .maxstack 8
IL_0000: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>() IL_0000: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>()
IL_0005: ret IL_0005: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnMethod } // end of method NoNewOfT`1::CreateUnconstrainedT
.method public hidebysig static !!T CreateClassT<class .ctor T>() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>()
IL_0005: ret
} // end of method NoNewOfT`1::CreateClassT
.method public hidebysig static !!T CollectionInitializer<.ctor (class [System.Runtime]System.Collections.Generic.IList`1<int32>) T>() cil managed
{
// Code size 78 (0x4e)
.maxstack 2
.locals init (!!T V_0)
IL_0000: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>()
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: ldc.i4.1
IL_0009: constrained. !!T
IL_000f: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0014: ldloca.s V_0
IL_0016: ldc.i4.2
IL_0017: constrained. !!T
IL_001d: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0022: ldloca.s V_0
IL_0024: ldc.i4.3
IL_0025: constrained. !!T
IL_002b: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0030: ldloca.s V_0
IL_0032: ldc.i4.4
IL_0033: constrained. !!T
IL_0039: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_003e: ldloca.s V_0
IL_0040: ldc.i4.5
IL_0041: constrained. !!T
IL_0047: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_004c: ldloc.0
IL_004d: ret
} // end of method NoNewOfT`1::CollectionInitializer
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed instance void .ctor() cil managed
@ -69,9 +105,9 @@
IL_0000: ldarg.0 IL_0000: ldarg.0
IL_0001: call instance void [System.Runtime]System.Object::.ctor() IL_0001: call instance void [System.Runtime]System.Object::.ctor()
IL_0006: ret IL_0006: ret
} // end of method NoGenericTypeInstantiation`1::.ctor } // end of method NoNewOfT`1::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1 } // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1
// ============================================================= // =============================================================

85
ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoGenericTypeInstantiation.roslyn.il → ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoNewOfT.roslyn.il

@ -7,9 +7,9 @@
.assembly extern System.Runtime .assembly extern System.Runtime
{ {
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 8:0:0:0 .ver 10:0:0:0
} }
.assembly tmpw4dati .assembly tmpybdlca
{ {
.custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
@ -18,17 +18,15 @@
// --- The following custom attribute is added automatically, do not uncomment ------- // --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) // .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01 00 18 2E 4E 45 54 43 6F 72 65 41 70 70 2C 56 // ....NETCoreApp,V .custom instance void [System.Runtime]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01 00 19 2E 4E 45 54 43 6F 72 65 41 70 70 2C 56 // ....NETCoreApp,V
65 72 73 69 6F 6E 3D 76 38 2E 30 01 00 54 0E 14 // ersion=v8.0..T.. 65 72 73 69 6F 6E 3D 76 31 30 2E 30 00 00 ) // ersion=v10.0..
46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C 61 79 // FrameworkDisplay
4E 61 6D 65 00 ) // Name.
.permissionset reqmin .permissionset reqmin
= {[System.Runtime]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} = {[System.Runtime]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module tmpw4dati.tmp .module tmpybdlca.tmp
// MVID: {901dcf98-cf20-4065-abc3-85086e5af113} // MVID: {b57f13a4-d291-42ea-b595-3766c1f1470c}
.custom instance void [System.Runtime]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 ) .custom instance void [System.Runtime]System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
@ -40,7 +38,7 @@
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1<.ctor TOnType> .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1<.ctor TOnType>
extends [System.Runtime]System.Object extends [System.Runtime]System.Object
{ {
.method public hidebysig static !TOnType .method public hidebysig static !TOnType
@ -56,14 +54,13 @@
IL_0009: ldloc.0 IL_0009: ldloc.0
IL_000a: ret IL_000a: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnType } // end of method NoNewOfT`1::CreateTOnType
.method public hidebysig static !!TOnMethod .method public hidebysig static !!T CreateUnconstrainedT<.ctor T>() cil managed
CreateTOnMethod<.ctor TOnMethod>() cil managed
{ {
// Code size 11 (0xb) // Code size 11 (0xb)
.maxstack 1 .maxstack 1
.locals init (!!TOnMethod V_0) .locals init (!!T V_0)
IL_0000: nop IL_0000: nop
IL_0001: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>() IL_0001: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0 IL_0006: stloc.0
@ -71,7 +68,63 @@
IL_0009: ldloc.0 IL_0009: ldloc.0
IL_000a: ret IL_000a: ret
} // end of method NoGenericTypeInstantiation`1::CreateTOnMethod } // end of method NoNewOfT`1::CreateUnconstrainedT
.method public hidebysig static !!T CreateClassT<class .ctor T>() cil managed
{
// Code size 11 (0xb)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method NoNewOfT`1::CreateClassT
.method public hidebysig static !!T CollectionInitializer<.ctor (class [System.Runtime]System.Collections.Generic.IList`1<int32>) T>() cil managed
{
// Code size 88 (0x58)
.maxstack 2
.locals init (!!T V_0,
!!T V_1)
IL_0000: nop
IL_0001: call !!0 [System.Runtime]System.Activator::CreateInstance<!!0>()
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: ldc.i4.1
IL_000a: constrained. !!T
IL_0010: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0015: nop
IL_0016: ldloca.s V_0
IL_0018: ldc.i4.2
IL_0019: constrained. !!T
IL_001f: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0024: nop
IL_0025: ldloca.s V_0
IL_0027: ldc.i4.3
IL_0028: constrained. !!T
IL_002e: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0033: nop
IL_0034: ldloca.s V_0
IL_0036: ldc.i4.4
IL_0037: constrained. !!T
IL_003d: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0042: nop
IL_0043: ldloca.s V_0
IL_0045: ldc.i4.5
IL_0046: constrained. !!T
IL_004c: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<int32>::Add(!0)
IL_0051: nop
IL_0052: ldloc.0
IL_0053: stloc.1
IL_0054: br.s IL_0056
IL_0056: ldloc.1
IL_0057: ret
} // end of method NoNewOfT`1::CollectionInitializer
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname
instance void .ctor() cil managed instance void .ctor() cil managed
@ -82,9 +135,9 @@
IL_0001: call instance void [System.Runtime]System.Object::.ctor() IL_0001: call instance void [System.Runtime]System.Object::.ctor()
IL_0006: nop IL_0006: nop
IL_0007: ret IL_0007: ret
} // end of method NoGenericTypeInstantiation`1::.ctor } // end of method NoNewOfT`1::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoGenericTypeInstantiation`1 } // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoNewOfT`1
// ============================================================= // =============================================================

3
ICSharpCode.Decompiler.Tests/UglyTestRunner.cs

@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.CodeDom.Compiler;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -133,7 +132,7 @@ namespace ICSharpCode.Decompiler.Tests
} }
[Test] [Test]
public async Task NoGenericTypeInstantiation([ValueSource(nameof(roslynOnlyOptions))] CompilerOptions cscOptions) public async Task NoNewOfT([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{ {
await RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings(CSharp.LanguageVersion.CSharp1)); await RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings(CSharp.LanguageVersion.CSharp1));
} }

Loading…
Cancel
Save