Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Implement Assembly.GetCallingAssembly for native AOT - #129963

#129963
Merged
MichalStrehovsky merged 4 commits into
dotnet:maindotnet/runtime:mainfrom
MichalStrehovsky:port-getcallingasmMichalStrehovsky/runtime:port-getcallingasmCopy head branch name to clipboard
Jun 29, 2026
Merged

Implement Assembly.GetCallingAssembly for native AOT#129963
MichalStrehovsky merged 4 commits into
dotnet:maindotnet/runtime:mainfrom
MichalStrehovsky:port-getcallingasmMichalStrehovsky/runtime:port-getcallingasmCopy head branch name to clipboard

Conversation

@MichalStrehovsky

@MichalStrehovsky MichalStrehovsky commented Jun 29, 2026

Copy link
Copy Markdown
Member
  • Use stack trace data to find the calling assembly.
  • It is therefore only supportable if stack trace data is available. Block for the same reason under F5 debugging (CoreCLR). This is why it's a breaking change.
  • Maintain an arbitrary list of methods to skip in stacktraces to make calling this API work in a .cctor. Matches similar arbitrary list in CoreCLR to the extent that is covered by tests.
  • canTailCall is now same between ILC and crossgen2.

Fixes dotnet#129961

* Use stack trace data to find the calling assembly.
* It is therefore only supportable if stack trace data is available. Block for the same reason under F5 debugging (CoreCLR). This is why it's a breaking change.
* Maintain an arbitrary list of methods to skip in stacktraces to make calling this API work in a .cctor. Matches similar arbitrary list in CoreCLR to the extent that is covered by tests.
* `canTailCall` is now same between ILC and crossgen2.
Copilot AI review requested due to automatic review settings June 29, 2026 03:28
@MichalStrehovsky MichalStrehovsky added the breaking-change Issue or PR that represents a breaking API or functional change over a previous release. label Jun 29, 2026
@dotnet-policy-service dotnet-policy-service Bot added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Jun 29, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
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.

Pull request overview

Enables Assembly.GetCallingAssembly() on NativeAOT by deriving the calling assembly from stack-trace metadata, and updates the toolchain/JIT interface to keep tailcall behavior consistent across ILC and crossgen2. The PR also re-enables/extends relevant reflection tests now that NativeAOT support is present.

Changes:

  • Implement Assembly.GetCallingAssembly() for NativeAOT using StackFrame + DiagnosticMethodInfo when stack traces are supported.
  • Gate GetCallingAssembly() on StackTrace.IsSupported (CoreCLR + NativeAOT) with a new resource string for the error.
  • Unify canTailCall handling by moving logic into the common JIT interface implementation and adjust tests accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Assembly.NativeAot.cs Adds NativeAOT implementation of GetCallingAssembly() via stack walking and method info extraction.
src/coreclr/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs Adds a StackTrace.IsSupported gate before CoreCLR’s existing stack-crawl-based implementation.
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx Adds a new resource string for the “stack trace support disabled” error path.
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Centralizes canTailCall logic and adjusts method attribute reporting for RequireSecObject.
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs Removes duplicate canTailCall implementation in favor of the common version.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs Removes duplicate canTailCall implementation in favor of the common version.
src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyTests.cs Re-enables NativeAOT coverage and adds a delegate-based GetCallingAssembly test.
src/libraries/System.Runtime/tests/System.Reflection.Tests/MethodInfoTests.cs Re-enables the aggressive-inlining callstack test on NativeAOT by removing an ActiveIssue skip.
src/libraries/System.Runtime/tests/System.Reflection.Tests/TestAssembly/ClassToInvoke.cs Adds a helper method to invoke a delegate from a separate assembly for test coverage.

Comment thread src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 03:47
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 03:57
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g new test added in #126124 is failing. will need disabling I guess, going to look at it next.

@MichalStrehovsky
MichalStrehovsky merged commit b6b7e33 into dotnet:main Jun 29, 2026
153 of 172 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the port-getcallingasm branch June 29, 2026 21:17
@github-actions

Copy link
Copy Markdown
Contributor

Caution

Security scanning requires review for Breaking Change Documentation

Details

The threat detection results could not be parsed. The workflow output should be reviewed before merging.

Review the workflow run logs for details.

Breaking Change Documentation

A breaking change draft has been prepared for this PR.

👉 Click here to create the issue in dotnet/docs

After creating the issue, please email a link to it to
[.NET Breaking Change Notifications]((redacted)

/cc @MichalStrehovsky

Note

This documentation was generated with AI assistance from Copilot.

Generated by Breaking Change Documentation for issue #129963 · ● 1.8M ·

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 30, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
* Use stack trace data to find the calling assembly.
* It is therefore only supportable if stack trace data is available.
Block for the same reason under F5 debugging (CoreCLR). This is why it's
a breaking change.
* Maintain an arbitrary list of methods to skip in stacktraces to make
calling this API work in a .cctor. Matches similar arbitrary list in
CoreCLR to the extent that is covered by tests.
* `canTailCall` is now same between ILC and crossgen2.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-NativeAOT-coreclr breaking-change Issue or PR that represents a breaking API or functional change over a previous release. needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.