public void TestSerializedSignatureWithReferenceToMDIntArray() { var typeInInitialContext = _context.GetWellKnownType(WellKnownType.Int32).MakeArrayType(3); // Create assembly with reference to interesting type TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new System.Reflection.AssemblyName("Lookup"), _context); var token = metadataEmitter.GetTypeRef(typeInInitialContext); Stream peStream = new MemoryStream(); metadataEmitter.SerializeToStream(peStream); peStream.Seek(0, SeekOrigin.Begin); // Create new TypeSystemContext with just created assembly inside var lookupContext = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = lookupContext.CreateModuleForSimpleName("CoreTestAssembly"); lookupContext.SetSystemModule(systemModule); lookupContext.CreateModuleForSimpleName("Lookup", peStream); // Use generated assembly to trigger a load through the token created above and verify that it loads correctly var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); TypeDesc int32ArrayFromLookup = ilLookupModule.GetType(token); var typeInLookupContext = lookupContext.GetWellKnownType(WellKnownType.Int32).MakeArrayType(3); Assert.Equal(typeInLookupContext, int32ArrayFromLookup); }
public void TestSerializedSignatureWithArrayShapes() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodDesc methodWithInterestingShapes = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")); // Create assembly with reference to interesting method TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new System.Reflection.AssemblyName("Lookup"), _context); var token = metadataEmitter.GetMethodRef(methodWithInterestingShapes); Stream peStream = new MemoryStream(); metadataEmitter.SerializeToStream(peStream); peStream.Seek(0, SeekOrigin.Begin); // Create new TypeSystemContext with just created assembly inside var lookupContext = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = lookupContext.CreateModuleForSimpleName("CoreTestAssembly"); lookupContext.SetSystemModule(systemModule); lookupContext.CreateModuleForSimpleName("Lookup", peStream); // Use generated assembly to trigger a load through the token created above and verify that it loads correctly var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); MethodDesc method4 = ilLookupModule.GetMethod(token); Assert.Equal("Method4", method4.Name); }
public InstanceFieldLayoutTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _ilTestModule = _context.CreateModuleForSimpleName("ILTestAssembly"); }
public ConstraintsValidationTest() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _iNonGenType = _testModule.GetType("GenericConstraints", "INonGen"); _iGenType = _testModule.GetType("GenericConstraints", "IGen`1"); _arg1Type = _testModule.GetType("GenericConstraints", "Arg1"); _arg2Type = _testModule.GetType("GenericConstraints", "Arg2`1"); _arg3Type = _testModule.GetType("GenericConstraints", "Arg3`1"); _structArgWithDefaultCtorType = _testModule.GetType("GenericConstraints", "StructArgWithDefaultCtor"); _structArgWithoutDefaultCtorType = _testModule.GetType("GenericConstraints", "StructArgWithoutDefaultCtor"); _classArgWithDefaultCtorType = _testModule.GetType("GenericConstraints", "ClassArgWithDefaultCtor"); _classArgWithPrivateDefaultCtorType = _testModule.GetType("GenericConstraints", "ClassArgWithPrivateDefaultCtor"); _abstractClassArgWithDefaultCtorType = _testModule.GetType("GenericConstraints", "AbstractClassArgWithDefaultCtor"); _classArgWithoutDefaultCtorType = _testModule.GetType("GenericConstraints", "ClassArgWithoutDefaultCtor"); _referenceTypeConstraintType = _testModule.GetType("GenericConstraints", "ReferenceTypeConstraint`1"); _defaultConstructorConstraintType = _testModule.GetType("GenericConstraints", "DefaultConstructorConstraint`1"); _notNullableValueTypeConstraintType = _testModule.GetType("GenericConstraints", "NotNullableValueTypeConstraint`1"); _simpleTypeConstraintType = _testModule.GetType("GenericConstraints", "SimpleTypeConstraint`1"); _doubleSimpleTypeConstraintType = _testModule.GetType("GenericConstraints", "DoubleSimpleTypeConstraint`1"); _simpleGenericConstraintType = _testModule.GetType("GenericConstraints", "SimpleGenericConstraint`2"); _complexGenericConstraint1Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint1`2"); _complexGenericConstraint2Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint2`2"); _complexGenericConstraint3Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint3`2"); _multipleConstraintsType = _testModule.GetType("GenericConstraints", "MultipleConstraints`2"); }
public GenericMethodTests() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public SyntheticVirtualOverrideTests() { _context = new SyntheticVirtualOverrideTypeSystemContext(); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public HashcodeTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public ILDisassemblerTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = _context.GetModuleForSimpleName("ILTestAssembly"); }
public static IEnumerable <object[]> VariantTestData() { var context = new TestTypeSystemContext(TargetArchitecture.Unknown); ModuleDesc testModule = context.CreateModuleForSimpleName("CoreTestAssembly"); context.SetSystemModule(testModule); MetadataType simple = testModule.GetType("VirtualStaticInterfaceMethods", "Simple"); MetadataType iSimple = testModule.GetType("VirtualStaticInterfaceMethods", "ISimple"); MetadataType iVariant = testModule.GetType("VirtualStaticInterfaceMethods", "IVariant`1"); MetadataType @base = testModule.GetType("VirtualStaticInterfaceMethods", "Base"); MetadataType mid = testModule.GetType("VirtualStaticInterfaceMethods", "Mid"); MetadataType derived = testModule.GetType("VirtualStaticInterfaceMethods", "Derived"); MetadataType simpleVariant = testModule.GetType("VirtualStaticInterfaceMethods", "SimpleVariant"); MetadataType simpleVariantTwice = testModule.GetType("VirtualStaticInterfaceMethods", "SimpleVariantTwice"); MetadataType variantWithInheritanceDerived = testModule.GetType("VirtualStaticInterfaceMethods", "VariantWithInheritanceDerived"); MetadataType genericVariantWithInheritanceDerived = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithInheritanceDerived`1"); MetadataType genericVariantWithHiddenBase = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithHiddenBase"); MetadataType genericVariantWithHiddenDerived = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithHiddenDerived`1"); MethodDesc iSimpleMethod = iSimple.GetMethod("WhichMethod", null); MethodDesc iVariantBaseMethod = iVariant.MakeInstantiatedType(@base).GetMethod("WhichMethod", null); MethodDesc iVariantMidMethod = iVariant.MakeInstantiatedType(mid).GetMethod("WhichMethod", null); MethodDesc iVariantDerivedMethod = iVariant.MakeInstantiatedType(derived).GetMethod("WhichMethod", null); yield return(new object[] { simple, iSimpleMethod, simple.GetMethod("WhichMethod", null) }); yield return(new object[] { simpleVariant, iVariantBaseMethod, simpleVariant.GetMethod("WhichMethod", null) }); yield return(new object[] { simpleVariant, iVariantDerivedMethod, simpleVariant.GetMethod("WhichMethod", null) }); yield return(new object[] { simpleVariantTwice, iVariantBaseMethod, simpleVariantTwice.GetMethod("WhichMethod", new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { @base })) }); yield return(new object[] { simpleVariantTwice, iVariantMidMethod, simpleVariantTwice.GetMethod("WhichMethod", new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { mid })) }); yield return(new object[] { simpleVariantTwice, iVariantDerivedMethod, simpleVariantTwice.GetMethod("WhichMethod", new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { @base })) }); yield return(new object[] { variantWithInheritanceDerived, iVariantBaseMethod, variantWithInheritanceDerived.GetMethod("WhichMethod", null) }); yield return(new object[] { variantWithInheritanceDerived, iVariantMidMethod, variantWithInheritanceDerived.GetMethod("WhichMethod", null) }); yield return(new object[] { variantWithInheritanceDerived, iVariantDerivedMethod, variantWithInheritanceDerived.GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(@base), iVariantBaseMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(@base), iVariantMidMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(mid), iVariantMidMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(mid).GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(@base), iVariantBaseMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(@base), iVariantMidMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(mid), iVariantMidMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(mid).GetMethod("WhichMethod", null) }); yield return(new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(derived), iVariantMidMethod, genericVariantWithHiddenBase.GetMethod("WhichMethod", null) }); }
public SyntheticVirtualOverrideTests() { _context = new SyntheticVirtualOverrideTypeSystemContext(); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public GenericMethodTests() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public GCPointerMapTests() { _context = new TestTypeSystemContext(TargetArchitecture.X86); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public ValueTypeShapeCharacteristicsTests() { _context = new TestTypeSystemContext(TargetArchitecture.ARM); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public ILDisassemblerTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = _context.GetModuleForSimpleName("ILTestAssembly"); }
public MarshalUtilsTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; }
public SignatureTests(ITestOutputHelper output) { _output = output; _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = _context.GetModuleForSimpleName("ILTestAssembly"); }
public VirtualMethodEnumerationAlgorithmTests() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _testType = _testModule.GetType("VirtualFunctionOverride", "SimpleGeneric`1") .MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Object)); }
public VirtualFunctionOverrideTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _stringType = _context.GetWellKnownType(WellKnownType.String); _voidType = _context.GetWellKnownType(WellKnownType.Void); }
public ValueTypeShapeCharacteristicsTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _singleType = _context.GetWellKnownType(WellKnownType.Single); _doubleType = _context.GetWellKnownType(WellKnownType.Double); }
public VirtualFunctionOverrideTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _stringType = _context.GetWellKnownType(WellKnownType.String); _voidType = _context.GetWellKnownType(WellKnownType.Void); }
public VirtualMethodEnumerationAlgorithmTests() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _testType = _testModule.GetType("VirtualFunctionOverride", "SimpleGeneric`1") .MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Object)); }
public ValueTypeShapeCharacteristicsTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _singleType = _context.GetWellKnownType(WellKnownType.Single); _doubleType = _context.GetWellKnownType(WellKnownType.Double); }
public CanonicalizationTests() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _referenceType = _testModule.GetType("Canonicalization", "ReferenceType"); _otherReferenceType = _testModule.GetType("Canonicalization", "OtherReferenceType"); _structType = _testModule.GetType("Canonicalization", "StructType"); _otherStructType = _testModule.GetType("Canonicalization", "OtherStructType"); _genericReferenceType = _testModule.GetType("Canonicalization", "GenericReferenceType`1"); _genericStructType = _testModule.GetType("Canonicalization", "GenericStructType`1"); }
public CanonicalizationTests() { _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = systemModule; _referenceType = _testModule.GetType("Canonicalization", "ReferenceType"); _otherReferenceType = _testModule.GetType("Canonicalization", "OtherReferenceType"); _structType = _testModule.GetType("Canonicalization", "StructType"); _otherStructType = _testModule.GetType("Canonicalization", "OtherStructType"); _genericReferenceType = _testModule.GetType("Canonicalization", "GenericReferenceType`1"); _genericStructType = _testModule.GetType("Canonicalization", "GenericStructType`1"); }
public ArchitectureSpecificFieldLayoutTests() { _contextX64 = new TestTypeSystemContext(TargetArchitecture.X64); var systemModuleX64 = _contextX64.CreateModuleForSimpleName("CoreTestAssembly"); _contextX64.SetSystemModule(systemModuleX64); _testModuleX64 = systemModuleX64; _contextX64Linux = new TestTypeSystemContext(TargetArchitecture.X64, TargetOS.Linux); var systemModuleX64Linux = _contextX64Linux.CreateModuleForSimpleName("CoreTestAssembly"); _contextX64Linux.SetSystemModule(systemModuleX64Linux); _testModuleX64Linux = systemModuleX64Linux; _contextX64Windows = new TestTypeSystemContext(TargetArchitecture.X64, TargetOS.Windows); var systemModuleX64Windows = _contextX64Windows.CreateModuleForSimpleName("CoreTestAssembly"); _contextX64Windows.SetSystemModule(systemModuleX64Windows); _testModuleX64Windows = systemModuleX64Windows; _contextARM = new TestTypeSystemContext(TargetArchitecture.ARM); var systemModuleARM = _contextARM.CreateModuleForSimpleName("CoreTestAssembly"); _contextARM.SetSystemModule(systemModuleARM); _testModuleARM = systemModuleARM; _contextX86 = new TestTypeSystemContext(TargetArchitecture.X86); var systemModuleX86 = _contextX86.CreateModuleForSimpleName("CoreTestAssembly"); _contextX86.SetSystemModule(systemModuleX86); _testModuleX86 = systemModuleX86; _contextARM64 = new TestTypeSystemContext(TargetArchitecture.ARM64); var systemModuleARM64 = _contextARM64.CreateModuleForSimpleName("CoreTestAssembly"); _contextARM64.SetSystemModule(systemModuleARM64); _testModuleARM64 = systemModuleARM64; }
public ArchitectureSpecificFieldLayoutTests() { _contextX64 = new TestTypeSystemContext(TargetArchitecture.X64); var systemModuleX64 = _contextX64.CreateModuleForSimpleName("CoreTestAssembly"); _contextX64.SetSystemModule(systemModuleX64); _testModuleX64 = systemModuleX64; _contextARM = new TestTypeSystemContext(TargetArchitecture.ARM); var systemModuleARM = _contextARM.CreateModuleForSimpleName("CoreTestAssembly"); _contextARM.SetSystemModule(systemModuleARM); _testModuleARM = systemModuleARM; _contextX86 = new TestTypeSystemContext(TargetArchitecture.X86); var systemModuleX86 = _contextX86.CreateModuleForSimpleName("CoreTestAssembly"); _contextX86.SetSystemModule(systemModuleX86); _testModuleX86 = systemModuleX86; }
public TypeNameParsingTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); // TODO-NICE: split test types into a separate, non-core, module _testModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(_testModule); _simpleType = _testModule.GetType("TypeNameParsing", "Simple"); _nestedType = _simpleType.GetNestedType("Nested"); _nestedTwiceType = _nestedType.GetNestedType("NestedTwice"); _genericType = _testModule.GetType("TypeNameParsing", "Generic`1"); _nestedGenericType = _genericType.GetNestedType("NestedGeneric`1"); _nestedNongenericType = _genericType.GetNestedType("NestedNongeneric"); _veryGenericType = _testModule.GetType("TypeNameParsing", "VeryGeneric`3"); _structType = _testModule.GetType("TypeNameParsing", "Struct"); _coreAssemblyQualifier = ((IAssemblyDesc)_testModule).GetName().FullName; }
public TypeNameParsingTests() { _context = new TestTypeSystemContext(TargetArchitecture.X64); // TODO-NICE: split test types into a separate, non-core, module _testModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(_testModule); _simpleType = _testModule.GetType("TypeNameParsing", "Simple"); _nestedType = _simpleType.GetNestedType("Nested"); _nestedTwiceType = _nestedType.GetNestedType("NestedTwice"); _genericType = _testModule.GetType("TypeNameParsing", "Generic`1"); _nestedGenericType = _genericType.GetNestedType("NestedGeneric`1"); _nestedNongenericType = _genericType.GetNestedType("NestedNongeneric"); _veryGenericType = _testModule.GetType("TypeNameParsing", "VeryGeneric`3"); _structType = _testModule.GetType("TypeNameParsing", "Struct"); _coreAssemblyQualifier = ((IAssemblyDesc)_testModule).GetName().FullName; }
public ArchitectureSpecificFieldLayoutTests() { _contextX64 = new TestTypeSystemContext(TargetArchitecture.X64); var systemModuleX64 = _contextX64.CreateModuleForSimpleName("CoreTestAssembly"); _contextX64.SetSystemModule(systemModuleX64); _testModuleX64 = systemModuleX64; _contextARM = new TestTypeSystemContext(TargetArchitecture.ARM); var systemModuleARM = _contextARM.CreateModuleForSimpleName("CoreTestAssembly"); _contextARM.SetSystemModule(systemModuleARM); _testModuleARM = systemModuleARM; _contextX86 = new TestTypeSystemContext(TargetArchitecture.X86); var systemModuleX86 = _contextX86.CreateModuleForSimpleName("CoreTestAssembly"); _contextX86.SetSystemModule(systemModuleX86); _testModuleX86 = systemModuleX86; }
public UniversalGenericFieldLayoutTests() { // Architecture specific tests may use these contexts _contextX64 = new TestTypeSystemContext(TargetArchitecture.X64); var systemModuleX64 = _contextX64.CreateModuleForSimpleName("CoreTestAssembly"); _contextX64.SetSystemModule(systemModuleX64); _testModuleX64 = systemModuleX64; _contextARM = new TestTypeSystemContext(TargetArchitecture.ARM); var systemModuleARM = _contextARM.CreateModuleForSimpleName("CoreTestAssembly"); _contextARM.SetSystemModule(systemModuleARM); _testModuleARM = systemModuleARM; _contextX86 = new TestTypeSystemContext(TargetArchitecture.X86); var systemModuleX86 = _contextX86.CreateModuleForSimpleName("CoreTestAssembly"); _contextX86.SetSystemModule(systemModuleX86); _testModuleX86 = systemModuleX86; }