Skip to content

[cDAC] Implement GetMethodDefinitionByToken in ClrDataModule#127091

Open
max-charlamb wants to merge 2 commits intodotnet:mainfrom
max-charlamb:dev/max-charlamb/cdac-getmethoddefbytoken
Open

[cDAC] Implement GetMethodDefinitionByToken in ClrDataModule#127091
max-charlamb wants to merge 2 commits intodotnet:mainfrom
max-charlamb:dev/max-charlamb/cdac-getmethoddefbytoken

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

Note

This PR was generated with the assistance of GitHub Copilot.

Summary

Implement IXCLRDataModule.GetMethodDefinitionByToken in the cDAC ClrDataModule wrapper instead of delegating entirely to the legacy DAC.

Changes

ClrDataModule.cs — Replaced the one-line legacy delegation stub with a full cDAC implementation that:

  1. Calls the legacy implementation first (if available) for DEBUG parity validation
  2. Validates the token is an mdtMethodDef (throws ArgumentExceptionE_INVALIDARG)
  3. Creates a ClrDataMethodDefinition with the token, module address, and legacy method definition
  4. Includes #if DEBUG ValidateHResult check against the legacy result

Pattern

Follows the same pattern used by EnumMethodDefinitionByName (line 302) which already creates ClrDataMethodDefinition objects in the same way.

The C++ legacy implementation (task.cpp:2215-2251) validates the token type, then calls ClrDataMethodDefinition::NewFromModule which simply creates a ClrDataMethodDefinition — the cDAC version mirrors this behavior.

Motivation

This enables removing GetMethodDefinitionByToken from the cDAC no-fallback allowlist in #126752.

@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements IXCLRDataModule.GetMethodDefinitionByToken in the managed cDAC ClrDataModule wrapper so it no longer relies solely on legacy DAC delegation, enabling progress toward stricter “no legacy fallback” coverage.

Changes:

  • Replace the legacy-only delegation stub with a cDAC implementation that validates the token type and constructs a ClrDataMethodDefinition.
  • When a legacy module is available, also invokes the legacy method to capture its result for DEBUG HRESULT parity validation.

Max Charlamb and others added 2 commits April 17, 2026 17:31
Implement IXCLRDataModule.GetMethodDefinitionByToken in the cDAC
ClrDataModule wrapper instead of delegating entirely to the legacy DAC.

The implementation validates the token is an mdtMethodDef, retrieves
the legacy method definition for DEBUG parity validation, and creates
a ClrDataMethodDefinition with the token and module address.

This follows the same pattern used by EnumMethodDefinitionByName and
enables removing GetMethodDefinitionByToken from the cDAC no-fallback
allowlist.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Now that GetMethodDefinitionByToken is implemented in the cDAC, it no
longer needs to be in the LegacyFallbackHelper allowlist.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@max-charlamb max-charlamb force-pushed the dev/max-charlamb/cdac-getmethoddefbytoken branch from fb386ce to e67c1fb Compare April 17, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants