Open SeanFarrow-RSK opened 1 year ago
allow a member to be compared using delegates for both the equality comparison and the hashcode creation.
What is your use case?
Earlier versions of this library (specifically v1-v4) did have those comparer types. They were deliberately removed because they enable incorrect comparers too easily - having two delegates, no matter how close together, lets them easily get out of sync. The builder API generates comparers where the hash code always has the correct semantics without users having to think about it.
So, v5 of this library removed the delegate-based comparers. I believe the current builder functionality covers any realistic use case. But if you have a use case not already covered by this library, I'd love to hear it!
I’m currently trying to compare two Roslyn SyntaxTree classes as part of an EqualityComparer I’m generating via the builder.
This class does not override Equals or GetHashCode, instead you are required to call the IsEquivalentTo method which returns true/false as expected.
I’m not sure how to integrate this, given the way the builder works and generates the hashcode.
We are the first IdentityServer partner to become a Certified B Corporation™. Head to our mission statement to read more about the ways we’re using business as a force for good. Rock Solid Knowledge Ltd is a company registered in England and Wales under number 6811209. Registered office: C2, Vantage Office Park, Old Gloucester Road, Bristol, BS16 1GW, United Kingdom Vat registered: GB948 1966 72 From: Stephen Cleary @.> Sent: Thursday, July 20, 2023 8:04 PM To: StephenCleary/Comparers @.> Cc: Sean Farrow @.>; Author @.> Subject: Re: [StephenCleary/Comparers] Provide the ability to take a compare an item using delegates (Issue #39)
allow a member to be compared using delegates for both the equality comparison and the hashcode creation.
What is your use case?
Earlier versions of this library (specifically v1-v4) did have those comparer types. They were deliberately removed because they enable incorrect comparers too easily - having two delegates, no matter how close together, lets them easily get out of sync. The builder API generates comparers where the hash code always has the correct semantics without users having to think about it.
So, v5 of this library removed the delegate-based comparers. I believe the current builder functionality covers any realistic use case. But if you have a use case not already covered by this library, I'd love to hear it!
— Reply to this email directly, view it on GitHubhttps://github.com/StephenCleary/Comparers/issues/39#issuecomment-1644448858, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BA6KLZKCDOKNKQ63ICVQWRLXRF6JTANCNFSM6AAAAAA2RQJBSI. You are receiving this because you authored the thread.Message ID: @.***>
It would be really nice if we could have a method in both the ComparerBuilder and EqualityComparerBuilder classes to allow a member to be compared using delegates for both the equality comparison and the hashcode creation.
Is this currently possible? If not would you accept a PR to implement this?
Thanks, Sean.