-
Couldn't load subscription status.
- Fork 5.2k
[release/9.0-staging] UnsafeAccessor - ambiguous name and signature match
#120011
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
[release/9.0-staging] UnsafeAccessor - ambiguous name and signature match
#120011
Conversation
Handle the case where there is an ambiguous name and signature match, but one is generic and the other isn't.
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 an issue with UnsafeAccessor where it couldn't properly differentiate between ambiguous method signatures that have the same calling convention but different generic parameter counts. The fix ensures that both generic and non-generic methods with the same name can be properly distinguished.
Key changes:
- Added proper generic parameter count validation in signature matching
- Enhanced test coverage to verify ambiguous method name resolution with generics
- Updated existing test cases to use more descriptive naming
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/tests/baseservices/compilerservices/UnsafeAccessors/UnsafeAccessorsTests.Generics.cs | Added comprehensive test cases for ambiguous method names and updated existing tests with clearer naming |
| src/coreclr/vm/prestub.cpp | Fixed signature matching logic to properly handle generic calling conventions and parameter counts |
| src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs | Added generic parameter count validation in method signature matching |
|
Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices |
|
This fix will make the following code throw I am not sure whether it meets the servicing bar. If there is a code out there that implemented a workaround for this corner-case bug by catching |
I think this is fine and the correct exception in this case. |
|
/ba-g timeouts |
d8b00b9
into
dotnet:release/9.0-staging
Backport of #119972 to release/9.0-staging
/cc @AaronRobinsonMSFT
Customer Impact
The
UnsafeAccessorAttributedoesn't properly differentiate ambiguity for between the two signatures below. Both arevoid(*)(void)and in that case the generic calling convention isn't used to indicate distinct signatures.Customer reported in #119875.
Regression
This is regression from .NET 8 because we didn't support generics method with
UnsafeAccessorAttribute. When it was added in .NET 9, a test case was missed. A new test was added to validate this scenario.Testing
A test was added.
Risk
Low.