Browse Source

Add old Generics tests as pretty test. Note that a few test cases are deactivated because we're emitting extra casts.

pull/1440/head
Siegfried Pammer 7 years ago
parent
commit
1eb1c0ba67
  1. 165
      ICSharpCode.Decompiler.Tests/Generics.cs
  2. 145
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.cs
  3. 376
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.il
  4. 304
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.opt.il
  5. 304
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.opt.roslyn.il
  6. 380
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.roslyn.il

165
ICSharpCode.Decompiler.Tests/Generics.cs

@ -1,165 +0,0 @@ @@ -1,165 +0,0 @@
// Copyright (c) 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;
public static class Generics
{
public class MyArray<T>
{
public class NestedClass<Y>
{
public T Item1;
public Y Item2;
}
public enum NestedEnum
{
A,
B
}
private T[] arr;
public MyArray(int capacity)
{
this.arr = new T[capacity];
}
public void Size(int capacity)
{
Array.Resize<T>(ref this.arr, capacity);
}
public void Grow(int capacity)
{
if (capacity >= this.arr.Length)
{
this.Size(capacity);
}
}
}
public interface IInterface
{
void Method1<T>() where T : class;
void Method2<T>() where T : class;
}
public abstract class Base : Generics.IInterface
{
// constraints must be repeated on implicit interface implementation
public abstract void Method1<T>() where T : class;
// constraints must not be specified on explicit interface implementation
void Generics.IInterface.Method2<T>()
{
}
}
public class Derived : Generics.Base
{
// constraints are inherited automatically and must not be specified
public override void Method1<T>()
{
}
}
private const Generics.MyArray<string>.NestedEnum enumVal = Generics.MyArray<string>.NestedEnum.A;
private static Type type1 = typeof(List<>);
private static Type type2 = typeof(Generics.MyArray<>);
private static Type type3 = typeof(List<>.Enumerator);
private static Type type4 = typeof(Generics.MyArray<>.NestedClass<>);
private static Type type5 = typeof(List<int>[]);
private static Type type6 = typeof(Generics.MyArray<>.NestedEnum);
public static void MethodWithConstraint<T, S>() where T : class, S where S : ICloneable, new()
{
}
public static void MethodWithStructConstraint<T>() where T : struct
{
}
private static void MultidimensionalArray<T>(T[,] array)
{
array[0, 0] = array[0, 1];
}
public static Dictionary<string, string>.KeyCollection.Enumerator GetEnumerator(Dictionary<string, string> d, Generics.MyArray<string>.NestedClass<int> nc)
{
// Tests references to inner classes in generic classes
return d.Keys.GetEnumerator();
}
public static bool IsString<T>(T input)
{
return input is string;
}
public static string AsString<T>(T input)
{
return input as string;
}
public static string CastToString<T>(T input)
{
return (string)((object)input);
}
public static T CastFromString<T>(string input)
{
return (T)((object)input);
}
public static bool IsInt<T>(T input)
{
return input is int;
}
public static int CastToInt<T>(T input)
{
return (int)((object)input);
}
public static T CastFromInt<T>(int input)
{
return (T)((object)input);
}
public static bool IsNullableInt<T>(T input)
{
return input is int?;
}
public static int? AsNullableInt<T>(T input)
{
return input as int?;
}
public static int? CastToNullableInt<T>(T input)
{
return (int?)((object)input);
}
public static T CastFromNullableInt<T>(int? input)
{
return (T)((object)input);
}
}

145
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.cs

