[release/9.0-staging] Fix UnsafeAccessor scenario for modopts/modreqs when comparing field sigs. #111675
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.
Backport of #111648 to release/9.0-staging
Customer Impact
Consume custom modifiers and ByRef in RetType signature prior to comparing field signature. Specifically signatures have contain modopts/modreqs. This is follow-up for #109694, which was also a .NET 9 servicing for a regression, but missed a specific scenario involving
readonly
and was testing using aUnsafeAccessor
declaration that did not properly validate the scenario.Fixes #111647
Regression
Issue #109665 was fixed with #109694 and assumed to also address issues with
readonly
and so tests were added with in #109944 - these tests do pass.The issue is best showcased with the following:
The
MEMBER
andLOCAL
are the same definition, butMEMBER
uses anmodreq
whenLOCAL
doesn't. For testing, theLOCAL
scenario was used for validation and this created a false sense of correctness in the tests. The result is the modopt/modreq issues can still occur for fields depending on how theUnsafeAccessor
is defined. This means we need to service .NET 9 again, see #109709, and make the correct fix in .NET 10 along with updating the testing so we validate both types of definition.Testing
New tests have been added and the existing tests have been updated to cover this scenario.
Risk
Medium. This is likely "Low" from a regression standpoint, but increases the Risk since this is a second attempt at a fix. There is much more confidence in this fix after uncovering the metadata differences in signature declaration.