Hey, is it somehow possible to disable the usage of IComparable<T> and compare both objects as if they wouldn't implement that interface (without having to write custom comparison rules)?
Why would I want that?
I use ObjectsComparer in my unit tests, where I compare two objects that should have the same content. But in my production code, I want to compare two objects based on one certain property in order to rank them in a SortedSet (which uses IComparable<T> to do so).
However, there seems to be a bug in it anyway, minimal example (should return true, but returns false - if you remove the interface, it's correct): https://dotnetfiddle.net/51zYFs
Is there a certain reason why you chose IComparable<T> and not IEqualityComparer<T>?
Hey, is it somehow possible to disable the usage of
IComparable<T>and compare both objects as if they wouldn't implement that interface (without having to write custom comparison rules)?Why would I want that?
I use ObjectsComparer in my unit tests, where I compare two objects that should have the same content. But in my production code, I want to compare two objects based on one certain property in order to rank them in a
SortedSet(which usesIComparable<T>to do so).However, there seems to be a bug in it anyway, minimal example (should return true, but returns false - if you remove the interface, it's correct): https://dotnetfiddle.net/51zYFs
Is there a certain reason why you chose
IComparable<T>and notIEqualityComparer<T>?