@ -38,6 +38,73 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -38,6 +38,73 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
}
public class MyArray<T>
{
public class NestedClass<Y>
{
public T Item1;
public Y Item2;
}
public enum NestedEnum
{
A,
B
}
private T[] arr;
public MyArray(int capacity)
{
arr = new T[capacity];
}
public void Size(int capacity)
{
Array.Resize(ref arr, capacity);
}
public void Grow(int capacity)
{
if (capacity >= arr.Length) {
Size(capacity);
}
}
}
public interface IInterface
{
void Method1<T>() where T : class;
void Method2<T>() where T : class;
}
public abstract class Base : IInterface
{
// constraints must be repeated on implicit interface implementation
public abstract void Method1<T>() where T : class;
// constraints must not be specified on explicit interface implementation
void IInterface.Method2<T>()
{
}
}
public class Derived : Base
{
// constraints are inherited automatically and must not be specified
public override void Method1<T>()
{
}
}
private const MyArray<string>.NestedEnum enumVal = MyArray<string>.NestedEnum.A;
private static Type type1 = typeof(List<>);
private static Type type2 = typeof(MyArray<>);
private static Type type3 = typeof(List<>.Enumerator);
private static Type type4 = typeof(MyArray<>.NestedClass<>);
private static Type type5 = typeof(List<int>[]);
private static Type type6 = typeof(MyArray<>.NestedEnum);
public T CastToTypeParameter<T>(DerivedClass d) where T : BaseClass
{
return (T)(BaseClass)d;
@ -111,5 +178,83 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -111,5 +178,83 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
typeof(List<>.Enumerator)
};
}
public static void MethodWithConstraint<T, S>() where T : class, S where S : ICloneable, new()
{
}
public static void MethodWithStructConstraint<T>() where T : struct
{
}
private static void MultidimensionalArray<T>(T[,] array)
{
array[0, 0] = array[0, 1];
}
public static Dictionary<string, string>.KeyCollection.Enumerator GetEnumerator(Dictionary<string, string> d, MyArray<string>.NestedClass<int> nc)
{
// Tests references to inner classes in generic classes
return d.Keys.GetEnumerator();
}
#if false
public static bool IsString<T>(T input)
{
return input is string;
}
#endif
public static string AsString<T>(T input)
{
return input as string;
}
public static string CastToString<T>(T input)
{
return (string)(object)input;
}
public static T CastFromString<T>(string input)
{
return (T)(object)input;
}
#if false
public static bool IsInt<T>(T input)
{
return input is int;
}
#endif
public static int CastToInt<T>(T input)
{
return (int)(object)input;
}
public static T CastFromInt<T>(int input)
{
return (T)(object)input;
}
#if false
public static bool IsNullableInt<T>(T input)
{
return input is int?;
}
#endif
public static int? AsNullableInt<T>(T input)
{
return input as int?;
}
public static int? CastToNullableInt<T>(T input)
{
return (int?)(object)input;
}
public static T CastFromNullableInt<T>(int? input)
{
return (T)(object)input;
}
}
}

376
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.il

