Skip to content

Disable usage of IComparable<T> #57

Description

@Velociraptor45

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>?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions