[release/8.0-staging] Fix HashSet copy constructor handling of instances that have fallen back to the randomized hashcode generator. (#107613) #107687
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 #107613 to release/8.0-staging
/cc @eiriktsarpalis
Customer Impact
Fixes a customer reported issue where passing a
HashSet<string>
that has fallen back to randomized string comparison will result in a corrupted set being created.Regression
Likely introduced in .NET 5 via #37180 which brought in non-randomized string comparison.
Testing
Added unit testing validating that the copy constructor works as expected.
Risk
Moderate. While this is a targeted fix,
HashSet<T>
is a very common core type so any change carries an elevated degree of risk.