Skip to content

Implement IEquatable<T> on Value Types #60

@israelaece

Description

@israelaece

See Jared Parsons blog post for details of why this is important and the MSDN article on IEquatable Interface.
Also quoting MSDN:

If you implement IEquatable<T>, you should also override the base class implementations of Object.Equals(Object) and GetHashCode so that their behavior is consistent with that of the IEquatable<T>.Equals method. If you do override Object.Equals(Object), your overridden implementation is also called in calls to the static Equals(System.Object, System.Object) method on your class. In addition, you should overload the op_Equality and op_Inequality operators. This ensures that all tests for equality return consistent results.

Equals implementation follows the one suggested on #50.

Severity: Hidden
Diagnostic Id: CC0027
Category: Refactoring
Related to #50 (Generate Equals() and GetHashCode() for reference types). If it is Done maybe we can use the same code to generate GetHashCode.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions