Skip to content

Feat: Prowlhash test suite #179

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

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

brmassa
Copy link
Contributor

@brmassa brmassa commented Sep 18, 2024

Prowlhash

  • Code optimization to avoid repetition (prone to errors)
  • Prowlhash Seed can be manually set
  • replace GetHashCode for a stable hash generator because GetHashCode is unpredictable on each run, Os and archteture.
  • 20+ unit tests to ensure it's quality

dependent on #177

@michaelsakharov
Copy link
Contributor

Could you explain the StableHash a bit more?
Does this not expect values to always be strings, and how does it handle class references?
GetHashCode is nice since two classes that are different instances return different HashCodes unless they override the function.

@brmassa
Copy link
Contributor Author

brmassa commented Sep 18, 2024

GetHashCode: The default GetHashCode method in .NET can produce different hash codes for the same object in different runs of the application. This is because the default implementation may use the object's memory address, which can/will change between runs.

StableHash: The StableHash method aims to produce the same hash code for the same object across different runs. This is achieved by using a deterministic seed and by hashing the object's state rather than its memory address

@michaelsakharov
Copy link
Contributor

michaelsakharov commented Sep 19, 2024

If im not mistaken StableHash works by the objects ability to convert to string?
What about like classes that don't implement ToString()? It would fallback to the Type name and all instances would receive the same hash? And what if the implementation of ToString() isn't reliable for object's state?

Im not entirely against this it does make sense to have a stable option, just curious how this method behaves compared to the default GetHashCode.
If that is the case it might be nice to support both, like GetHashCode(bool deterministic) or something, as I can see a few cases where just GetHashCode might be nice to have for having a unique "hash" per instance of a class (the memory address).

@michaelsakharov
Copy link
Contributor

Also if you don't mind me asking whats your original reasoning/intention for having a deterministic hashcode?

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.

2 participants