Exemplo n.º 1
0
        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))
            {
#if ECMA_METADATA_SUPPORT
                string result = EcmaMetadataFullName(qTypeDefinition);
                if (result != null)
                {
                    return(result);
                }
#endif

                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))
            {
                return(typeRefHandle.GetFullName(reader));
            }

            // Fallback implementation when no metadata available
            return(LowLevelToStringRawEETypeAddress(rtth));
        }
Exemplo n.º 2
0
        public static string LowLevelToString(this RuntimeTypeHandle rtth)
        {
            MetadataReader       reader;
            TypeDefinitionHandle typeDefHandle;
            TypeReferenceHandle  typeRefHandle;

            // Try to get the name from metadata
            if (TypeLoaderEnvironment.Instance.TryGetMetadataForNamedType(rtth, out reader, out typeDefHandle))
            {
                return(typeDefHandle.GetFullName(reader));
            }

            // Try to get the name from diagnostic metadata
            if (TypeLoaderEnvironment.TryGetTypeReferenceForNamedType(rtth, out reader, out typeRefHandle))
            {
                return(typeRefHandle.GetFullName(reader));
            }

            // Fallback implementation when no metadata available
            string prefix = "EEType:0x";

            StringBuilder sb  = new StringBuilder(prefix.Length + IntPtr.Size * 4);
            ulong         num = (ulong)rtth.ToIntPtr();

            int shift = IntPtr.Size * 8;

            while (shift > 0)
            {
                shift -= 4;
                int digit = (int)((num >> shift) & 0xF);
                sb.Append(HexDigits[digit]);
            }

            return(sb.ToString());
        }