public PrecomputedMetadataManager( CompilationModuleGroup group, CompilerTypeSystemContext typeSystemContext, ModuleDesc metadataDescribingModule, IEnumerable <ModuleDesc> compilationModules, IEnumerable <ModuleDesc> inputMetadataOnlyAssemblies, byte[] metadataBlob, StackTraceEmissionPolicy stackTraceEmissionPolicy) : base(group, typeSystemContext, new AttributeSpecifiedBlockingPolicy()) { _metadataDescribingModule = metadataDescribingModule; _compilationModules = new HashSet <ModuleDesc>(compilationModules); _metadataOnlyAssemblies = new HashSet <ModuleDesc>(inputMetadataOnlyAssemblies); _loadedMetadata = new Lazy <MetadataLoadedInfo>(LoadMetadata); _dynamicInvokeStubs = new Lazy <Dictionary <MethodDesc, MethodDesc> >(LoadDynamicInvokeStubs); _metadataBlob = metadataBlob; _stackTraceEmissionPolicy = stackTraceEmissionPolicy; }
public RuntimeDeterminedTypesTests() { _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"); _genericReferenceTypeWithThreeParams = _testModule.GetType("Canonicalization", "GenericReferenceTypeWithThreeParams`3"); _genericStructTypeWithThreeParams = _testModule.GetType("Canonicalization", "GenericStructTypeWithThreeParams`3"); }
private TypeDesc FindType(CompilerTypeSystemContext context, string typeName) { ModuleDesc systemModule = context.SystemModule; TypeDesc foundType = systemModule.GetTypeByCustomAttributeTypeName(typeName); if (foundType == null) { throw new CommandLineException($"Type '{typeName}' not found"); } TypeDesc classLibCanon = systemModule.GetType("System", "__Canon", false); TypeDesc classLibUniCanon = systemModule.GetType("System", "__UniversalCanon", false); return(foundType.ReplaceTypesInConstructionOfType( new TypeDesc[] { classLibCanon, classLibUniCanon }, new TypeDesc[] { context.CanonType, context.UniversalCanonType })); }
private IReadOnlyCollection <MethodDesc> CreateInitializerList(CompilerTypeSystemContext context, ILCompilerOptions options) { List <ModuleDesc> assembliesWithInitalizers = new List <ModuleDesc> (); // Build a list of assemblies that have an initializer that needs to run before // any user code runs. foreach (string initAssemblyName in options.InitAssemblies) { ModuleDesc assembly = context.ResolveAssembly(new AssemblyName(initAssemblyName), throwIfNotFound: true); assembliesWithInitalizers.Add(assembly); } var libraryInitializers = new LibraryInitializers(context, assembliesWithInitalizers); List <MethodDesc> initializerList = new List <MethodDesc> (libraryInitializers.LibraryInitializerMethods); return(initializerList); }
static bool ParseDocumentationSignature(string id, ModuleDesc module, List <TypeSystemEntity> results) { if (id == null) { return(false); } if (id.Length < 2) { return(false); } int index = 0; results.Clear(); ParseSignature(id, ref index, module, results); return(results.Count > 0); }
private void ProcessAssembly(ModuleDesc assembly) { while (_reader.IsStartElement()) { if (_reader.Name == "type") { ProcessType(assembly); } else if (_reader.Name == "resource") { ProcessResource(assembly); } _reader.Skip(); } _reader.ReadEndElement(); }
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 override MetadataType GetType(string nameSpace, string name, bool throwIfNotFound = true) { QualifiedNamespaceDefinition[] namespaceDefinitions = GetNamespaceDefinitionsFromString(nameSpace); foreach (QualifiedNamespaceDefinition namespaceDefinition in namespaceDefinitions) { // At least the namespace was found. MetadataReader metadataReader = namespaceDefinition.MetadataReader; // Now scan the type definitions on this namespace foreach (var typeDefinitionHandle in namespaceDefinition.Definition.TypeDefinitions) { var typeDefinition = metadataReader.GetTypeDefinition(typeDefinitionHandle); if (typeDefinition.Name.StringEquals(name, metadataReader)) { return((MetadataType)namespaceDefinition.MetadataUnit.GetType((Handle)typeDefinitionHandle)); } } } foreach (QualifiedNamespaceDefinition namespaceDefinition in namespaceDefinitions) { // At least the namespace was found. MetadataReader metadataReader = namespaceDefinition.MetadataReader; // Now scan the type forwarders on this namespace foreach (var typeForwarderHandle in namespaceDefinition.Definition.TypeForwarders) { var typeForwarder = metadataReader.GetTypeForwarder(typeForwarderHandle); if (typeForwarder.Name.StringEquals(name, metadataReader)) { ModuleDesc forwardTargetModule = namespaceDefinition.MetadataUnit.GetModule(typeForwarder.Scope); return(forwardTargetModule.GetType(nameSpace, name, throwIfNotFound)); } } } if (throwIfNotFound) { throw CreateTypeLoadException(nameSpace + "." + name); } return(null); }
public PInvokeMethodData(PInvokeLazyFixupField pInvokeLazyFixupField) { PInvokeMetadata metadata = pInvokeLazyFixupField.PInvokeMetadata; ModuleDesc declaringModule = ((MetadataType)pInvokeLazyFixupField.TargetMethod.OwningType).Module; DllImportSearchPath?dllImportSearchPath = default; if (declaringModule.Assembly is EcmaAssembly asm) { // We look for [assembly:DefaultDllImportSearchPaths(...)] var attrHandle = asm.MetadataReader.GetCustomAttributeHandle(asm.AssemblyDefinition.GetCustomAttributes(), "System.Runtime.InteropServices", "DefaultDllImportSearchPathsAttribute"); if (!attrHandle.IsNil) { var attr = asm.MetadataReader.GetCustomAttribute(attrHandle); var decoded = attr.DecodeValue(new CustomAttributeTypeProvider(asm)); if (decoded.FixedArguments.Length == 1 && decoded.FixedArguments[0].Value is int searchPath) { dllImportSearchPath = (DllImportSearchPath)searchPath; } } } ModuleData = new PInvokeModuleData(metadata.Module, dllImportSearchPath, declaringModule); EntryPointName = metadata.Name; CharSet charSetMangling = default; if (declaringModule.Context.Target.IsWindows && !metadata.Flags.ExactSpelling) { // Mirror CharSet normalization from Marshaller.CreateMarshaller bool isAnsi = metadata.Flags.CharSet switch { CharSet.Ansi => true, CharSet.Unicode => false, CharSet.Auto => false, _ => true }; charSetMangling = isAnsi ? CharSet.Ansi : CharSet.Unicode; } CharSetMangling = charSetMangling; }
/// <summary> /// Given a parsed out module, namespace + type, and method name, try to find a matching MethodDesc /// TODO: We have no signature information for the method - what policy should we apply where multiple methods exist with the same name /// but different signatures? For now we'll take the first matching and ignore others. Ideally we'll improve the profile data to include this. /// </summary> /// <returns>MethodDesc if found, null otherwise</returns> private MethodDesc ResolveMethodName(CompilerTypeSystemContext context, ModuleDesc module, string namespaceAndTypeName, string methodName) { TypeDesc resolvedType = module.GetTypeByCustomAttributeTypeName(namespaceAndTypeName, false, (typeDefName, module, throwIfNotFound) => { return((MetadataType)context.GetCanonType(typeDefName) ?? CustomAttributeTypeNameParser.ResolveCustomAttributeTypeDefinitionName(typeDefName, module, throwIfNotFound)); }); if (resolvedType != null) { var resolvedMethod = resolvedType.GetMethod(methodName, null); if (resolvedMethod != null) { return(resolvedMethod); } } return(null); }
// Returns null if no matching type is found private static TypeDesc GetMatchingType(ModuleDesc module, TypeDesc type) { var metadataType = (MetadataType)type; var containingType = metadataType.ContainingType; if (containingType != null) { var matchingContainingType = (MetadataType)GetMatchingType(module, containingType); if (matchingContainingType == null) { return(null); } return(matchingContainingType.GetNestedType(metadataType.Name)); } else { return(module.GetType(metadataType.Namespace, metadataType.Name, false)); } }
public override bool IsManifestResourceBlocked(ModuleDesc module, string resourceName) { // The embedded RESX files all have names that end with .resources, so use that as the initial filter. if (!resourceName.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) { return(false); } // Assuming multimodule and non-ecma assemblies are unsupported EcmaModule ecmaModule = (EcmaModule)module; // If this is not a framework assembly, no resources are blocked if (!IsFrameworkAssembly(ecmaModule)) { return(false); } MetadataReader reader = ecmaModule.MetadataReader; // We have a resource in the framework assembly. Now check if this is a RESX foreach (ManifestResourceHandle resourceHandle in reader.ManifestResources) { ManifestResource resource = reader.GetManifestResource(resourceHandle); if (reader.StringComparer.Equals(resource.Name, resourceName) && resource.Implementation.IsNil) { PEMemoryBlock resourceDirectory = ecmaModule.PEReader.GetSectionData(ecmaModule.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress); BlobReader blob = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset); int length = (int)blob.ReadUInt32(); if (length > 4) { // Check for magic bytes that correspond to RESX if (blob.ReadUInt32() == 0xBEEFCACE) { return(true); } } } } return(false); }
private void ProcessType(ModuleDesc assembly) { if (ShouldProcessElement()) { string typeName = _reader.GetAttribute("fullname"); if (typeName.Contains('*')) { throw new NotSupportedException(); } TypeDesc type = CustomAttributeTypeNameParser.GetTypeByCustomAttributeTypeName(assembly, typeName, throwIfNotFound: false); if (type == null) { //Context.LogWarning ($"Could not resolve type '{fullname}'", 2008, _xmlDocumentLocation); _reader.Skip(); return; } _reader.Read(); while (_reader.IsStartElement()) { if (_reader.Name == "method") { ProcessMethod(type); } else if (_reader.Name == "field") { ProcessField(type); } else if (_reader.Name == "attribute") { ProcessAttribute(type); } _reader.Skip(); } } _reader.Skip(); }
public BoxedValueType(ModuleDesc owningModule, MetadataType valuetype) { // BoxedValueType has the same genericness as the valuetype it's wrapping. // Making BoxedValueType wrap the genericness (and be itself nongeneric) would // require a name mangling scheme to allow generating stable and unique names // for the wrappers. Debug.Assert(valuetype.IsTypeDefinition); Debug.Assert(valuetype.IsValueType); Module = owningModule; ValueTypeRepresented = valuetype; // Unboxing thunks for byref-like types don't make sense. Byref-like types cannot be boxed. // We still allow these to exist in the system, because it's easier than trying to prevent // their creation. We create them as if they existed (in lieu of e.g. pointing all of them // to the same __unreachable method body) so that the various places that store pointers to // them because they want to be able to extract the target instance method can use the same // mechanism they use for everything else at runtime. }
private void ProcessAssemblyDirective(IRootingServiceProvider rootProvider, XElement assemblyElement) { var assemblyNameAttribute = assemblyElement.Attribute("Name"); if (assemblyNameAttribute == null) { throw new Exception(); } ModuleDesc assembly = _context.ResolveAssembly(new AssemblyName(assemblyNameAttribute.Value)); rootProvider.RootModuleMetadata(assembly, "RD.XML root"); var dynamicDegreeAttribute = assemblyElement.Attribute("Dynamic"); if (dynamicDegreeAttribute != null) { if (dynamicDegreeAttribute.Value != "Required All") { throw new NotSupportedException(); } foreach (TypeDesc type in ((EcmaModule)assembly).GetAllTypes()) { RootType(rootProvider, type); } } foreach (var element in assemblyElement.Elements()) { switch (element.Name.LocalName) { case "Type": ProcessTypeDirective(rootProvider, assembly, element); break; default: throw new NotSupportedException(); } } }
private void ProcessAssemblyDirective(IRootingServiceProvider rootProvider, XElement assemblyElement) { var assemblyNameAttribute = assemblyElement.Attribute("Name"); if (assemblyNameAttribute == null) { throw new Exception("The \"Name\" attribute is required on the \"Assembly\" Runtime Directive."); } ModuleDesc assembly = _context.ResolveAssembly(new AssemblyName(assemblyNameAttribute.Value)); rootProvider.RootModuleMetadata(assembly, "RD.XML root"); var dynamicDegreeAttribute = assemblyElement.Attribute("Dynamic"); if (dynamicDegreeAttribute != null) { if (dynamicDegreeAttribute.Value != "Required All") { throw new NotSupportedException($"\"{dynamicDegreeAttribute.Value}\" is not a supported value for the \"Dynamic\" attribute of the \"Assembly\" Runtime Directive. Supported values are \"Required All\"."); } foreach (TypeDesc type in ((EcmaModule)assembly).GetAllTypes()) { RootingHelpers.TryRootType(rootProvider, type, "RD.XML root"); } } foreach (var element in assemblyElement.Elements()) { switch (element.Name.LocalName) { case "Type": ProcessTypeDirective(rootProvider, assembly, element); break; default: throw new NotSupportedException($"\"{element.Name.LocalName}\" is not a supported Runtime Directive."); } } }
private static bool TryLogSingleWarning(Logger context, int code, MessageOrigin origin, string subcategory) { if (subcategory != MessageSubCategory.AotAnalysis && subcategory != MessageSubCategory.TrimAnalysis) { return(false); } var declaringType = origin.MemberDefinition switch { TypeDesc type => type, MethodDesc method => method.OwningType, FieldDesc field => field.OwningType, #if !READYTORUN PropertyPseudoDesc property => property.OwningType, EventPseudoDesc @event => @event.OwningType, #endif _ => null, }; ModuleDesc declaringAssembly = (declaringType as MetadataType)?.Module; Debug.Assert(declaringAssembly != null); if (declaringAssembly == null) { return(false); } // Any IL2026 warnings left in an assembly with an IsTrimmable attribute are considered intentional // and should not be collapsed, so that the user-visible RUC message gets printed. if (code == 2026 && IsTrimmableAssembly(declaringAssembly)) { return(false); } if (context.IsSingleWarn(declaringAssembly, subcategory)) { return(true); } return(false); }
private static bool GrantsFriendAccessTo(this ModuleDesc module, ModuleDesc friendModule) { var assembly = (EcmaAssembly)module; var friendName = ((IAssemblyDesc)friendModule).GetName(); foreach (var attribute in assembly.GetDecodedCustomAttributes("System.Runtime.CompilerServices", "InternalsVisibleToAttribute")) { AssemblyName friendAttributeName = new AssemblyName((string)attribute.FixedArguments[0].Value); if (!friendName.Name.Equals(friendAttributeName.Name, StringComparison.OrdinalIgnoreCase)) { continue; } // Comparing PublicKeyToken, since GetPublicKey returns null due to a bug if (IsSamePublicKey(friendAttributeName.GetPublicKeyToken(), friendName.GetPublicKeyToken())) { return(true); } } return(false); }
private void InitializeSimdModules(TypeDesc type) { TypeSystemContext context = type.Context; ArrayBuilder <ModuleDesc> simdModules = new ArrayBuilder <ModuleDesc>(); ModuleDesc module = context.ResolveAssembly(new AssemblyName("System.Numerics"), false); if (module != null) { simdModules.Add(module); } module = context.ResolveAssembly(new AssemblyName("System.Numerics.Vectors"), false); if (module != null) { simdModules.Add(module); } _simdModulesCached = simdModules.ToArray(); }
public bool IsInSimdModule(TypeDesc type) { if (type is MetadataType) { if (_simdModulesCached == null) { InitializeSimdModules(type); } ModuleDesc typeModule = ((MetadataType)type).Module; foreach (ModuleDesc simdModule in _simdModulesCached) { if (typeModule == simdModule) { return(true); } } } return(false); }
private int ModuleToIndexForInputModulesOnly(ModuleDesc module) { if (!(module is EcmaModule ecmaModule)) { return(-1); } if (!_nodeFactory.CompilationModuleGroup.IsModuleInCompilationGroup(ecmaModule)) { return(-1); } #if DEBUG int oldModuleToIndexCount = _assemblyRefToModuleIdMap.Count; #endif int index = ModuleToIndexInternal(ecmaModule); #if DEBUG Debug.Assert(oldModuleToIndexCount == _assemblyRefToModuleIdMap.Count); #endif return(index); }
/// <summary> /// Gets an object representing the static data for RVA mapped fields from the PE image. /// </summary> public virtual ISymbolNode GetFieldRvaData(FieldDesc field) { if (field.GetType() == typeof(PInvokeLazyFixupField)) { var pInvokeFixup = (PInvokeLazyFixupField)field; PInvokeMetadata metadata = pInvokeFixup.PInvokeMetadata; ModuleDesc callingModule = ((MetadataType)pInvokeFixup.TargetMethod.OwningType).Module; DllImportSearchPath?dllImportSearchPath = default; if (callingModule.Assembly is EcmaAssembly asm) { // We look for [assembly:DefaultDllImportSearchPaths(...)] var attrHandle = asm.MetadataReader.GetCustomAttributeHandle(asm.AssemblyDefinition.GetCustomAttributes(), "System.Runtime.InteropServices", "DefaultDllImportSearchPathsAttribute"); if (!attrHandle.IsNil) { var attr = asm.MetadataReader.GetCustomAttribute(attrHandle); var decoded = attr.DecodeValue(new CustomAttributeTypeProvider(asm)); if (decoded.FixedArguments.Length == 1 && decoded.FixedArguments[0].Value is int searchPath) { dllImportSearchPath = (DllImportSearchPath)searchPath; } } } PInvokeModuleData moduleData = new PInvokeModuleData(metadata.Module, dllImportSearchPath, callingModule); return(NodeFactory.PInvokeMethodFixup(moduleData, metadata.Name, metadata.Flags)); } else if (field is ExternSymbolMappedField externField) { return(NodeFactory.ExternSymbol(externField.SymbolName)); } else { // Use the typical field definition in case this is an instantiated generic type field = field.GetTypicalFieldDefinition(); return(NodeFactory.ReadOnlyDataBlob(NameMangler.GetMangledFieldName(field), ((EcmaField)field).GetFieldRvaData(), NodeFactory.Target.PointerSize)); } }
private void ProcessMethodDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, TypeDesc containingType, XElement methodElement) { var methodNameAttribute = methodElement.Attribute("Name"); if (methodNameAttribute == null) { throw new Exception(); } string methodName = methodNameAttribute.Value; MethodDesc method = containingType.GetMethod(methodName, null); var instArgs = new List <TypeDesc>(); foreach (var element in methodElement.Elements()) { switch (element.Name.LocalName) { case "GenericArgument": string instArgName = element.Attribute("Name").Value; instArgs.Add(containingModule.GetTypeByCustomAttributeTypeName(instArgName)); break; default: throw new NotSupportedException(); } } if (instArgs.Count != method.Instantiation.Length) { throw new Exception(); } if (instArgs.Count > 0) { var methodInst = new Instantiation(instArgs.ToArray()); method = method.MakeInstantiatedMethod(methodInst); } RootMethod(rootProvider, method); }
public SimpleArrayOfTRuntimeInterfacesAlgorithm(ModuleDesc systemModule) { _systemModule = systemModule; // initialize interfaces _arrayRuntimeInterfaces = _systemModule.GetType("System", "Array")?.RuntimeInterfaces ?? Array.Empty <DefType>(); _genericRuntimeInterfaces = new MetadataType[s_genericRuntimeInterfacesNames.Length]; int count = 0; for (int i = 0; i < s_genericRuntimeInterfacesNames.Length; ++i) { MetadataType runtimeInterface = _systemModule.GetType("System.Collections.Generic", s_genericRuntimeInterfacesNames[i], false); if (runtimeInterface != null) { _genericRuntimeInterfaces[count++] = runtimeInterface; } } ; Array.Resize(ref _genericRuntimeInterfaces, count); }
public void AppendNameForNamespaceTypeWithoutAliases(StringBuilder sb, DefType type) { ModuleDesc owningModule = (type as MetadataType)?.Module; if (owningModule != null && owningModule != _thisModule) { Debug.Assert(owningModule is IAssemblyDesc); string owningModuleName = ((IAssemblyDesc)owningModule).GetName().Name; sb.Append('['); sb.Append(owningModuleName); sb.Append(']'); } string ns = type.Namespace; if (ns.Length > 0) { sb.Append(ns); sb.Append('.'); } sb.Append(type.Name); }
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; }
private void ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, XElement typeElement) { var typeNameAttribute = typeElement.Attribute("Name"); if (typeNameAttribute == null) { throw new Exception(); } var dynamicDegreeAttribute = typeElement.Attribute("Dynamic"); if (dynamicDegreeAttribute != null) { if (dynamicDegreeAttribute.Value != "Required All") { throw new NotSupportedException(); } } string typeName = typeNameAttribute.Value; TypeDesc type = containingModule.GetTypeByCustomAttributeTypeName(typeName); rootProvider.AddCompilationRoot(type, "RD.XML root"); if (type.IsDefType) { foreach (var method in type.GetMethods()) { if (method.IsAbstract || method.HasInstantiation) { continue; } rootProvider.AddCompilationRoot(method, "RD.XML root"); } } }
private void ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, XElement typeElement) { var typeNameAttribute = typeElement.Attribute("Name"); if (typeNameAttribute == null) { throw new Exception(); } var dynamicDegreeAttribute = typeElement.Attribute("Dynamic"); if (dynamicDegreeAttribute != null) { if (dynamicDegreeAttribute.Value != "Required All") { throw new NotSupportedException(); } } string typeName = typeNameAttribute.Value; RootType(rootProvider, containingModule.GetTypeByCustomAttributeTypeName(typeName)); }
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 ProfileData GetDataForModuleDesc(ModuleDesc moduleDesc) { lock (_profileData) { if (_profileData.TryGetValue(moduleDesc, out ProfileData precomputedProfileData)) { return(precomputedProfileData); } } ProfileData computedProfileData = ComputeDataForModuleDesc(moduleDesc); lock (_profileData) { if (_profileData.TryGetValue(moduleDesc, out ProfileData precomputedProfileData)) { return(precomputedProfileData); } _profileData.Add(moduleDesc, computedProfileData); return(computedProfileData); } }