This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
Fixing HashCode Seed Initialization on BCL package #43004
Merged
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 dotnet/runtime#42808
Fixing seed initialization on Microsoft.Bcl.Hashcode to match netcoreapp behavior. Also provided a quirk in case people consuming the BCL package want to fall back to the non-randomized version.
cc: @stephentoub @bartonjs @ericstj @fabricefou @Anipik
Customer Impact
NetStandard implementation of GetRandomBytes has a bug which causes it to always return 0. This is used by HashCode when generating its internal seed used for generating hashes, which causes the user to get non-random hashes when consuming the Microsoft.Bcl.HashCode package in netstandard.
Testing
We added test coverage as part of this PR to ensure that a) Customers behavior will now be the same in netcoreapp and netfx and b) we added an AppContext switch so that folks can fall back to wrong behavior if they depended on non-randomized hashes.
Regression?
No. This package has had the incorrect behavior since we initially shipped it.
Risk
Low. It may break customers that depended on the wrong behavior, but for such cases we provided an AppContext switch that they can decide to turn on if necessary.