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

Hash cleanup in C# #2120

Merged
merged 3 commits into from
May 7, 2024
Merged

Conversation

bernardnormier
Copy link
Member

This PR simplifies the implementation of GetHashCode in C# by using the BCL HashCode. It also removes all hash code caching.

@bernardnormier bernardnormier requested review from pepone and externl May 6, 2024 18:58
Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines +2907 to +2908
_out << nl << "var hash = new global::System.HashCode();";
assert(dataMembers.size() > 0); // a Slice struct must have at least one field.
Copy link
Member

Choose a reason for hiding this comment

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

This is because we're using the defaults for classes and exceptions.

return hashValue_;
}
}
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), _adapterId);
Copy link
Member Author

Choose a reason for hiding this comment

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

We should include the endpoints in this hash.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Also added test.

@bernardnormier bernardnormier marked this pull request as draft May 7, 2024 02:45
@bernardnormier bernardnormier marked this pull request as ready for review May 7, 2024 14:32
@bernardnormier bernardnormier merged commit 74efb4d into zeroc-ice:main May 7, 2024
16 checks passed
@bernardnormier bernardnormier deleted the hash-cleanup branch May 10, 2024 23:44
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
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.

3 participants