Skip to content

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 requested a review from ladipro March 14, 2024 13:40
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