-
Notifications
You must be signed in to change notification settings - Fork 152
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
Incorrect hashcode caching in Entity #7
Comments
feel free to fork, apply the fix, and issue a pull request |
GetHashCode() uses the DomainSignature properties to calculate the HashCode(), "Since it is recommended that GetHashCode change infrequently, if at all, in an object's lifetime, it's important that properties are carefully selected which truly represent the signature of an object." I'm okay with it calling from a cache rather than calculating it each time, unless you had additional thoughts on the matter? |
Okay it has been a week with no response, please feel free to send me a note and I'll open this back up for discussion. |
The implemented version of GetHashCode() causes problems when used across sessions. For example, consider the following test: public void Test()
} This test can pass or it can fail. I can see why you have decided to cache the hashcode, but I find that it can be confusing and problematic. |
Entity caches the hash code on the first call to
GetHashCode()
. This is a bug because the properties from which the hashcode is calculated can change thus rendering the cached hashcode invalid and violation the combined contract ofEquals
andGetHashCode
.The text was updated successfully, but these errors were encountered: