[release/8.0-staging] Handle open types to appear in interface maps #98182
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 Issue #97667 and #97807
main PR PR #97733
Description
When an application uses the curiously recurring generics pattern in combination with a base generic type which is constrained over that pattern, the .NET 8.0 runtime will fail with a constraint checking exception. (There is also a small reflection visible impact)
Customer Impact
Customer applications which worked in .NET 7 and below are unable to be ported to .NET 8,
Regression
Yes, this is a regression in .NET 8. In .NET 7, the problematic type loading behavior was introduced with an issue that masked this issue, in .NET 8 it was 'fixed' (#PR 78619). Now that constraints are being properly checked it exposed that the runtime was failing on valid applications.
Testing
2 customer repro cases, which were independently reported in the span of a week have been verified to work with this fix. In addition, the fix contains an update to a test case we already had to verify the behavior.
Risk
Fairly low. It only changes the behavior of the runtime in a very targeted way.
Package authoring signed off?
N/A, this code does not affect code which ships in a NuGet package