-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Options Source Gen Fixes #91363
Options Source Gen Fixes #91363
Conversation
Tagging subscribers to this area: @dotnet/area-extensions-options Issue DetailsPlanning to port these fixes to rc2 The changes in this PR fix the following issues:
|
/// <summary> | ||
/// Returns a non-randomized hash code for the given string. | ||
/// We always return a positive value. | ||
/// </summary> | ||
internal static int GetNonRandomizedHashCode(string s) | ||
{ | ||
uint result = 2166136261u; | ||
foreach (char c in s) | ||
{ | ||
result = (c ^ result) * 16777619; | ||
} | ||
return Math.Abs((int)result); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to consider using SHA256 here instead of FNV-1a. I think that's what the compiler itself uses when it needs uniqueness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After offline discussion, we decided to stick with FNV-1a
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thanks.
Failing tests tracked by #91410 |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6043270790 |
Planning to port these fixes to rc2
The changes in this PR fix the following issues:
Random
in the source generator and instead use the module name hash. Options source generator shouldn't use random names #90990!
when callingValidator.TryValidateValue
IEnumerable<T>
and tagged with the attributeValidateEnumeratedItems