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

Introduce intrinsic stable hash function Fixes #4986 #5723

Merged
merged 4 commits into from
Oct 2, 2020

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Sep 8, 2020

Fixes #4986 by introducing a new, stable hash function. Takes the safe route of not overwriting the previous hash function.

This method hashes a string without taking target framework or bitness into account. Fixes dotnet#4986
@cdmihai
Copy link
Contributor

cdmihai commented Sep 10, 2020

Copy link
Member

@benvillalobos benvillalobos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines 3618 to 3626
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cat1s'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cat1z'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('bat1s'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cut1s'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cat1so'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cats1'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('acat1s'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cat12s'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance),
(int)expander.ExpandPropertiesLeaveTypedAndEscaped("$([MSBuild]::StableStringHash('cat1s'))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Perhaps you could create an array with just the strings to hash ("cat1s", "cat1z", ...) to eliminate code/text duplication.

@Forgind Forgind merged commit 295bf2e into dotnet:master Oct 2, 2020
@Forgind Forgind deleted the stable-hash branch October 2, 2020 22:10
sujitnayak pushed a commit to NikolaMilosavljevic/msbuild that referenced this pull request Oct 12, 2020
Add StableStringHash method

This method hashes a string without taking target framework or bitness into account. Fixes dotnet#4986

Test StableStringHash
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.

Add property function GetStableHash for String
5 participants