diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/LowLevelStringConverter.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/LowLevelStringConverter.cs index f03ac5101a045..ce7111657e862 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/LowLevelStringConverter.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/LowLevelStringConverter.cs @@ -117,8 +117,17 @@ public static string LowLevelToString(this IntPtr arg) public static string LowLevelToString(this RuntimeTypeHandle rtth) { TypeReferenceHandle typeRefHandle; + QTypeDefinition qTypeDefinition; MetadataReader reader; + // Try to get the name from metadata + if (TypeLoaderEnvironment.Instance.TryGetMetadataForNamedType(rtth, out qTypeDefinition)) + { + reader = qTypeDefinition.NativeFormatReader; + TypeDefinitionHandle typeDefHandle = qTypeDefinition.NativeFormatHandle; + return typeDefHandle.GetFullName(reader); + } + // Try to get the name from diagnostic metadata if (TypeLoaderEnvironment.TryGetTypeReferenceForNamedType(rtth, out reader, out typeRefHandle)) {