Class CannotApplyEqualityOperatorAttribute
Indicates that the value of the marked type (or its derivatives)
cannot be compared using '==' or '!=' operators and Equals()
should be used instead. However, using '==' or '!=' for comparison
with null
is always permitted.
Implements
Inherited Members
Namespace: JetBrains.Annotations
Assembly: UnityEngine.dll
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
public sealed class CannotApplyEqualityOperatorAttribute : Attribute, _Attribute
Examples
[CannotApplyEqualityOperator]
class NoEquality { }
class UsesNoEquality {
public void Test() {
var ca1 = new NoEquality();
var ca2 = new NoEquality();
if (ca1 != null) { // OK
bool condition = ca1 == ca2; // Warning
}
}
}