A type defines == but does not override Equals, so the two kinds of equality disagree
What it finds
Code that compares with == and code that compares with Equals, such as collections and LINQ, should agree on what is equal. A type that defines operator == but keeps the inherited Equals makes a list's Contains and a direct comparison give different answers for the same two objects.
From the rule's source, equality_operator_without_equals.rs.
class Version{ public int Major; public static bool operator ==(Version a, Version b) => a.Major == b.Major;tx0 reports: Version defines == but does not override Equals public static bool operator !=(Version a, Version b) => !(a == b);} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:equality-operator-without-equals" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:equality-operator-without-equals] reason="..."tx0 explain tx0/csharp:equality-operator-without-equals shows the same in the terminal. Found a false positive? Report it.