internal virtual TypeReference ImportType(TypeReference type, ImportGenericContext context) { if (type.IsTypeSpecification()) { return(ImportTypeSpecification(type, context)); } var reference = new TypeReference( type.Namespace, type.Name, module, ImportScope(type.Scope), type.IsValueType); MetadataSystem.TryProcessPrimitiveTypeReference(reference); if (type.IsNested) { reference.DeclaringType = ImportType(type.DeclaringType, context); } if (type.HasGenericParameters) { ImportGenericParameters(reference, type); } return(reference); }
static TypeReference CreateReference(Type type_info, ModuleDefinition module, IMetadataScope scope) { string @namespace, name; SplitFullName(type_info.type_fullname, out @namespace, out name); var type = new TypeReference(@namespace, name, module, scope); MetadataSystem.TryProcessPrimitiveTypeReference(type); AdjustGenericParameters(type); var nested_names = type_info.nested_names; if (nested_names.IsNullOrEmpty()) { return(type); } for (int i = 0; i < nested_names.Length; i++) { type = new TypeReference(string.Empty, nested_names [i], module, null) { DeclaringType = type, }; AdjustGenericParameters(type); } return(type); }
public TypeReference ImportType(TypeReference type, Mono.Collections.Generic.Collection <IGenericParameterProvider> context) { if (type.IsTypeSpecification()) { return(ImportTypeSpecification(type, context)); } var reference = new TypeReference( type.Namespace, type.Name, module, ImportScope(type.Scope), type.IsValueType); MetadataSystem.TryProcessPrimitiveTypeReference(reference); if (type.IsNested) { reference.DeclaringType = ImportType(type.DeclaringType, context); } if (type.HasGenericParameters) { ImportGenericParameters(reference, type); } return(reference); }
private static TypeReference CreateReference(TypeParser.Type type_info, ModuleDefinition module, IMetadataScope scope) { string str; string str1; TypeParser.SplitFullName(type_info.type_fullname, out str, out str1); TypeReference typeReference = new TypeReference(str, str1, module, scope); MetadataSystem.TryProcessPrimitiveTypeReference(typeReference); TypeParser.AdjustGenericParameters(typeReference); string[] nestedNames = type_info.nested_names; if (nestedNames.IsNullOrEmpty <string>()) { return(typeReference); } for (int i = 0; i < (int)nestedNames.Length; i++) { typeReference = new TypeReference(string.Empty, nestedNames[i], module, null) { DeclaringType = typeReference }; TypeParser.AdjustGenericParameters(typeReference); } return(typeReference); }
TypeReference ImportType(TypeReference type, ImportGenericContext context) { if (type.IsTypeSpecification()) { return(ImportTypeSpecification(type, context)); } var reference = default(TypeReference); var key = TypeRefKey.From(type); if (cache.TryGetValue(key, out reference)) { // Cecil only fills TypeRef GenericParameters if used ( bug ?) // Now that we cache them, we need to make sure the cached version has all of the needed ones if (type.HasGenericParameters && reference.GenericParameters.Count != type.GenericParameters.Count) { for (int i = reference.GenericParameters.Count - 1; i < type.GenericParameters.Count; i++) { reference.GenericParameters.Add(new GenericParameter(reference)); } } return(reference); } reference = new TypeReference( type.Namespace, type.Name, module, ImportScope(type.Scope), type.IsValueType); MetadataSystem.TryProcessPrimitiveTypeReference(reference); if (type.IsNested) { reference.DeclaringType = ImportType(type.DeclaringType, context); } if (type.HasGenericParameters) { ImportGenericParameters(reference, type); } cache.Add(key, reference); return(reference); }
public TypeReference ImportType(TypeReference type, ImportGenericContext context) { if (type.IsTypeSpecification()) { return(this.ImportTypeSpecification(type, context)); } TypeReference typeReference = new TypeReference(type.Namespace, type.Name, this.module, this.ImportScope(type.Scope), type.IsValueType); MetadataSystem.TryProcessPrimitiveTypeReference(typeReference); if (type.IsNested) { typeReference.DeclaringType = this.ImportType(type.DeclaringType, context); } if (type.HasGenericParameters) { MetadataImporter.ImportGenericParameters(typeReference, type); } return(typeReference); }
private static TypeReference CreateReference(Type type_info, ModuleDefinition module, IMetadataScope scope) { string str; string str2; SplitFullName(type_info.type_fullname, out str, out str2); TypeReference type = new TypeReference(str, str2, module, scope); MetadataSystem.TryProcessPrimitiveTypeReference(type); AdjustGenericParameters(type); string[] self = type_info.nested_names; if (!self.IsNullOrEmpty <string>()) { for (int i = 0; i < self.Length; i++) { type = new TypeReference(string.Empty, self[i], module, null) { DeclaringType = type }; AdjustGenericParameters(type); } } return(type); }