Skip to content

Declare Implementation

Michael Damatov edited this page Sep 10, 2025 · 2 revisions

Suggests declaring an implementation of the IEqualityOperators<T, T, bool> interface

Declare an implementation of the IEqualityOperators<T, T, bool> interface when one of the following conditions is met:

  • The type is a class that already implements the IEquatable<T> interface.
  • The type is a struct that already implements the IEquatable<T> interface.
  • The type is a record.

Note

  • The context action does not add the equality operators. It only declares the implementation of the IEqualityOperators<T, T, bool> interface. The equality operators must be implemented manually or by using the ReSharper context actions.
  • The context action is only available when C# 11 or higher is used with the the framework, which has the IEqualityOperators<TSelf,TOther,TResult> interface.

Important

Known Limitations

  • Only classes, which implement the IEquatable<T> interface are supported. Derived classes are not analyzed.
  • Only classes, which implement the IEquatable<T> interface are supported. Interfaces that extend the IEquatable<T> interface are not considered (rare use case).

Suggests declaring an implementation of the IComparisonOperators<T, T, bool> interface

Declare an implementation of the IComparisonOperators<T, T, bool> interface when one of the following conditions is met:

  • The type is a class that already implements the IComparable<T> interface.
  • The type is a struct that already implements the IComparable<T> interface.
  • The type is a record.

Note

  • The context action does not add the equality operators. It only declares the implementation of the IComparisonOperators<T, T, bool> interface. The equality operators must be implemented manually or by using the ReSharper context actions.
  • The context action is only available when C# 11 or higher is used with the the framework, which has the IComparisonOperators<TSelf,TOther,TResult> interface.

Important

Known Limitations

  • Only classes, which implement the IComparable<T> interface are supported. Derived classes are not analyzed.
  • Only classes, which implement the IComparable<T> interface are supported. Interfaces that extend the IComparable<T> interface are not considered (rare use case).
Clone this wiki locally