Fix MethodBase.GetCurrentMethod with runtime async#122710
Merged
eduardo-vp merged 3 commits intodotnet:mainfrom Dec 23, 2025
Merged
Fix MethodBase.GetCurrentMethod with runtime async#122710eduardo-vp merged 3 commits intodotnet:mainfrom
eduardo-vp merged 3 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix an issue where MethodBase.GetCurrentMethod() fails when called from within an async method in Native AOT compilation. The fix adds logic to handle async methods by unwrapping async method variants to get the original method definition before creating the reflection thunk.
Key Changes
- Adds async method handling in the
ExpandIntrinsicForCallsitemethod forMethodBase.GetCurrentMethod()intrinsic expansion - When the callsite is an async method, the code attempts to get the target of the async variant method before generating the thunk
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Member
MichalStrehovsky
left a comment
There was a problem hiding this comment.
We also need a test. Conveniently, a test already exists, we just need to remove ActiveIssue (the issue number is wrong):
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs
Outdated
Show resolved
Hide resolved
MichalStrehovsky
approved these changes
Dec 23, 2025
This was referenced Jan 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #122546.
The following code can now be Native AOT compiled and run with runtime-async enabled.