Skip to content
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

Reintroduce FNV hashing #9860

Merged
merged 7 commits into from
Mar 18, 2024

Conversation

JanKrivanek
Copy link
Member

Fixes: #7131

Context

Contains changes from:

  • Reintroduce FNV hashing #9721
  • Last 2 commits is playing it save by putting the calling behind the changewave + preventing inlining - so that when opted out (from 17_10 ChangeWave), the new method body would not be loaded - and hence new StringTools functions would not be JITted. This way opting out of changewave can save anyone who is combining old version of StringTools with new version of Microsoft.Build

Usage

<!-- Works unchanged. Identical to [MSBuild]::StableStringHash($x, 'Legacy') -->
[MSBuild]::StableStringHash($x)

<!-- 
  $hashAlgo will currently allow:
    'Legacy' - the legacy behavior (mimicking string.GetHashCode)
    'Fnv1a32bit' - Fawler-Noll-Vo 1a 32bit
    'Fnv1a32bitFast' - Custom, faster, Fawler-Noll-Vo 1a 32bit
    'Fnv1a64bit' - Fawler-Noll-Vo 1a 64bit
    'Fnv1a64bitFast' -  Custom, faster, Fawler-Noll-Vo 1a 64bit
    'Sha256' - hex string of the Sha256 hash of the given string
-->
[MSBuild]::StableStringHash($x, $hashAlgo)

Testing

  • Existing test on colissions extended for all overloads
  • Added test on expected output types

Documentation

https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2022#msbuild-stablestringhash

@JanKrivanek JanKrivanek enabled auto-merge (squash) March 18, 2024 12:51
@JanKrivanek JanKrivanek merged commit 55777e8 into dotnet:main Mar 18, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The property function StableStringHash is relatively weak on some input
3 participants