Skip to content
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

Update S1210: "Override Equals when implementing IComparable" should be code smell #438

Closed
valhristov opened this issue Jun 14, 2017 · 0 comments
Milestone

Comments

@valhristov
Copy link
Contributor

RSPEC-1210

When you implement IComparable or IComparable<T> on a class you should also override Equals(object) and overload the comparison operators (==, !=, <, <=, >, >=). That's because the CLR cannot automatically call your CompareTo implementation from Equals(object) or from the base comparison operator implementations. Additionally, it is best practice to override GetHashCode along with Equals.

@valhristov valhristov added this to the 6.0 milestone Jun 14, 2017
@valhristov valhristov changed the title Update S1210: "Equals" and the comparison operators should be overridden when implementing "IComparable" Update S1210: "Override Equals when implementing IComparable" should be code smell Jun 14, 2017
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

No branches or pull requests

1 participant