diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index 7ab79c353fc7e8..7355b77b859971 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -594,7 +594,6 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) bool hasNonGcStatics = NodeFactory.MetadataManager.HasNonGcStaticBase(defType); bool hasGcStatics = NodeFactory.MetadataManager.HasGcStaticBase(defType); bool hasThreadStatics = NodeFactory.MetadataManager.HasThreadStaticBase(defType); - bool hasInstanceFields = defType.IsValueType || NodeFactory.MetadataManager.HasConstructedEEType(defType); bool isCanonical = defType.IsCanonicalSubtype(CanonicalFormKind.Any); @@ -622,8 +621,11 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) } else { - if (!hasInstanceFields) - continue; + // Allow instance fields to be emitted even for types that are never instantiated. + // This ensures DWARF debug info is generated for all type fields, which is + // important for debugging scenarios where types are referenced but not constructed. + // Previously, a guard would skip instance fields when hasInstanceFields was false, + // preventing debug info generation for types like: var nullObj = (MyClass)null; } LayoutInt fieldOffset = fieldDesc.Offset;