private static void AppendType(TypeReference type, StringBuilder name, bool fq_name, bool top_level) { TypeReference declaringType = type.DeclaringType; if (declaringType != null) { TypeParser.AppendType(declaringType, name, false, top_level); name.Append('+'); } string @namespace = type.Namespace; if (!string.IsNullOrEmpty(@namespace)) { TypeParser.AppendNamePart(@namespace, name); name.Append('.'); } TypeParser.AppendNamePart(type.GetElementType().Name, name); if (!fq_name) { return; } if (type.IsTypeSpecification()) { TypeParser.AppendTypeSpecification((TypeSpecification)type, name); } if (TypeParser.RequiresFullyQualifiedName(type, top_level)) { name.Append(", "); name.Append(TypeParser.GetScopeFullName(type)); } }
private 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 bool AreSame(TypeReference a, TypeReference b) { if (object.ReferenceEquals(a, b)) { return(true); } if (a == null || b == null) { return(false); } if (a.etype != b.etype) { return(false); } if (a.IsGenericParameter) { return(MetadataResolver.AreSame((GenericParameter)a, (GenericParameter)b)); } if (a.IsTypeSpecification()) { return(MetadataResolver.AreSame((TypeSpecification)a, (TypeSpecification)b)); } return(!(a.Name != b.Name) && !(a.Namespace != b.Namespace) && MetadataResolver.AreSame(a.DeclaringType, b.DeclaringType)); }