Equals is called on an array, which compares references and not elements

tx0/csharp:array-equals-referencedefaultwarningreliability/equalitydepth fastbug

What it finds

Arrays inherit Equals from object: a.Equals(b) is true only when both are the same array, never for two arrays with the same elements. SequenceEqual, or StructuralComparisons.StructuralEqualityComparer, compares the elements. The rule reports Equals called on a variable whose declared type is an array, with an argument that is also declared as an array.

From the rule's source, array_equals_reference.rs.

Example from the rule's tests
class Keys{    bool Same(byte[] a, byte[] b) => a.Equals(b);tx0 reports: Equals on arrays compares references, not elements     bool Same(string a, string b) => a.Equals(b);}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:array-equals-reference" = "off"

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:array-equals-reference] reason="..."

tx0 explain tx0/csharp:array-equals-reference shows the same in the terminal. Found a false positive? Report it.