public bool TestTryCatchFinallyIL() {
      ITypeDefinition type = Helper.GetNamespaceType((IUnitNamespace)this.ModuleReaderTest.TestAssembly.NamespaceRoot, this.MethodBodyTest);
      IMethodDefinition method = Helper.GetMethodNamed(type, this.TryCatchFinallyHandlerMethod);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method private hidebysig instance explicit default void TryCatchFinallyHandlerMethod()cil managed
{
  .maxstack 1
  .locals init(
    [mscorlib]System.Exception  V_0
  )
  IL_0000:  nop
  IL_0001:  nop
  IL_0002:  newobj instance void[mscorlib]System.Object::.ctor()
  IL_0007:  pop
  IL_0008:  nop
  IL_0009:  leave.s IL_001c
  IL_000b:  stloc.0
  IL_000c:  nop
  IL_000d:  ldloc.0
  IL_000e:  callvirt instance[mscorlib]System.String[mscorlib]System.Object::ToString()
  IL_0013:  call static void[mscorlib]System.Console::WriteLine([mscorlib]System.String)
  IL_0018:  nop
  IL_0019:  nop
  IL_001a:  leave.s IL_001c
  IL_001c:  nop
  IL_001d:  leave.s IL_002d
  IL_001f:  nop
  IL_0020:  ldstr ""In Finally""
  IL_0025:  call static void[mscorlib]System.Console::WriteLine([mscorlib]System.String)
  IL_002a:  nop
  IL_002b:  nop
  IL_002c:  endfinally
  IL_002d:  nop
  IL_002e:  ret
  .try IL_0001 to IL_000b catch[mscorlib]System.Exception handler IL_000b to IL_001c
  .try IL_0001 to IL_001f finally handler IL_001f to IL_002d
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestCurrentAssembly() {
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.Assembly(this.ModuleReaderTest.TestAssembly);
      string result =
@".assembly MRW_TestAssembly
{
  .custom instance void[mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32)
  {
    .argument const(8,int32)
  }
  .custom instance void[mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor()
  {
    .argument .property WrapNonExceptionThrows : bool()=const(True,bool)
  }
  .publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00   // .$..............
                00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00   // .$..RSA1........
                2B 96 12 82 73 B1 F0 B2 89 A1 53 81 A7 A1 1A BF   // +...s.....S.....
                07 40 A0 08 21 51 DE DF 0D 8C 66 0D 61 9A 97 19   // .@..!Q....f.a...
                07 08 76 E4 94 44 5A AB 22 BC B3 97 D7 B4 FF 97   // ..v..DZ."".......
                CA 80 ED 49 B3 FC 2B 87 BB 76 7B 60 CA FB F9 49   // ...I..+..v{`...I
                AA 43 5F CF 17 DE B3 19 01 BE 16 49 3C 87 DF E6   // .C_........I<...
                1D 71 F5 18 5F 06 97 A7 0A B5 E0 F1 E0 5C 70 46   // .q.._........\pF
                DB 0D 28 C1 BE 6D 83 DA 3F AC 58 16 1C 56 3C A5   // ..(..m..?.X..V<.
                9D C2 EF 9C E3 02 30 D9 37 7A A6 3D D2 76 CD BF ) // ......0.7z.=.v..
  .hash algorithm 0x00008004
  .ver 0:0:0:0
  .flags 0x00000001
  .permissionset reqmin
  {
    .custom instance void[mscorlib]System.Security.Permissions.FileIOPermissionAttribute::.ctor([mscorlib]System.Security.Permissions.SecurityAction)
    {
      .argument .property Write : [mscorlib]System.String()=const(""C:\AnotherDirectoryAltogether"",[mscorlib]System.String)
    }
  }
}
";
      return result.Equals(stringPaper.Content);
    }
示例#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);
    }
示例#4
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);
    }
示例#5
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);
    }
示例#6
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);
    }
示例#7
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);
    }
