Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7323824
[cdac] Rename TypeHandle to ITypeHandle
Jun 24, 2026
9fa9272
[cdac] Extract ITypeHandle interface with NullTypeHandle and TargetTy…
Jun 24, 2026
26d789e
Address review feedback: accessor name, Equals symmetry, comments, docs
Jul 14, 2026
c167ba6
Intern TargetTypeHandle instances per address in GetTypeHandle
Jul 14, 2026
ef3c912
Use an expression-bodied static property for ITypeHandle.Null
Jul 14, 2026
8bd863c
Use canonical reference identity for ITypeHandle
Jul 14, 2026
cfa662b
Address remaining PR review feedback
Jul 15, 2026
5650fcc
Clarify runtime TypeHandle terminology and simplify ITypeHandle usage
Jul 15, 2026
049c58c
Preserve span APIs and flush cached type handles
Jul 15, 2026
e83472f
Address latest ITypeHandle review feedback
Jul 15, 2026
bd8e420
Use TargetPointer.Null in type handle helpers
Jul 15, 2026
849cc33
Remove unused ImmutableArray import
Jul 15, 2026
b620b5e
Preserve default ArgumentLocation handle semantics without a constructor
Jul 15, 2026
fcb4ce8
Simplify ArgumentLocation and use explicit types
Jul 16, 2026
8f8f9b0
Default ArgumentLocation handles to the null sentinel
Jul 16, 2026
a72c613
Fix typo in RuntimeTypeSystem comment
Jul 16, 2026
2e2d66c
Clarify runtime TypeHandle signature encoding
Jul 20, 2026
b67eb50
Clarify ITypeHandle null sentinel documentation
Jul 20, 2026
6e7f483
Update docs/design/datacontracts/Signature.md
max-charlamb Jul 21, 2026
20b1574
Apply suggestions from code review
max-charlamb Jul 21, 2026
f9066d9
Use nullable references for absent ITypeHandle values
Jul 21, 2026
11ef228
Clarify ITypeHandle identity lifetime and nullable docs
Jul 21, 2026
4ea8f52
Align ManagedTypeSource docs with nullable outputs
Jul 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions docs/design/datacontracts/ManagedTypeSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ bool TryGetTypeInfo(string fullyQualifiedName, out Target.TypeInfo info);
// Throws InvalidOperationException if the type cannot be resolved.
Target.TypeInfo GetTypeInfo(string fullyQualifiedName);

// Return true and populate `typeHandle` with the runtime TypeHandle for the type,
// Return true and populate `typeHandle` with the ITypeHandle for the runtime type,
// or false if the type cannot be resolved.
bool TryGetTypeHandle(string fullyQualifiedName, out TypeHandle typeHandle);
TypeHandle GetTypeHandle(string fullyQualifiedName);
bool TryGetTypeHandle(string fullyQualifiedName, [NotNullWhen(true)] out ITypeHandle? typeHandle);
ITypeHandle GetTypeHandle(string fullyQualifiedName);

// Return true and populate `address` with the address of the named static field,
// or false if the type / field cannot be resolved or its statics storage has not
Expand Down Expand Up @@ -68,7 +68,11 @@ they read in their own `### Managed types used` section.
``` csharp
// Type resolution: parse the fully-qualified name, walk System.Private.CoreLib's
// metadata to locate the TypeDef, then map TypeDef -> MethodTable via the loader.
bool TryResolveType(string managedFqName, out TypeHandle th, out MetadataReader mdReader, out TypeDefinition typeDef)
bool TryResolveType(
string managedFqName,
[NotNullWhen(true)] out ITypeHandle? th,
[NotNullWhen(true)] out MetadataReader? mdReader,
out TypeDefinition typeDef)
{
ILoader loader = target.Contracts.Loader;
TargetPointer systemAssembly = loader.GetSystemAssembly();
Expand Down Expand Up @@ -96,14 +100,14 @@ bool TryResolveType(string managedFqName, out TypeHandle th, out MetadataReader
return true;
}

bool TryGetTypeHandle(string fqn, out TypeHandle th)
bool TryGetTypeHandle(string fqn, [NotNullWhen(true)] out ITypeHandle? th)
{
return TryResolveType(fqn, out th, out _, out _);
}

bool TryGetTypeInfo(string fqn, out Target.TypeInfo info)
{
if (!TryResolveType(fqn, out TypeHandle th, out MetadataReader mdReader, out TypeDefinition typeDef))
if (!TryResolveType(fqn, out ITypeHandle? th, out MetadataReader? mdReader, out TypeDefinition typeDef))
return false;

IRuntimeTypeSystem rts = target.Contracts.RuntimeTypeSystem;
Expand Down Expand Up @@ -147,7 +151,7 @@ bool TryGetStaticFieldAddress(string fqn, string fieldName, out TargetPointer ad
// cannot dereference a small offset-from-zero when the class has not been
// initialized.
TargetPointer enclosingMT = rts.GetMTOfEnclosingClass(fdAddr);
TypeHandle ctx = rts.GetTypeHandle(enclosingMT);
ITypeHandle ctx = rts.GetTypeHandle(enclosingMT);
CorElementType et = rts.GetFieldDescType(fdAddr);
bool isGC = et is CorElementType.Class or CorElementType.ValueType;
TargetPointer @base = isGC
Expand All @@ -174,7 +178,7 @@ bool TryGetThreadStaticFieldAddress(string fqn, string fieldName, TargetPointer
// thread so callers cannot dereference a small offset-from-zero when this
// thread has not initialized thread-static storage for the type.
TargetPointer enclosingMT = rts.GetMTOfEnclosingClass(fdAddr);
TypeHandle ctx = rts.GetTypeHandle(enclosingMT);
ITypeHandle ctx = rts.GetTypeHandle(enclosingMT);
CorElementType et = rts.GetFieldDescType(fdAddr);
bool isGC = et is CorElementType.Class or CorElementType.ValueType;
TargetPointer @base = isGC
Expand All @@ -189,7 +193,7 @@ bool TryGetThreadStaticFieldAddress(string fqn, string fieldName, TargetPointer

bool TryGetFieldDesc(string fqn, string fieldName, out TargetPointer fdAddr)
{
if (!TryResolveType(fqn, out TypeHandle th, out _, out _))
if (!TryResolveType(fqn, out ITypeHandle th, out _, out _))
{
fdAddr = TargetPointer.Null;
return false;
Expand Down
4 changes: 2 additions & 2 deletions docs/design/datacontracts/RuntimeMutableTypeSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This contract exposes runtime type system information about changes that occurre
## APIs of contract

```csharp
IEnumerable<TargetPointer> EnumerateAddedFieldDescs(TypeHandle typeHandle, bool staticFields);
IEnumerable<TargetPointer> EnumerateAddedFieldDescs(ITypeHandle typeHandle, bool staticFields);
bool IsFieldDescEnCNew(TargetPointer fieldDescPointer);
bool DoesEnCFieldDescNeedFixup(TargetPointer encFieldDescPointer);
TargetPointer GetEnCStaticFieldDataAddress(TargetPointer encFieldDescPointer);
Expand Down Expand Up @@ -59,7 +59,7 @@ internal enum FieldDescFlags2 : uint
OffsetMask = 0x07ffffff,
}

IEnumerable<TargetPointer> EnumerateAddedFieldDescs(TypeHandle typeHandle, bool staticFields)
IEnumerable<TargetPointer> EnumerateAddedFieldDescs(ITypeHandle typeHandle, bool staticFields)
{
// get modulePtr and moduleHandle from typeHandle
// if there is no EnC data, yield break
Expand Down
Loading