dotnet / dotnet/dotnet-api-docs
Documentation for EqualityComparer<T> contains wrong remark
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
The current version of the [documentation of `EqualityComparer`](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.equalitycomparer-1?view=net-5.0) contains this in its "Remarks" section:
> 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.
I think this statement is completely wrong. The [current (.NET 5) implementation of `EqualityComparer`](https://github.com/dotnet/runtime/blob/6cf1b8ec012d52880d46fa4773f60ed52ddc9f3d/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.cs) is like this (only the relevant parts):
```c#
public abstract partial class EqualityComparer : IEqualityComparer, IEqualityComparer
{
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`. There's no "pre-processing" of `x` and `y`.
So I don't see what this remark in the documentation would be referring to.
Contributor guide
Assessment
This issue has not been assessed yet.