-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix MethodBase.GetCurrentMethod with runtime async #122710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix MethodBase.GetCurrentMethod with runtime async #122710
Conversation
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <175728472+Copilot@users.noreply.github.com>
MichalStrehovsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need a test. Conveniently, a test already exists, we just need to remove ActiveIssue (the issue number is wrong):
| [ActiveIssue("https://github.com/dotnet/runtime/issues/122517", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] |
Fixes #122546.
The following code can now be Native AOT compiled and run with runtime-async enabled.