-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix up reflection with runtime async #121576
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
Conversation
The reflection-simple test passes with this fix. The general reflection just falls out naturally. The only thing needed fixing was blocking direct invocation of `AsyncExplicitImpl` methods. We just block this when generating reflection mapping tables. We could also block this within the runtime reflection stack so that we can match the exception type, but given this is only reachable for CoreLib privates, it's really not worth the extra code.
|
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 fixes reflection support for runtime async methods by blocking direct invocation of AsyncExplicitImpl methods (non-Task-returning async methods with special calling conventions). The fix adds validation in the AOT compiler's metadata manager and updates tests to account for platform-specific exception behavior.
Key Changes
- Added validation logic to prevent reflection invocation of async methods with non-standard calling conventions
- Updated test expectations to handle different exception types between NativeAOT and other runtimes
- Gated reflection emit test with appropriate conditional attribute
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tests/async/reflection/reflection-simple.csproj | Added TestLibrary project reference to support platform detection utilities |
| src/tests/async/reflection/reflection-simple.cs | Updated tests to handle NativeAOT-specific exception behavior and gated TypeBuilder test with reflection emit support check |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs | Added validation to exclude non-Task-returning async methods and async variants from reflection invocation mapping tables |
|
|
/ba-g known timeouts |
The reflection-simple test passes with this fix (when I remove
<Optimize>True</Optimize>). The general reflection just falls out naturally. The only thing needed fixing was blocking direct invocation ofAsyncExplicitImplmethods.We just block this when generating reflection mapping tables. We could also block this within the runtime reflection stack so that we can match the exception type, but given this is only reachable for CoreLib privates, it's really not worth the extra code.
Cc @dotnet/ilc-contrib