public TypeReference ImportType(TypeReference type, IGenericContext context) { if (type.IsTypeSpecification()) { return(ImportTypeSpecification(type, context)); } var reference = new TypeReference( type.Namespace, type.Name, module, ImportScope(type.Scope), type.IsValueType); MetadataSystem.TryProcessPrimitiveType(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.TryProcessPrimitiveType(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); }