// The only purpose of this method is to get type name and "is nested" flag, everything else is ignored by the SymWriter. // "td" is token returned by GetMethodProps or GetNestedClassProps unsafe uint IMetaDataImport.GetTypeDefProps(uint td, IntPtr stringTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags) { pchTypeDef = 0; if (td == 0) { return(0); } // The typeDef name should be fully qualified ITypeDefinition t = _writer.GetTypeDefinition(td); string typeDefName; if (_lastTypeDef == td) { typeDefName = _lastTypeDefName; } else { typeDefName = MetadataWriter.GetMangledName((INamedTypeReference)t); INamespaceTypeDefinition namespaceTypeDef; if ((namespaceTypeDef = t.AsNamespaceTypeDefinition(_writer.Context)) != null) { typeDefName = CodeAnalysis.MetadataHelpers.BuildQualifiedName(namespaceTypeDef.NamespaceName, typeDefName); } _lastTypeDef = td; _lastTypeDefName = typeDefName; } pchTypeDef = (uint)typeDefName.Length; if (pchTypeDef >= cchTypeDef) { pchTypeDef = cchTypeDef - 1; } char *pointerTypeDef = (char *)stringTypeDef.ToPointer(); for (int i = 0; i < pchTypeDef; i++) { *(pointerTypeDef + i) = typeDefName[i]; } *(pointerTypeDef + pchTypeDef) = (char)0; uint *pointerFlags = (uint *)pdwTypeDefFlags.ToPointer(); *pointerFlags = (uint)_writer.GetTypeAttributes(t.GetResolvedType(_writer.Context)); return(0); }
public bool TryGetTypeDefinitionInfo( int typeDefinitionToken, out string namespaceName, out string typeName, out TypeAttributes attributes ) { if (typeDefinitionToken == 0) { namespaceName = null; typeName = null; attributes = 0; return(false); } // The typeDef name should be fully qualified ITypeDefinition t = _writer.GetTypeDefinition(typeDefinitionToken); if (_lastTypeDef == typeDefinitionToken) { typeName = _lastTypeDefName; namespaceName = _lastTypeDefNamespace; } else { typeName = MetadataWriter.GetMangledName((INamedTypeReference)t); INamespaceTypeDefinition namespaceTypeDef; if ((namespaceTypeDef = t.AsNamespaceTypeDefinition(_writer.Context)) != null) { namespaceName = namespaceTypeDef.NamespaceName; } else { namespaceName = null; } _lastTypeDef = typeDefinitionToken; _lastTypeDefName = typeName; _lastTypeDefNamespace = namespaceName; } attributes = _writer.GetTypeAttributes(t.GetResolvedType(_writer.Context)); return(true); }