We recommend that you derive from the EqualityComparer class instead of implementing the IEqualityComparer interface, because the EqualityComparer class tests for equality using the IEquatable.Equals method instead of the Object.Equals method.
public abstract partial class EqualityComparer<T> : IEqualityComparer, IEqualityComparer<T>
{
public abstract bool Equals(T? x, T? y);
public abstract int GetHashCode([DisallowNull] T obj);
}
These two abstract methods are the two methods required by IEqualityComparer<T>. There's no "pre-processing" of x and y.
So I don't see what this remark in the documentation would be referring to.
The current version of the documentation of
EqualityComparer<T>
contains this in its "Remarks" section:I think this statement is completely wrong. The current (.NET 5) implementation of
EqualityComparer<T>
is like this (only the relevant parts):These two abstract methods are the two methods required by
IEqualityComparer<T>
. There's no "pre-processing" ofx
andy
.So I don't see what this remark in the documentation would be referring to.