JetBrains Rider 2020.2 Help

Code Inspection: Compare with '==' types marked by 'CannotApplyEqualityOperatorAttribute'

The CannotApplyEqualityOperator attribute is a ReSharper annotation attribute used to mark types for which the use of == and != operators is inappropriate and should be replaced with Equals() or other operations. Consequently, when two types marked with this attribute are compared with == or !=, JetBrains Rider will issue a warning.

You may also wonder how JetBrains Rider knows which types cannot be compared with equality operators. Well, the trick is done with External Annotations for the .NET Framework Class Library and other frequently used libraries. These annotations are included in the JetBrains Rider installation. The [CannotApplyEqualityOperator] attribute that triggers this inspection can also be used for your custom types, or you can use the mechanism of External Annotations to annotate types in compiled libraries that you use.

Last modified: 08 May 2020