@ -89,6 +89,171 @@ @@ -89,6 +89,171 @@
} // end of class DerivedClass
.class auto ansi nested public beforefieldinit MyArray`1<T>
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit NestedClass`1<T,Y>
extends [mscorlib]System.Object
{
.field public !T Item1
.field public !Y Item2
.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 NestedClass`1::.ctor
} // end of class NestedClass`1
.class auto ansi sealed nested public NestedEnum<T>
extends [mscorlib]System.Enum
{
.field public specialname rtspecialname int32 value__
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> A = int32(0x00000000)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> B = int32(0x00000001)
} // end of class NestedEnum
.field private !T[] arr
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 capacity) cil managed
{
// Code size 22 (0x16)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: nop
IL_0008: ldarg.0
IL_0009: ldarg.1
IL_000a: newarr !T
IL_000f: stfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0014: nop
IL_0015: ret
} // end of method MyArray`1::.ctor
.method public hidebysig instance void
Size(int32 capacity) cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldflda !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0007: ldarg.1
IL_0008: call void [mscorlib]System.Array::Resize<!T>(!!0[]&,
int32)
IL_000d: nop
IL_000e: ret
} // end of method MyArray`1::Size
.method public hidebysig instance void
Grow(int32 capacity) cil managed
{
// Code size 27 (0x1b)
.maxstack 2
.locals init (bool V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.0
IL_0003: ldfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0008: ldlen
IL_0009: conv.i4
IL_000a: clt
IL_000c: stloc.0
IL_000d: ldloc.0
IL_000e: brtrue.s IL_001a
IL_0010: nop
IL_0011: ldarg.0
IL_0012: ldarg.1
IL_0013: call instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::Size(int32)
IL_0018: nop
IL_0019: nop
IL_001a: ret
} // end of method MyArray`1::Grow
} // end of class MyArray`1
.class interface abstract auto ansi nested public IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method IInterface::Method1
.method public hidebysig newslot abstract virtual
instance void Method2<class T>() cil managed
{
} // end of method IInterface::Method2
} // end of class IInterface
.class abstract auto ansi nested public beforefieldinit Base
extends [mscorlib]System.Object
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method Base::Method1
.method private hidebysig newslot virtual final
instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2<class T>() cil managed
{
.override ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface::Method2
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Base::ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2
.method family 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 Base::.ctor
} // end of class Base
.class auto ansi nested public beforefieldinit Derived
extends ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base
{
.method public hidebysig virtual instance void
Method1<class T>() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Derived::Method1
.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 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base::.ctor()
IL_0006: ret
} // end of method Derived::.ctor
} // end of class Derived
.field private static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<string> enumVal = int32(0x00000000)
.field private static class [mscorlib]System.Type type1
.field private static class [mscorlib]System.Type type2
.field private static class [mscorlib]System.Type type3
.field private static class [mscorlib]System.Type type4
.field private static class [mscorlib]System.Type type5
.field private static class [mscorlib]System.Type type6
.method public hidebysig instance !!T CastToTypeParameter<(ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/BaseClass) T>(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/DerivedClass d) cil managed
{
// Code size 12 (0xc)
@ -363,6 +528,191 @@ @@ -363,6 +528,191 @@
IL_0075: ret
} // end of method Generics::TestTypeOf
.method public hidebysig static void MethodWithConstraint<class (!!S) T,.ctor ([mscorlib]System.ICloneable) S>() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Generics::MethodWithConstraint
.method public hidebysig static void MethodWithStructConstraint<valuetype .ctor ([mscorlib]System.ValueType) T>() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Generics::MethodWithStructConstraint
.method private hidebysig static void MultidimensionalArray<T>(!!T[0...,0...] 'array') cil managed
{
// Code size 18 (0x12)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.0
IL_0003: ldc.i4.0
IL_0004: ldarg.0
IL_0005: ldc.i4.0
IL_0006: ldc.i4.1
IL_0007: call instance !!T !!T[0...,0...]::Get(int32,
int32)
IL_000c: call instance void !!T[0...,0...]::Set(int32,
int32,
!!T)
IL_0011: ret
} // end of method Generics::MultidimensionalArray
.method public hidebysig static valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<string,string>
GetEnumerator(class [mscorlib]System.Collections.Generic.Dictionary`2<string,string> d,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1<string,int32> nc) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<string,string> V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: callvirt instance class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2<string,string>::get_Keys()
IL_0007: callvirt instance valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<string,string>::GetEnumerator()
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::GetEnumerator
.method public hidebysig static string
AsString<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: isinst [mscorlib]System.String
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::AsString
.method public hidebysig static string
CastToString<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: castclass [mscorlib]System.String
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastToString
.method public hidebysig static !!T CastFromString<T>(string input) cil managed
{
// Code size 12 (0xc)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: unbox.any !!T
IL_0007: stloc.0
IL_0008: br.s IL_000a
IL_000a: ldloc.0
IL_000b: ret
} // end of method Generics::CastFromString
.method public hidebysig static int32 CastToInt<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: unbox.any [mscorlib]System.Int32
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastToInt
.method public hidebysig static !!T CastFromInt<T>(int32 input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box [mscorlib]System.Int32
IL_0007: unbox.any !!T
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastFromInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
AsNullableInt<T>(!!T input) cil managed
{
// Code size 22 (0x16)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: isinst valuetype [mscorlib]System.Nullable`1<int32>
IL_000c: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_0011: stloc.0
IL_0012: br.s IL_0014
IL_0014: ldloc.0
IL_0015: ret
} // end of method Generics::AsNullableInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
CastToNullableInt<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastToNullableInt
.method public hidebysig static !!T CastFromNullableInt<T>(valuetype [mscorlib]System.Nullable`1<int32> input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box valuetype [mscorlib]System.Nullable`1<int32>
IL_0007: unbox.any !!T
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastFromNullableInt
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -373,6 +723,32 @@ @@ -373,6 +723,32 @@
IL_0006: ret
} // end of method Generics::.ctor
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 91 (0x5b)
.maxstack 1
IL_0000: ldtoken [mscorlib]System.Collections.Generic.List`1
IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_000a: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type1
IL_000f: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1
IL_0014: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0019: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type2
IL_001e: ldtoken [mscorlib]System.Collections.Generic.List`1/Enumerator
IL_0023: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0028: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type3
IL_002d: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1
IL_0032: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0037: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type4
IL_003c: ldtoken class [mscorlib]System.Collections.Generic.List`1<int32>[]
IL_0041: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0046: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type5
IL_004b: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum
IL_0050: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0055: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type6
IL_005a: ret
} // end of method Generics::.cctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics

304
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.opt.il

@ -88,6 +88,156 @@ @@ -88,6 +88,156 @@
} // end of class DerivedClass
.class auto ansi nested public beforefieldinit MyArray`1<T>
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit NestedClass`1<T,Y>
extends [mscorlib]System.Object
{
.field public !T Item1
.field public !Y Item2
.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 NestedClass`1::.ctor
} // end of class NestedClass`1
.class auto ansi sealed nested public NestedEnum<T>
extends [mscorlib]System.Enum
{
.field public specialname rtspecialname int32 value__
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> A = int32(0x00000000)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> B = int32(0x00000001)
} // end of class NestedEnum
.field private !T[] arr
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 capacity) cil managed
{
// Code size 19 (0x13)
.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: newarr !T
IL_000d: stfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0012: ret
} // end of method MyArray`1::.ctor
.method public hidebysig instance void
Size(int32 capacity) cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldflda !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0006: ldarg.1
IL_0007: call void [mscorlib]System.Array::Resize<!T>(!!0[]&,
int32)
IL_000c: ret
} // end of method MyArray`1::Size
.method public hidebysig instance void
Grow(int32 capacity) cil managed
{
// Code size 19 (0x13)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.0
IL_0002: ldfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0007: ldlen
IL_0008: conv.i4
IL_0009: blt.s IL_0012
IL_000b: ldarg.0
IL_000c: ldarg.1
IL_000d: call instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::Size(int32)
IL_0012: ret
} // end of method MyArray`1::Grow
} // end of class MyArray`1
.class interface abstract auto ansi nested public IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method IInterface::Method1
.method public hidebysig newslot abstract virtual
instance void Method2<class T>() cil managed
{
} // end of method IInterface::Method2
} // end of class IInterface
.class abstract auto ansi nested public beforefieldinit Base
extends [mscorlib]System.Object
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method Base::Method1
.method private hidebysig newslot virtual final
instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2<class T>() cil managed
{
.override ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface::Method2
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Base::ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2
.method family 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 Base::.ctor
} // end of class Base
.class auto ansi nested public beforefieldinit Derived
extends ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base
{
.method public hidebysig virtual instance void
Method1<class T>() cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Derived::Method1
.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 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base::.ctor()
IL_0006: ret
} // end of method Derived::.ctor
} // end of class Derived
.field private static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<string> enumVal = int32(0x00000000)
.field private static class [mscorlib]System.Type type1
.field private static class [mscorlib]System.Type type2
.field private static class [mscorlib]System.Type type3
.field private static class [mscorlib]System.Type type4
.field private static class [mscorlib]System.Type type5
.field private static class [mscorlib]System.Type type6
.method public hidebysig instance !!T CastToTypeParameter<(ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/BaseClass) T>(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/DerivedClass d) cil managed
{
// Code size 7 (0x7)
@ -284,6 +434,134 @@ @@ -284,6 +434,134 @@
IL_0070: ret
} // end of method Generics::TestTypeOf
.method public hidebysig static void MethodWithConstraint<class (!!S) T,.ctor ([mscorlib]System.ICloneable) S>() cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Generics::MethodWithConstraint
.method public hidebysig static void MethodWithStructConstraint<valuetype .ctor ([mscorlib]System.ValueType) T>() cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Generics::MethodWithStructConstraint
.method private hidebysig static void MultidimensionalArray<T>(!!T[0...,0...] 'array') cil managed
{
// Code size 17 (0x11)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldc.i4.0
IL_0002: ldc.i4.0
IL_0003: ldarg.0
IL_0004: ldc.i4.0
IL_0005: ldc.i4.1
IL_0006: call instance !!T !!T[0...,0...]::Get(int32,
int32)
IL_000b: call instance void !!T[0...,0...]::Set(int32,
int32,
!!T)
IL_0010: ret
} // end of method Generics::MultidimensionalArray
.method public hidebysig static valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<string,string>
GetEnumerator(class [mscorlib]System.Collections.Generic.Dictionary`2<string,string> d,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1<string,int32> nc) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: callvirt instance class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2<string,string>::get_Keys()
IL_0006: callvirt instance valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<string,string>::GetEnumerator()
IL_000b: ret
} // end of method Generics::GetEnumerator
.method public hidebysig static string
AsString<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: isinst [mscorlib]System.String
IL_000b: ret
} // end of method Generics::AsString
.method public hidebysig static string
CastToString<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: castclass [mscorlib]System.String
IL_000b: ret
} // end of method Generics::CastToString
.method public hidebysig static !!T CastFromString<T>(string input) cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: unbox.any !!T
IL_0006: ret
} // end of method Generics::CastFromString
.method public hidebysig static int32 CastToInt<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: unbox.any [mscorlib]System.Int32
IL_000b: ret
} // end of method Generics::CastToInt
.method public hidebysig static !!T CastFromInt<T>(int32 input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box [mscorlib]System.Int32
IL_0006: unbox.any !!T
IL_000b: ret
} // end of method Generics::CastFromInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
AsNullableInt<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: isinst valuetype [mscorlib]System.Nullable`1<int32>
IL_000b: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_0010: ret
} // end of method Generics::AsNullableInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
CastToNullableInt<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_000b: ret
} // end of method Generics::CastToNullableInt
.method public hidebysig static !!T CastFromNullableInt<T>(valuetype [mscorlib]System.Nullable`1<int32> input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box valuetype [mscorlib]System.Nullable`1<int32>
IL_0006: unbox.any !!T
IL_000b: ret
} // end of method Generics::CastFromNullableInt
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -294,6 +572,32 @@ @@ -294,6 +572,32 @@
IL_0006: ret
} // end of method Generics::.ctor
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 91 (0x5b)
.maxstack 1
IL_0000: ldtoken [mscorlib]System.Collections.Generic.List`1
IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_000a: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type1
IL_000f: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1
IL_0014: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0019: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type2
IL_001e: ldtoken [mscorlib]System.Collections.Generic.List`1/Enumerator
IL_0023: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0028: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type3
IL_002d: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1
IL_0032: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0037: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type4
IL_003c: ldtoken class [mscorlib]System.Collections.Generic.List`1<int32>[]
IL_0041: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0046: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type5
IL_004b: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum
IL_0050: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0055: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type6
IL_005a: ret
} // end of method Generics::.cctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics

304
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.opt.roslyn.il

@ -92,6 +92,156 @@ @@ -92,6 +92,156 @@
} // end of class DerivedClass
.class auto ansi nested public beforefieldinit MyArray`1<T>
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit NestedClass`1<T,Y>
extends [mscorlib]System.Object
{
.field public !T Item1
.field public !Y Item2
.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 NestedClass`1::.ctor
} // end of class NestedClass`1
.class auto ansi sealed nested public NestedEnum<T>
extends [mscorlib]System.Enum
{
.field public specialname rtspecialname int32 value__
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> A = int32(0x00000000)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> B = int32(0x00000001)
} // end of class NestedEnum
.field private !T[] arr
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 capacity) cil managed
{
// Code size 19 (0x13)
.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: newarr !T
IL_000d: stfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0012: ret
} // end of method MyArray`1::.ctor
.method public hidebysig instance void
Size(int32 capacity) cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldflda !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0006: ldarg.1
IL_0007: call void [mscorlib]System.Array::Resize<!T>(!!0[]&,
int32)
IL_000c: ret
} // end of method MyArray`1::Size
.method public hidebysig instance void
Grow(int32 capacity) cil managed
{
// Code size 19 (0x13)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.0
IL_0002: ldfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0007: ldlen
IL_0008: conv.i4
IL_0009: blt.s IL_0012
IL_000b: ldarg.0
IL_000c: ldarg.1
IL_000d: call instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::Size(int32)
IL_0012: ret
} // end of method MyArray`1::Grow
} // end of class MyArray`1
.class interface abstract auto ansi nested public IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method IInterface::Method1
.method public hidebysig newslot abstract virtual
instance void Method2<class T>() cil managed
{
} // end of method IInterface::Method2
} // end of class IInterface
.class abstract auto ansi nested public beforefieldinit Base
extends [mscorlib]System.Object
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method Base::Method1
.method private hidebysig newslot virtual final
instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2<class T>() cil managed
{
.override ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface::Method2
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Base::ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2
.method family 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 Base::.ctor
} // end of class Base
.class auto ansi nested public beforefieldinit Derived
extends ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base
{
.method public hidebysig virtual instance void
Method1<class T>() cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Derived::Method1
.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 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base::.ctor()
IL_0006: ret
} // end of method Derived::.ctor
} // end of class Derived
.field private static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<string> enumVal = int32(0x00000000)
.field private static class [mscorlib]System.Type type1
.field private static class [mscorlib]System.Type type2
.field private static class [mscorlib]System.Type type3
.field private static class [mscorlib]System.Type type4
.field private static class [mscorlib]System.Type type5
.field private static class [mscorlib]System.Type type6
.method public hidebysig instance !!T CastToTypeParameter<(ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/BaseClass) T>(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/DerivedClass d) cil managed
{
// Code size 7 (0x7)
@ -272,6 +422,134 @@ @@ -272,6 +422,134 @@
IL_006e: ret
} // end of method Generics::TestTypeOf
.method public hidebysig static void MethodWithConstraint<class (!!S) T,.ctor ([mscorlib]System.ICloneable) S>() cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Generics::MethodWithConstraint
.method public hidebysig static void MethodWithStructConstraint<valuetype .ctor ([mscorlib]System.ValueType) T>() cil managed
{
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method Generics::MethodWithStructConstraint
.method private hidebysig static void MultidimensionalArray<T>(!!T[0...,0...] 'array') cil managed
{
// Code size 17 (0x11)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldc.i4.0
IL_0002: ldc.i4.0
IL_0003: ldarg.0
IL_0004: ldc.i4.0
IL_0005: ldc.i4.1
IL_0006: call instance !!T !!T[0...,0...]::Get(int32,
int32)
IL_000b: call instance void !!T[0...,0...]::Set(int32,
int32,
!!T)
IL_0010: ret
} // end of method Generics::MultidimensionalArray
.method public hidebysig static valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<string,string>
GetEnumerator(class [mscorlib]System.Collections.Generic.Dictionary`2<string,string> d,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1<string,int32> nc) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: callvirt instance class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2<string,string>::get_Keys()
IL_0006: callvirt instance valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<string,string>::GetEnumerator()
IL_000b: ret
} // end of method Generics::GetEnumerator
.method public hidebysig static string
AsString<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: isinst [mscorlib]System.String
IL_000b: ret
} // end of method Generics::AsString
.method public hidebysig static string
CastToString<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: castclass [mscorlib]System.String
IL_000b: ret
} // end of method Generics::CastToString
.method public hidebysig static !!T CastFromString<T>(string input) cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: unbox.any !!T
IL_0006: ret
} // end of method Generics::CastFromString
.method public hidebysig static int32 CastToInt<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: unbox.any [mscorlib]System.Int32
IL_000b: ret
} // end of method Generics::CastToInt
.method public hidebysig static !!T CastFromInt<T>(int32 input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box [mscorlib]System.Int32
IL_0006: unbox.any !!T
IL_000b: ret
} // end of method Generics::CastFromInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
AsNullableInt<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: isinst valuetype [mscorlib]System.Nullable`1<int32>
IL_000b: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_0010: ret
} // end of method Generics::AsNullableInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
CastToNullableInt<T>(!!T input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box !!T
IL_0006: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_000b: ret
} // end of method Generics::CastToNullableInt
.method public hidebysig static !!T CastFromNullableInt<T>(valuetype [mscorlib]System.Nullable`1<int32> input) cil managed
{
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
IL_0001: box valuetype [mscorlib]System.Nullable`1<int32>
IL_0006: unbox.any !!T
IL_000b: ret
} // end of method Generics::CastFromNullableInt
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -282,6 +560,32 @@ @@ -282,6 +560,32 @@
IL_0006: ret
} // end of method Generics::.ctor
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 91 (0x5b)
.maxstack 1
IL_0000: ldtoken [mscorlib]System.Collections.Generic.List`1
IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_000a: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type1
IL_000f: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1
IL_0014: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0019: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type2
IL_001e: ldtoken [mscorlib]System.Collections.Generic.List`1/Enumerator
IL_0023: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0028: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type3
IL_002d: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1
IL_0032: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0037: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type4
IL_003c: ldtoken class [mscorlib]System.Collections.Generic.List`1<int32>[]
IL_0041: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0046: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type5
IL_004b: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum
IL_0050: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0055: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type6
IL_005a: ret
} // end of method Generics::.cctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics

380
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.roslyn.il

@ -96,6 +96,175 @@ @@ -96,6 +96,175 @@
} // end of class DerivedClass
.class auto ansi nested public beforefieldinit MyArray`1<T>
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit NestedClass`1<T,Y>
extends [mscorlib]System.Object
{
.field public !T Item1
.field public !Y Item2
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method NestedClass`1::.ctor
} // end of class NestedClass`1
.class auto ansi sealed nested public NestedEnum<T>
extends [mscorlib]System.Enum
{
.field public specialname rtspecialname int32 value__
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> A = int32(0x00000000)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<!T> B = int32(0x00000001)
} // end of class NestedEnum
.field private !T[] arr
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 capacity) cil managed
{
// Code size 21 (0x15)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: nop
IL_0008: ldarg.0
IL_0009: ldarg.1
IL_000a: newarr !T
IL_000f: stfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0014: ret
} // end of method MyArray`1::.ctor
.method public hidebysig instance void
Size(int32 capacity) cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldflda !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0007: ldarg.1
IL_0008: call void [mscorlib]System.Array::Resize<!T>(!!0[]&,
int32)
IL_000d: nop
IL_000e: ret
} // end of method MyArray`1::Size
.method public hidebysig instance void
Grow(int32 capacity) cil managed
{
// Code size 30 (0x1e)
.maxstack 2
.locals init (bool V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.0
IL_0003: ldfld !0[] class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::arr
IL_0008: ldlen
IL_0009: conv.i4
IL_000a: clt
IL_000c: ldc.i4.0
IL_000d: ceq
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: brfalse.s IL_001d
IL_0013: nop
IL_0014: ldarg.0
IL_0015: ldarg.1
IL_0016: call instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1<!T>::Size(int32)
IL_001b: nop
IL_001c: nop
IL_001d: ret
} // end of method MyArray`1::Grow
} // end of class MyArray`1
.class interface abstract auto ansi nested public IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method IInterface::Method1
.method public hidebysig newslot abstract virtual
instance void Method2<class T>() cil managed
{
} // end of method IInterface::Method2
} // end of class IInterface
.class abstract auto ansi nested public beforefieldinit Base
extends [mscorlib]System.Object
implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface
{
.method public hidebysig newslot abstract virtual
instance void Method1<class T>() cil managed
{
} // end of method Base::Method1
.method private hidebysig newslot virtual final
instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2<class T>() cil managed
{
.override ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/IInterface::Method2
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Base::ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics.IInterface.Method2
.method family hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Base::.ctor
} // end of class Base
.class auto ansi nested public beforefieldinit Derived
extends ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base
{
.method public hidebysig virtual instance void
Method1<class T>() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Derived::Method1
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/Base::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Derived::.ctor
} // end of class Derived
.field private static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum<string> enumVal = int32(0x00000000)
.field private static class [mscorlib]System.Type type1
.field private static class [mscorlib]System.Type type2
.field private static class [mscorlib]System.Type type3
.field private static class [mscorlib]System.Type type4
.field private static class [mscorlib]System.Type type5
.field private static class [mscorlib]System.Type type6
.method public hidebysig instance !!T CastToTypeParameter<(ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/BaseClass) T>(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/DerivedClass d) cil managed
{
// Code size 12 (0xc)
@ -354,6 +523,191 @@ @@ -354,6 +523,191 @@
IL_0073: ret
} // end of method Generics::TestTypeOf
.method public hidebysig static void MethodWithConstraint<class (!!S) T,.ctor ([mscorlib]System.ICloneable) S>() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Generics::MethodWithConstraint
.method public hidebysig static void MethodWithStructConstraint<valuetype .ctor ([mscorlib]System.ValueType) T>() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Generics::MethodWithStructConstraint
.method private hidebysig static void MultidimensionalArray<T>(!!T[0...,0...] 'array') cil managed
{
// Code size 18 (0x12)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.0
IL_0003: ldc.i4.0
IL_0004: ldarg.0
IL_0005: ldc.i4.0
IL_0006: ldc.i4.1
IL_0007: call instance !!T !!T[0...,0...]::Get(int32,
int32)
IL_000c: call instance void !!T[0...,0...]::Set(int32,
int32,
!!T)
IL_0011: ret
} // end of method Generics::MultidimensionalArray
.method public hidebysig static valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<string,string>
GetEnumerator(class [mscorlib]System.Collections.Generic.Dictionary`2<string,string> d,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1<string,int32> nc) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<string,string> V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: callvirt instance class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2<string,string>::get_Keys()
IL_0007: callvirt instance valuetype [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection/Enumerator<!0,!1> class [mscorlib]System.Collections.Generic.Dictionary`2/KeyCollection<string,string>::GetEnumerator()
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::GetEnumerator
.method public hidebysig static string
AsString<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: isinst [mscorlib]System.String
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::AsString
.method public hidebysig static string
CastToString<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: castclass [mscorlib]System.String
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastToString
.method public hidebysig static !!T CastFromString<T>(string input) cil managed
{
// Code size 12 (0xc)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: unbox.any !!T
IL_0007: stloc.0
IL_0008: br.s IL_000a
IL_000a: ldloc.0
IL_000b: ret
} // end of method Generics::CastFromString
.method public hidebysig static int32 CastToInt<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: unbox.any [mscorlib]System.Int32
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastToInt
.method public hidebysig static !!T CastFromInt<T>(int32 input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box [mscorlib]System.Int32
IL_0007: unbox.any !!T
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastFromInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
AsNullableInt<T>(!!T input) cil managed
{
// Code size 22 (0x16)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: isinst valuetype [mscorlib]System.Nullable`1<int32>
IL_000c: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_0011: stloc.0
IL_0012: br.s IL_0014
IL_0014: ldloc.0
IL_0015: ret
} // end of method Generics::AsNullableInt
.method public hidebysig static valuetype [mscorlib]System.Nullable`1<int32>
CastToNullableInt<T>(!!T input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: unbox.any valuetype [mscorlib]System.Nullable`1<int32>
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastToNullableInt
.method public hidebysig static !!T CastFromNullableInt<T>(valuetype [mscorlib]System.Nullable`1<int32> input) cil managed
{
// Code size 17 (0x11)
.maxstack 1
.locals init (!!T V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box valuetype [mscorlib]System.Nullable`1<int32>
IL_0007: unbox.any !!T
IL_000c: stloc.0
IL_000d: br.s IL_000f
IL_000f: ldloc.0
IL_0010: ret
} // end of method Generics::CastFromNullableInt
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -365,6 +719,32 @@ @@ -365,6 +719,32 @@
IL_0007: ret
} // end of method Generics::.ctor
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 91 (0x5b)
.maxstack 1
IL_0000: ldtoken [mscorlib]System.Collections.Generic.List`1
IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_000a: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type1
IL_000f: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1
IL_0014: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0019: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type2
IL_001e: ldtoken [mscorlib]System.Collections.Generic.List`1/Enumerator
IL_0023: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0028: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type3
IL_002d: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedClass`1
IL_0032: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0037: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type4
IL_003c: ldtoken class [mscorlib]System.Collections.Generic.List`1<int32>[]
IL_0041: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0046: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type5
IL_004b: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics/MyArray`1/NestedEnum
IL_0050: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0055: stsfld class [mscorlib]System.Type ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics::type6
IL_005a: ret
} // end of method Generics::.cctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Generics

Loading…
Cancel
Save