in src/Microsoft.Diagnostics.Runtime/Implementation/ClrTypeFactory.cs [109:144]
public ClrType? GetOrCreateType(ulong mt, ulong obj)
{
if (mt == 0)
return null;
// Remove marking bit.
mt &= ~1ul;
ClrType? existing = TryGetType(mt);
if (existing != null)
{
if (obj != 0 && !existing.IsString && existing.ComponentSize != 0 && existing.ComponentType is null && existing is ClrDacType type)
type.SetComponentType(TryGetComponentType(obj));
return existing;
}
if (!_typeHelpers.GetTypeInfo(mt, out TypeInfo mtd))
return null;
ClrType? baseType = GetOrCreateType(mtd.ParentMethodTable, 0);
ClrModule module = GetModule(mtd.ModuleAddress);
ClrType? componentType = null;
if (obj != 0 && mtd.ComponentSize != 0)
componentType = TryGetComponentType(obj);
ClrType result = new ClrDacType(_typeHelpers, _heap, baseType, componentType, module, mtd);
if (_options.CacheTypes)
{
lock (_types)
_types[mt] = result;
}
return result;
}