示例#8
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);
    }
    public bool TestAssemGenericMethod() {
      ITypeDefinition type = Helper.GetNamespaceType((IUnitNamespace)this.ModuleReaderTest.AssemblyAssembly.NamespaceRoot, this.Assem);
      IMethodDefinition method = Helper.GetMethodNamed(type, this.GenMethod);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method public hidebysig instance explicit default!!0 GenMethod<class T>(
  !!0  t,
  [mscorlib]System.Collections.Generic.List`1<!!0> l,
  !!0[] ta,
  !!0[,] tm,
  !!0[,] tn
)cil managed
{
  .maxstack 6
  .locals init(
    !!0  V_0
  )
  IL_0000:  nop
  IL_0001:  ldarg.0
  IL_0002:  ldnull
  IL_0003:  ldnull
  IL_0004:  ldnull
  IL_0005:  ldnull
  IL_0006:  ldnull
  IL_0007:  call instance!!0[MRW_Assembly]Assem::GenMethod<[mscorlib]System.Object>(!!0,[mscorlib]System.Collections.Generic.List`1<!!0>,!!0[],!!0[,],!!0[,])
  IL_000c:  pop
  IL_000d:  ldarg.1
  IL_000e:  stloc.0
  IL_000f:  br.s IL_0011
  IL_0011:  ldloc.0
  IL_0012:  ret
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestCreateFontIndirectArray() {
      ITypeDefinition type = Helper.GetNamespaceType((IUnitNamespace)this.ModuleReaderTest.TestAssembly.NamespaceRoot, this.MarshalTest);
      IMethodDefinition method = Helper.GetMethodNamed(type, this.CreateFontIndirectArray);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method public hidebysig static pinvokeimpl(gdi32.dll as CreateFontIndirectArray autochar winapi)explicit default native int CreateFontIndirectArray(
  [vjslib]com.ms.win32.LOGFONT[]marshal(lpstruct,0,1) lplf
)cil managed preservesig
{
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestListAddMethodInstructions() {
      ITypeDefinition type = Helper.GetNamespaceType(Helper.GetNamespace(this.ModuleReaderTest.MscorlibAssembly, this.System, this.Collections, this.Generic), this.List);
      IMethodDefinition method = Helper.GetMethodNamed(type, this.Add);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.MscorlibAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method public hidebysig newslot virtual final instance explicit default void Add(
  !0  item
)cil managed
{
  .maxstack 4
  .locals init(
    int32  V_0
  )
  IL_0000:  ldarg.0
  IL_0001:  ldfld int32 System.Collections.Generic.List`1<!0>::_size
  IL_0006:  ldarg.0
  IL_0007:  ldfld!0[]System.Collections.Generic.List`1<!0>::_items
  IL_000c:  ldlen
  IL_000d:  conv.i4
  IL_000e:  bne.un.s IL_001e
  IL_0010:  ldarg.0
  IL_0011:  ldarg.0
  IL_0012:  ldfld int32 System.Collections.Generic.List`1<!0>::_size
  IL_0017:  ldc.i4.1
  IL_0018:  add
  IL_0019:  call instance void System.Collections.Generic.List`1<!0>::EnsureCapacity(int32)
  IL_001e:  ldarg.0
  IL_001f:  ldfld!0[]System.Collections.Generic.List`1<!0>::_items
  IL_0024:  ldarg.0
  IL_0025:  dup
  IL_0026:  ldfld int32 System.Collections.Generic.List`1<!0>::_size
  IL_002b:  dup
  IL_002c:  stloc.0
  IL_002d:  ldc.i4.1
  IL_002e:  add
  IL_002f:  stfld int32 System.Collections.Generic.List`1<!0>::_size
  IL_0034:  ldloc.0
  IL_0035:  ldarg.1
  IL_0036:  stelem!0
  IL_003b:  ldarg.0
  IL_003c:  dup
  IL_003d:  ldfld int32 System.Collections.Generic.List`1<!0>::_version
  IL_0042:  ldc.i4.1
  IL_0043:  add
  IL_0044:  stfld int32 System.Collections.Generic.List`1<!0>::_version
  IL_0049:  ret
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestGeneric1Event() {
      ITypeDefinition genType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Generic1);
      IEventDefinition eventDef = Helper.GetEventNamed(genType, this.GenericEvent);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.EventDefinition(eventDef);
      string result =
@".event public[MRW_Assembly]GenericDelegate`1<!0>GenericEvent
{
  .addon instance void[MRW_Assembly]Generic1`1::add_GenericEvent([MRW_Assembly]GenericDelegate`1<!0>)
  .removeon instance void[MRW_Assembly]Generic1`1::remove_GenericEvent([MRW_Assembly]GenericDelegate`1<!0>)
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestGCClearCacheEvent() {
      ITypeDefinition type = Helper.GetNamespaceType(Helper.GetNamespace(this.ModuleReaderTest.MscorlibAssembly, this.System), this.GC);
      IEventDefinition eventDef = Helper.GetEventNamed(type, this.ClearCache);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.MscorlibAssembly);
      prettyPrinter.EventDefinition(eventDef);
      string result =
@".event assembly System.Reflection.Cache.ClearCacheHandler ClearCache
{
  .addon static void System.GC::add_ClearCache(System.Reflection.Cache.ClearCacheHandler)
  .removeon static void System.GC::remove_ClearCache(System.Reflection.Cache.ClearCacheHandler)
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestListItemProperty() {
      ITypeDefinition type = Helper.GetNamespaceType(Helper.GetNamespace(this.ModuleReaderTest.MscorlibAssembly, this.System, this.Collections, this.Generic), this.List);
      IPropertyDefinition property = Helper.GetPropertyNamed(type, this.Item);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.MscorlibAssembly);
      prettyPrinter.PropertyDefinition(property);
      string result =
@".property public instance default!0 Item(
  int32
)
{
  .get instance!0 System.Collections.Generic.List`1::get_Item(int32)
  .set instance void System.Collections.Generic.List`1::set_Item(int32,!0)
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestListDefaultCapacityField() {
      ITypeDefinition type = Helper.GetNamespaceType(Helper.GetNamespace(this.ModuleReaderTest.MscorlibAssembly, this.System, this.Collections, this.Generic), this.List);
      IFieldDefinition field = Helper.GetFieldNamed(type, this._defaultCapacity);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.MscorlibAssembly);
      prettyPrinter.FieldDefinition(field);
      string result =
@".field private static literal int32 _defaultCapacity=const(4,int32)
{
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestGenMethodType() {
      ITypeDefinition type = Helper.GetNamespaceType(this.ModuleReaderTest.ILAsmAssembly.UnitNamespaceRoot, this.Generic);
      IMethodDefinition method = Helper.GetMethodNamed(type, this.GenMethod);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.ILAsmAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method public hidebysig instance explicit default!!0 GenMethod<class T>(
  !!0  t,
  !!0 modopt([mscorlib]System.Runtime.CompilerServices.IsConst)* tp
)cil managed
{
  .maxstack 3
  .locals init(
    !!0  V_0
  )
  IL_0000:  nop
  IL_0001:  ldarg.0
  IL_0002:  ldnull
  IL_0003:  ldc.i4.0
  IL_0004:  call instance!!0 Generic`1::GenMethod<[mscorlib]System.Object>(!!0,!!0 modopt([mscorlib]System.Runtime.CompilerServices.IsConst)*)
  IL_0009:  pop
  IL_000a:  ldarg.1
  IL_000b:  stloc.0
  IL_000c:  br.s IL_000e
  IL_000e:  ldloc.0
  IL_000f:  ret
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestPhxPointerGlobalField() {
      IFieldDefinition field = Helper.GetGlobalField(Helper.GetNamespace(this.ModuleReaderTest.PhxArchMsil, this._A0x8179e609), this._InitializedPerProcess_initializer__CurrentDomain__CrtImplementationDetails_____Q2P6MXXZEA);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.CppAssembly);
      prettyPrinter.FieldDefinition(field);
      string result =
@".field assembly static void()?A0x8179e609.?InitializedPerProcess$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA at{0x00000058,0x00000004}.data=(78 00 00 06 )                                     // x...
{
}
";
      return result.Equals(stringPaper.Content);
    }
    public bool TestAssemGenericMethodCall() {
      ITypeDefinition type = Helper.GetNamespaceType((IUnitNamespace)this.ModuleReaderTest.AssemblyAssembly.NamespaceRoot, this.Assem);
      IMethodDefinition method = Helper.GetMethodNamed(type, this.GenMethod);
      IOperation op = Helper.GetOperation(method, 7);
      IMethodReference methodRef = op.Value as IMethodReference;
      if (methodRef == null)
        return false;
      IGenericMethodInstance gmi = methodRef.ResolvedMethod as IGenericMethodInstance;
      if (gmi == null)
        return false;
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.MethodDefinition(gmi);
      string result =
@".method public hidebysig instance explicit default[mscorlib]System.Object GenMethod<[mscorlib]System.Object>(
  [mscorlib]System.Object  t,
  [mscorlib]System.Collections.Generic.List`1<[mscorlib]System.Object> l,
  [mscorlib]System.Object[] ta,
  [mscorlib]System.Object[,] tm,
  [mscorlib]System.Object[,] tn
)cil managed
{
  .maxstack 6
  .locals init(
     V_0
  )
  IL_0000:  nop
  IL_0001:  ldarg.0
  IL_0002:  ldnull
  IL_0003:  ldnull
  IL_0004:  ldnull
  IL_0005:  ldnull
  IL_0006:  ldnull
  IL_0007:  call instance!!0[MRW_Assembly]Assem::GenMethod<[mscorlib]System.Object>(!!0,[mscorlib]System.Collections.Generic.List`1<!!0>,!!0[],!!0[,],!!0[,])
  IL_000c:  pop
  IL_000d:  ldarg.1
  IL_000e:  stloc.0
  IL_000f:  br.s IL_0011
  IL_0011:  ldloc.0
  IL_0012:  ret
}
";
      return result.Equals(stringPaper.Content);
    }
示例#19
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);
    }
    public bool TestGenericTypeField() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic1);
      ITypeDefinition type = fld.Type.ResolvedType;
      IFieldDefinition field = Helper.GetFieldNamed(type, this.fieldT);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.FieldDefinition(field);
      string result =
@".field public int32 fieldT
{
}
";
      return result.Equals(stringPaper.Content);
    }
示例#21
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);
    }
    public bool TestGenericTypeMethod() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic1);
      ITypeDefinition type = fld.Type.ResolvedType;
      IMethodDefinition method = Helper.GetMethodNamed(type, this.get_propT);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method public hidebysig specialname instance explicit default int32 get_propT()cil managed
{
  .maxstack 1
  .locals init(
    int32  V_0,
    int32  V_1
  )
  IL_0000:  nop
  IL_0001:  ldloca.s V_1
  IL_0003:  initobj int32
  IL_0009:  ldloc.1
  IL_000a:  stloc.0
  IL_000b:  br.s IL_000d
  IL_000d:  ldloc.0
  IL_000e:  ret
}
";
      return result.Equals(stringPaper.Content);
    }
示例#23
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);
    }
    public bool TestGenericTypeProperty() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic1);
      ITypeDefinition type = fld.Type.ResolvedType;
      IPropertyDefinition prop = Helper.GetPropertyNamed(type, this.propT);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.PropertyDefinition(prop);
      string result =
@".property public instance default int32 propT()
{
  .get instance int32[MRW_Assembly]Generic1`1<int32>::get_propT()
  .set instance void[MRW_Assembly]Generic1`1<int32>::set_propT(int32)
}
";
      return result.Equals(stringPaper.Content);
    }
示例#25
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);
    }
    public bool TestGenericTypeEvent() {
      ITypeDefinition assemType = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
      IFieldDefinition fld = Helper.GetFieldNamed(assemType, this.Generic1);
      ITypeDefinition type = fld.Type.ResolvedType;
      IEventDefinition eventDef = Helper.GetEventNamed(type, this.GenericEvent);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);
      prettyPrinter.EventDefinition(eventDef);
      string result =
@".event public[MRW_Assembly]GenericDelegate`1<int32>GenericEvent
{
  .addon instance void[MRW_Assembly]Generic1`1<int32>::add_GenericEvent([MRW_Assembly]GenericDelegate`1<int32>)
  .removeon instance void[MRW_Assembly]Generic1`1<int32>::remove_GenericEvent([MRW_Assembly]GenericDelegate`1<int32>)
}
";
      return result.Equals(stringPaper.Content);
    }
示例#27
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);
    }
    public bool TestfreeMethod() {
      IMethodDefinition method = Helper.GetGlobalMethod((IUnitNamespace)this.ModuleReaderTest.CppAssembly.NamespaceRoot, this.free);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.CppAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method public static pinvokeimpl(MSVCR80.dll as free cdecl lasterr)explicit default void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)free(
  void*
)cil managed preservesig
{
  .custom instance void[mscorlib]System.Security.SuppressUnmanagedCodeSecurityAttribute::.ctor()
  {
  }
}
";
      return result.Equals(stringPaper.Content);
    }
示例#29
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);
    }
    public bool TestPtrToStringCharsMethod() {
      IMethodDefinition method = Helper.GetGlobalMethod((IUnitNamespace)this.ModuleReaderTest.CppAssembly.NamespaceRoot, this.PtrToStringChars);
      StringILDasmPaper stringPaper = new StringILDasmPaper(2);
      ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.CppAssembly);
      prettyPrinter.MethodDefinition(method);
      string result =
@".method assembly static explicit default char modopt([mscorlib]System.Runtime.CompilerServices.IsConst)&modopt([mscorlib]System.Runtime.CompilerServices.IsExplicitlyDereferenced)PtrToStringChars(
  [mscorlib]System.String modopt([mscorlib]System.Runtime.CompilerServices.IsConst) s
)cil managed
{
  .maxstack 2
  .locals(
    unsigned int8&modopt([mscorlib]System.Runtime.CompilerServices.IsExplicitlyDereferenced) V_0
  )
  IL_0000:  ldarg.0
  IL_0001:  stloc.0
  IL_0002:  ldloc.0
  IL_0003:  brfalse.s IL_000d
  IL_0005:  call static int32[mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::get_OffsetToStringData()
  IL_000a:  ldloc.0
  IL_000b:  add
  IL_000c:  stloc.0
  IL_000d:  ldloc.0
  IL_000e:  ret
}
";
      return result.Equals(stringPaper.Content);
    }