Beispiel #1
0
    public bool TestListInstType() {
      ITypeDefinition testType = Helper.GetNamespaceType(this.ModuleReaderTest.TestAssembly.UnitNamespaceRoot, this.TypeTest);
      IFieldDefinition fld = Helper.GetFieldNamed(testType, this.IntList);
      ITypeDefinition type = fld.Type.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.ILAsmAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi serializable beforefieldinit[mscorlib]System.Collections.Generic.List`1<int32>
  extends [mscorlib]System.Object
  implements [mscorlib]System.Collections.Generic.IList`1<int32>,
             [mscorlib]System.Collections.Generic.ICollection`1<int32>,
             [mscorlib]System.Collections.Generic.IEnumerable`1<int32>,
             [mscorlib]System.Collections.IList,
             [mscorlib]System.Collections.ICollection,
             [mscorlib]System.Collections.IEnumerable
{
  .custom instance void[mscorlib]System.Diagnostics.DebuggerDisplayAttribute::.ctor([mscorlib]System.String)
  {
    .argument const(""Count = {Count}"",[mscorlib]System.String)
  }
  .custom instance void[mscorlib]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor([mscorlib]System.Type)
  {
    .argument typeof([mscorlib]System.Collections.Generic.Mscorlib_CollectionDebugView`1)
  }
  .custom instance void[mscorlib]System.Reflection.DefaultMemberAttribute::.ctor([mscorlib]System.String)
  {
    .argument const(""Item"",[mscorlib]System.String)
  }
  .class Enumerator
  .field _defaultCapacity : int32
  .field _emptyArray : int32[]
  .field _items : int32[]
  .field _size : int32
  .field _syncRoot : [mscorlib]System.Object
  .field _version : int32
  .method .cctor : void()
  .method .ctor : void()
  .method .ctor : void([mscorlib]System.Collections.Generic.IEnumerable`1<int32>)
  .method .ctor : void(int32)
  .method Add : void(int32)
  .method AddRange : void([mscorlib]System.Collections.Generic.IEnumerable`1<int32>)
  .method AsReadOnly : [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1<int32>()
  .method BinarySearch : int32(int32)
  .method BinarySearch : int32(int32,[mscorlib]System.Collections.Generic.IComparer`1<int32>)
  .method BinarySearch : int32(int32,int32,int32,[mscorlib]System.Collections.Generic.IComparer`1<int32>)
  .method Clear : void()
  .method Contains : bool(int32)
  .method ConvertAll : [mscorlib]System.Collections.Generic.List`1<!!0>([mscorlib]System.Converter`2<int32,!!0>)
  .method CopyTo : void(int32,int32[],int32,int32)
  .method CopyTo : void(int32[])
  .method CopyTo : void(int32[],int32)
  .method EnsureCapacity : void(int32)
  .method Exists : bool([mscorlib]System.Predicate`1<int32>)
  .method Find : int32([mscorlib]System.Predicate`1<int32>)
  .method FindAll : [mscorlib]System.Collections.Generic.List`1<int32>([mscorlib]System.Predicate`1<int32>)
  .method FindIndex : int32([mscorlib]System.Predicate`1<int32>)
  .method FindIndex : int32(int32,[mscorlib]System.Predicate`1<int32>)
  .method FindIndex : int32(int32,int32,[mscorlib]System.Predicate`1<int32>)
  .method FindLast : int32([mscorlib]System.Predicate`1<int32>)
  .method FindLastIndex : int32([mscorlib]System.Predicate`1<int32>)
  .method FindLastIndex : int32(int32,[mscorlib]System.Predicate`1<int32>)
  .method FindLastIndex : int32(int32,int32,[mscorlib]System.Predicate`1<int32>)
  .method ForEach : void([mscorlib]System.Action`1<int32>)
  .method get_Capacity : int32()
  .method get_Count : int32()
  .method get_Item : int32(int32)
  .method GetEnumerator : [mscorlib]System.Collections.Generic.List`1<int32>/Enumerator()
  .method GetRange : [mscorlib]System.Collections.Generic.List`1<int32>(int32,int32)
  .method IndexOf : int32(int32)
  .method IndexOf : int32(int32,int32)
  .method IndexOf : int32(int32,int32,int32)
  .method Insert : void(int32,int32)
  .method InsertRange : void(int32,[mscorlib]System.Collections.Generic.IEnumerable`1<int32>)
  .method IsCompatibleObject : bool([mscorlib]System.Object)
  .method LastIndexOf : int32(int32)
  .method LastIndexOf : int32(int32,int32)
  .method LastIndexOf : int32(int32,int32,int32)
  .method Remove : bool(int32)
  .method RemoveAll : int32([mscorlib]System.Predicate`1<int32>)
  .method RemoveAt : void(int32)
  .method RemoveRange : void(int32,int32)
  .method Reverse : void()
  .method Reverse : void(int32,int32)
  .method set_Capacity : void(int32)
  .method set_Item : void(int32,int32)
  .method Sort : void()
  .method Sort : void([mscorlib]System.Collections.Generic.IComparer`1<int32>)
  .method Sort : void([mscorlib]System.Comparison`1<int32>)
  .method Sort : void(int32,int32,[mscorlib]System.Collections.Generic.IComparer`1<int32>)
  .method System.Collections.Generic.ICollection<T>.get_IsReadOnly : bool()
  .method System.Collections.Generic.IEnumerable<T>.GetEnumerator : [mscorlib]System.Collections.Generic.IEnumerator`1<int32>()
  .method System.Collections.ICollection.CopyTo : void([mscorlib]System.Array,int32)
  .method System.Collections.ICollection.get_IsSynchronized : bool()
  .method System.Collections.ICollection.get_SyncRoot : [mscorlib]System.Object()
  .method System.Collections.IEnumerable.GetEnumerator : [mscorlib]System.Collections.IEnumerator()
  .method System.Collections.IList.Add : int32([mscorlib]System.Object)
  .method System.Collections.IList.Contains : bool([mscorlib]System.Object)
  .method System.Collections.IList.get_IsFixedSize : bool()
  .method System.Collections.IList.get_IsReadOnly : bool()
  .method System.Collections.IList.get_Item : [mscorlib]System.Object(int32)
  .method System.Collections.IList.IndexOf : int32([mscorlib]System.Object)
  .method System.Collections.IList.Insert : void(int32,[mscorlib]System.Object)
  .method System.Collections.IList.Remove : void([mscorlib]System.Object)
  .method System.Collections.IList.set_Item : void(int32,[mscorlib]System.Object)
  .method ToArray : int32[]()
  .method TrimExcess : void()
  .method TrueForAll : bool([mscorlib]System.Predicate`1<int32>)
  .method VerifyValueType : void([mscorlib]System.Object)
  .property Capacity : int32()
  .property Count : int32()
  .property Item : int32(int32)
  .property System.Collections.Generic.ICollection<T>.IsReadOnly : bool()
  .property System.Collections.ICollection.IsSynchronized : bool()
  .property System.Collections.ICollection.SyncRoot : [mscorlib]System.Object()
  .property System.Collections.IList.IsFixedSize : bool()
  .property System.Collections.IList.IsReadOnly : bool()
  .property System.Collections.IList.Item : [mscorlib]System.Object(int32)
  .flags class reftype
  .pack 0
  .size 0
  .override instance bool[mscorlib]System.Collections.IList::Contains([mscorlib]System.Object) with instance bool[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.Contains([mscorlib]System.Object)
  .override instance bool[mscorlib]System.Collections.Generic.ICollection`1<int32>::get_IsReadOnly() with instance bool[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.Generic.ICollection<T>.get_IsReadOnly()
  .override instance bool[mscorlib]System.Collections.IList::get_IsReadOnly() with instance bool[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.get_IsReadOnly()
  .override instance bool[mscorlib]System.Collections.ICollection::get_IsSynchronized() with instance bool[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.ICollection.get_IsSynchronized()
  .override instance[mscorlib]System.Object[mscorlib]System.Collections.ICollection::get_SyncRoot() with instance[mscorlib]System.Object[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.ICollection.get_SyncRoot()
  .override instance[mscorlib]System.Object[mscorlib]System.Collections.IList::get_Item(int32) with instance[mscorlib]System.Object[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.get_Item(int32)
  .override instance void[mscorlib]System.Collections.IList::set_Item(int32,[mscorlib]System.Object) with instance void[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.set_Item(int32,[mscorlib]System.Object)
  .override instance int32[mscorlib]System.Collections.IList::Add([mscorlib]System.Object) with instance int32[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.Add([mscorlib]System.Object)
  .override instance bool[mscorlib]System.Collections.IList::get_IsFixedSize() with instance bool[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.get_IsFixedSize()
  .override instance void[mscorlib]System.Collections.ICollection::CopyTo([mscorlib]System.Array,int32) with instance void[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.ICollection.CopyTo([mscorlib]System.Array,int32)
  .override instance[mscorlib]System.Collections.Generic.IEnumerator`1<int32>[mscorlib]System.Collections.Generic.IEnumerable`1<int32>::GetEnumerator() with instance[mscorlib]System.Collections.Generic.IEnumerator`1<int32>[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.Generic.IEnumerable<T>.GetEnumerator()
  .override instance[mscorlib]System.Collections.IEnumerator[mscorlib]System.Collections.IEnumerable::GetEnumerator() with instance[mscorlib]System.Collections.IEnumerator[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IEnumerable.GetEnumerator()
  .override instance int32[mscorlib]System.Collections.IList::IndexOf([mscorlib]System.Object) with instance int32[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.IndexOf([mscorlib]System.Object)
  .override instance void[mscorlib]System.Collections.IList::Insert(int32,[mscorlib]System.Object) with instance void[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.Insert(int32,[mscorlib]System.Object)
  .override instance void[mscorlib]System.Collections.IList::Remove([mscorlib]System.Object) with instance void[mscorlib]System.Collections.Generic.List`1<int32>::System.Collections.IList.Remove([mscorlib]System.Object)
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #2
0
    public bool TestGenericType() {
      ITypeDefinition type = Helper.GetNamespaceType(this.ModuleReaderTest.ILAsmAssembly.UnitNamespaceRoot, this.Generic);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.ILAsmAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class public auto ansi beforefieldinit Generic`1<T>
  extends [mscorlib]System.Object
{
  .custom instance void TestAttribute1::.ctor([mscorlib]System.Type)
  {
    .argument typeof(float32*&)
  }
  .field field1 : !0*
  .field field2 : Generic`1<[mscorlib]System.Object>
  .method GenMethod : !!0(!!0,!!0*)
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #3
0
    public bool TestGenericInstfield1Type() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.ILAsmAssembly.UnitNamespaceRoot, this.Generic);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.field2);
      ITypeDefinition type = fld.Type.ResolvedType;
      fld = Helper.GetFieldNamed(type, this.field1);
      type = fld.Type.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.ILAsmAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto autochar[mscorlib]System.Object modopt([mscorlib]System.Runtime.CompilerServices.IsConst)*
{
  .flags
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #4
0
    public bool TestGeneric4Instance() {
      ITypeDefinition type = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Generic4);
      type = type.InstanceType.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi beforefieldinit Generic4`1<!0>
  extends [mscorlib]System.Object
{
  .field field1 : !0
  .field field2 : !0[]
  .field field3 : int32*
  .field field4 : !0[,]
  .method .ctor : void()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #5
0
    public bool TestGeneric2NestedInstance() {
      ITypeDefinition type = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Generic2);
      type = Helper.GetNestedType(type, this.Nested);
      type = type.InstanceType.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi beforefieldinit Generic2`1<!0>/Nested`1<!0>
  extends [mscorlib]System.Object
  implements  IGen2`2<!0,!0>
{
  .field fieldT : !0
  .field fieldU : !0
  .method .ctor : void()
  .method get_propT : !0()
  .method get_propU : !0()
  .method Meth : !0(IGen1`1<!0>,!!0)
  .method set_propT : void(!0)
  .method set_propU : void(!0)
  .property propT : !0()
  .property propU : !0()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #6
0
    public bool TestCppFunctionBarPointer() {
      IGlobalFieldDefinition globalField = Helper.GetGlobalField(Helper.GetNamespace(this.ModuleReaderTest.CppAssembly, this.Foo), this.bar);
      ITypeDefinition type = globalField.Type.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto autochar void*(int32,float32)
{
  .flags
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #7
0
    public bool TestTypeTest() {
      ITypeDefinition type = Helper.GetNamespaceType(this.ModuleReaderTest.TestAssembly.UnitNamespaceRoot, this.TypeTest);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class public auto ansi beforefieldinit TypeTest
  extends [mscorlib]System.Object
{
  .custom instance void DAttribute::.ctor([mscorlib]System.String,int32,float64,[mscorlib]System.Type,TestEnum)
  {
    .argument const(""DDD"",[mscorlib]System.String)
    .argument const(666,int32)
    .argument const(666.666,float64)
    .argument typeof(TestEnum)
    .argument const(0,TestEnum)
    .argument .field Array : [mscorlib]System.Object[]=array([mscorlib]System.Object[]){const(null,[mscorlib]System.String), const(null,[mscorlib]System.String)}
    .argument .field IntArray : int32[]=array(int32[]){const(6,int32), const(6,int32), const(6,int32)}
  }
  .custom instance void TestAttribute::.ctor([mscorlib]System.Type)
  {
    .argument typeof(int32[,][])
  }
  .custom instance void TestAttribute::.ctor([mscorlib]System.Type)
  {
    .argument typeof(float32**)
  }
  .custom instance void TestAttribute::.ctor([mscorlib]System.Type)
  {
    .argument typeof(Faa`1<TestAttribute>/Baa`1<int32>)
  }
  .field Foo : [.module MRW_Module1.netmodule]Module1.Foo
  .field FooNested : [.module MRW_Module1.netmodule]Module1.Foo/Nested
  .field IntList : [mscorlib]System.Collections.Generic.List`1<int32>
  .method .ctor : void()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #8
0
    public bool TestCurrentExportedNestedTypeReference() {
      ITypeDefinition testType = Helper.GetNamespaceType(this.ModuleReaderTest.TestAssembly.UnitNamespaceRoot, this.TypeTest);
      IFieldDefinition fld = Helper.GetFieldNamed(testType, this.FooNested);
      if (!fld.Type.IsAlias)
        return false;
      IAliasForType alias = fld.Type.AliasForType;
      ITypeDefinition type = alias.AliasedType.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi nested public beforefieldinit[MRW_Assembly]Module1.Foo/Nested
  extends [mscorlib]System.Object
{
  .method .ctor : void()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #9
0
    public bool TestAssemblyExportedTypeReference() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Foo);
      ITypeDefinition type = fld.Type.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class public auto ansi beforefieldinit Module1.Foo
  extends [mscorlib]System.Object
{
  .class Nested
  .method .ctor : void()
  .method Bar : [.module MRW_Module1.netmodule]Module1.Foo()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #10
0
    public bool TestGeneric3FieldTypeNestedType() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic3);
      ITypeDefinition type = Helper.GetNestedType(fld.Type.ResolvedType, this.Nested);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi nested public beforefieldinit Generic3/Nested`1<U>
  extends [mscorlib]System.Object
  implements  IGen1`1<!0>
{
  .field fieldU : !0
  .method .ctor : void()
  .method get_propU : !0()
  .method set_propU : void(!0)
  .property propU : !0()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #11
0
    public bool TestGeneric2NestedFieldType() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic2Nested);
      ITypeDefinition type = fld.Type.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi beforefieldinit Generic2`1<[mscorlib]System.Object>/Nested`1<float32>
  extends [mscorlib]System.Object
  implements  IGen2`2<[mscorlib]System.Object,float32>
{
  .field fieldT : [mscorlib]System.Object
  .field fieldU : float32
  .method .ctor : void()
  .method get_propT : [mscorlib]System.Object()
  .method get_propU : float32()
  .method Meth : float32(IGen1`1<[mscorlib]System.Object>,!!0)
  .method set_propT : void([mscorlib]System.Object)
  .method set_propU : void(float32)
  .property propT : [mscorlib]System.Object()
  .property propU : float32()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }
Beispiel #12
0
    public bool TestGeneric1FieldType() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic1);
      ITypeDefinition type = fld.Type.ResolvedType;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.AssemblyAssembly);
      prettyPrinter.TypeDefinition(type);
      string result =
@".class auto ansi beforefieldinit Generic1`1<int32>
  extends [mscorlib]System.Object
  implements  IGen1`1<int32>
{
  .class Nested
  .event GenericEvent : GenericDelegate`1<int32>
  .field fieldT : int32
  .field GenericEvent : GenericDelegate`1<int32>
  .method .ctor : void()
  .method add_GenericEvent : void(GenericDelegate`1<int32>)
  .method get_propT : int32()
  .method remove_GenericEvent : void(GenericDelegate`1<int32>)
  .method set_propT : void(int32)
  .property propT : int32()
  .flags class reftype
  .pack 0
  .size 0
}
";
      return result.Equals(stringPaper.Content);
    }