public override int GetTypeRefProps( int typeRef, [Out] int *resolutionScope, // ModuleRef or AssemblyRef [Out] char *qualifiedName, int qualifiedNameBufferLength, [Out] int *qualifiedNameLength) { if (!_metadataProvider.TryGetTypeReferenceInfo(typeRef, out var namespaceName, out var typeName)) { return(HResult.E_INVALIDARG); } if (qualifiedNameLength != null || qualifiedName != null) { InteropUtilities.CopyQualifiedTypeName( qualifiedName, qualifiedNameBufferLength, qualifiedNameLength, namespaceName, typeName); } if (resolutionScope != null) { // unused *resolutionScope = 0; } return(HResult.S_OK); }
public override int GetTypeDefProps( int typeDef, [Out] char *qualifiedName, int qualifiedNameBufferLength, [Out] int *qualifiedNameLength, [Out] TypeAttributes *attributes, [Out] int *baseType) { Debug.Assert(baseType == null); if (!_metadataProvider.TryGetTypeDefinitionInfo(typeDef, out var namespaceName, out var typeName, out var attrib)) { return(HResult.E_INVALIDARG); } if (qualifiedNameLength != null || qualifiedName != null) { InteropUtilities.CopyQualifiedTypeName( qualifiedName, qualifiedNameBufferLength, qualifiedNameLength, namespaceName, typeName); } if (attributes != null) { *attributes = attrib; } return(HResult.S_OK); }
int IMetadataImport.GetTypeRefProps( int typeRef, [Out] int *resolutionScope, // ModuleRef or AssemblyRef [Out] char *qualifiedName, int qualifiedNameBufferLength, [Out] int *qualifiedNameLength) { MetadataRequired(); var handle = (TypeReferenceHandle)MetadataTokens.Handle(typeRef); var typeReference = _metadataReaderOpt.GetTypeReference(handle); if (qualifiedNameLength != null || qualifiedName != null) { InteropUtilities.CopyQualifiedTypeName( qualifiedName, qualifiedNameLength, _metadataReaderOpt.GetString(typeReference.Namespace), _metadataReaderOpt.GetString(typeReference.Name)); } if (resolutionScope != null) { *resolutionScope = MetadataTokens.GetToken(typeReference.ResolutionScope); } return(HResult.S_OK); }
int IMetadataImport.GetTypeDefProps( int typeDef, [Out] char *qualifiedName, int qualifiedNameBufferLength, [Out] int *qualifiedNameLength, [Out] TypeAttributes *attributes, [Out] int *baseType) { MetadataRequired(); var handle = (TypeDefinitionHandle)MetadataTokens.Handle(typeDef); var typeDefinition = _metadataReaderOpt.GetTypeDefinition(handle); if (qualifiedNameLength != null || qualifiedName != null) { InteropUtilities.CopyQualifiedTypeName( qualifiedName, qualifiedNameLength, _metadataReaderOpt.GetString(typeDefinition.Namespace), _metadataReaderOpt.GetString(typeDefinition.Name)); } if (attributes != null) { *attributes = typeDefinition.Attributes; } if (baseType != null) { *baseType = MetadataTokens.GetToken(typeDefinition.BaseType); } return(HResult.S_OK); }
// The only purpose of this method is to get type name of the method and declaring type token (opaque for SymWriter), everything else is ignored by the SymWriter. // "mb" is the token passed to OpenMethod. The token is remembered until the corresponding CloseMethod, which passes it to GetMethodProps. // It's opaque for SymWriter. int IMetadataImport.GetMethodProps( int methodDef, [Out] int *declaringTypeDef, [Out] char *name, int nameBufferLength, [Out] int *nameLength, [Out] MethodAttributes *attributes, [Out] byte **signature, [Out] int *signatureLength, [Out] int *relativeVirtualAddress, [Out] MethodImplAttributes *implAttributes) { MetadataRequired(); Debug.Assert(attributes == null); Debug.Assert(signature == null); Debug.Assert(signatureLength == null); Debug.Assert(relativeVirtualAddress == null); Debug.Assert(implAttributes == null); var handle = (MethodDefinitionHandle)MetadataTokens.Handle(methodDef); var methodDefinition = _metadataReaderOpt.GetMethodDefinition(handle); if (name != null || nameLength != null) { string nameStr = _metadataReaderOpt.GetString(methodDefinition.Name); // if the buffer is too small to fit the name, truncate the name. // -1 to account for a NUL terminator. int adjustedLength = Math.Min(nameStr.Length, nameBufferLength - 1); // return the length of the name not including NUL if (nameLength != null) { *nameLength = adjustedLength; } if (name != null) { InteropUtilities.StringCopy(name, nameStr, adjustedLength); } } if (declaringTypeDef != null) { *declaringTypeDef = MetadataTokens.GetToken(methodDefinition.GetDeclaringType()); } return(HResult.S_OK); }