Skip to content

Implement TypeHandle::GetName in managed cDAC - #131336

Merged
rcj1 merged 7 commits into
mainfrom
copilot/implement-typehandle-getname
Jul 25, 2026
Merged

rcj1 merged 7 commits into
mainfrom
copilot/implement-typehandle-getname

Conversation

Copilot AI commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds managed type-handle naming with output matching native TypeHandle::GetName.

  • Implementation

    • Formats MethodTables, TypeDescs, modifiers, generic variables, function pointers, instantiations, and arrays.
    • Reuses TypeNameBuilder generic-instantiation formatting.
  • Coverage

    • Adds cross-architecture parity tests for supported type shapes and array-rank behavior.

    We need this for example to implement ClrDataTypeInstance.GetName. This has some different behavior than the existing TypeNameBuilder - for example, function pointers are displayed as "FNPTR" instead of attempting to resolve further details.

Copilot AI review requested due to automatic review settings July 24, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI review requested due to automatic review settings July 24, 2026 19:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 1

Copilot AI review requested due to automatic review settings July 24, 2026 19:21
@rcj1
rcj1 requested review from max-charlamb and noahfalk July 24, 2026 19:26
@rcj1
rcj1 marked this pull request as ready for review July 24, 2026 19:26
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Comments suppressed due to low confidence (1)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs:250

  • Changing IRuntimeTypeSystem.IsGenericVariable to add an extra out parameter is a source/binary breaking change for any external consumers (the Abstractions project is packable). To preserve compatibility, keep the existing 3-out signature and add the new 4-out overload, with the 3-out overload delegating to the 4-out overload (discarding index).
    // return true if the ITypeHandle represents an array, and set the rank to either 0 (if the type is not an array), or the rank number if it is.
    bool IsArray(ITypeHandle typeHandle, out uint rank) => throw new NotImplementedException();
    ITypeHandle GetTypeParam(ITypeHandle typeHandle) => throw new NotImplementedException();
    ITypeHandle? GetConstructedType(ITypeHandle? typeHandle, CorElementType corElementType, int rank, ImmutableArray<ITypeHandle?> typeArguments, SignatureCallingConvention callConv = SignatureCallingConvention.Default) => throw new NotImplementedException();
    ITypeHandle GetPrimitiveType(CorElementType typeCode) => throw new NotImplementedException();
    bool IsGenericVariable(ITypeHandle typeHandle, out TargetPointer module, out uint token, out uint index) => throw new NotImplementedException();
    bool IsFunctionPointer(ITypeHandle typeHandle, out ReadOnlySpan<ITypeHandle> retAndArgTypes, out SignatureCallingConvention callConv) => throw new NotImplementedException();
  • Files reviewed: 13/13 changed files
  • Comments generated: 0 new

@davidwrighton davidwrighton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one change around function pointer handling. Also I'd like to see us file a bug to remove this name builder and just use the TypeNameBuilder. I know the semantics aren't quite the same, but once we stop testing against the legacy implementation of the DAC we should stop using this.

Copilot AI review requested due to automatic review settings July 24, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Comments suppressed due to low confidence (1)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs:250

  • Changing the IRuntimeTypeSystem.IsGenericVariable signature to add a new out uint index is a binary/source breaking change for any downstream consumers that implement or call this contract (the Abstractions project is IsPackable=true). If compatibility matters, keep the existing 3-parameter overload and add a new overload (or new method name) that provides index, with a default interface implementation delegating to the new API while discarding index.
    // return true if the ITypeHandle represents an array, and set the rank to either 0 (if the type is not an array), or the rank number if it is.
    bool IsArray(ITypeHandle typeHandle, out uint rank) => throw new NotImplementedException();
    ITypeHandle GetTypeParam(ITypeHandle typeHandle) => throw new NotImplementedException();
    ITypeHandle? GetConstructedType(ITypeHandle? typeHandle, CorElementType corElementType, int rank, ImmutableArray<ITypeHandle?> typeArguments, SignatureCallingConvention callConv = SignatureCallingConvention.Default) => throw new NotImplementedException();
    ITypeHandle GetPrimitiveType(CorElementType typeCode) => throw new NotImplementedException();
    bool IsGenericVariable(ITypeHandle typeHandle, out TargetPointer module, out uint token, out uint index) => throw new NotImplementedException();
    bool IsFunctionPointer(ITypeHandle typeHandle, out ReadOnlySpan<ITypeHandle> retAndArgTypes, out SignatureCallingConvention callConv) => throw new NotImplementedException();
  • Files reviewed: 13/13 changed files
  • Comments generated: 1

@rcj1
rcj1 enabled auto-merge (squash) July 24, 2026 22:02
@rcj1
rcj1 merged commit a6c4461 into main Jul 25, 2026
142 checks passed
@rcj1
rcj1 deleted the copilot/implement-typehandle-getname branch July 25, 2026 01:48
Copilot AI added a commit that referenced this pull request Jul 25, 2026
<!-- -->

Adds managed type-handle naming with output matching native
`TypeHandle::GetName`.

- **Implementation**
- Formats MethodTables, TypeDescs, modifiers, generic variables,
function pointers, instantiations, and arrays.
  - Reuses `TypeNameBuilder` generic-instantiation formatting.

- **Coverage**
- Adds cross-architecture parity tests for supported type shapes and
array-rank behavior.

We need this for example to implement ClrDataTypeInstance.GetName. This
has some different behavior than the existing TypeNameBuilder - for
example, function pointers are displayed as "FNPTR" instead of
attempting to resolve further details.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: rcj1 <[email protected]>
Co-authored-by: rcj1 <[email protected]>
hez2010 pushed a commit to hez2010/runtime that referenced this pull request Jul 26, 2026
<!-- -->

Adds managed type-handle naming with output matching native
`TypeHandle::GetName`.

- **Implementation**
- Formats MethodTables, TypeDescs, modifiers, generic variables,
function pointers, instantiations, and arrays.
  - Reuses `TypeNameBuilder` generic-instantiation formatting.

- **Coverage**
- Adds cross-architecture parity tests for supported type shapes and
array-rank behavior.
  
We need this for example to implement ClrDataTypeInstance.GetName. This
has some different behavior than the existing TypeNameBuilder - for
example, function pointers are displayed as "FNPTR" instead of
attempting to resolve further details.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: rcj1 <[email protected]>
Co-authored-by: rcj1 <[email protected]>
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 26, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants