Skip to content

Comments

Fix mentions of equality comparison for collections#12330

Open
svick wants to merge 1 commit intodotnet:mainfrom
svick:contains-equalitycomparer
Open

Fix mentions of equality comparison for collections#12330
svick wants to merge 1 commit intodotnet:mainfrom
svick:contains-equalitycomparer

Conversation

@svick
Copy link
Member

@svick svick commented Feb 18, 2026

For ICollection<T>.Contains and Remove, the relevant types are (I)EqualityComparer<T>, not (I)Comparer<T>.

For List<T> and Array, don't try to (badly) explain their behavior, instead link to EqualityComparer<T>.Default.

Copilot AI review requested due to automatic review settings February 18, 2026 15:47
@svick svick requested a review from a team as a code owner February 18, 2026 15:47
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 18, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-collections

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects documentation inaccuracies regarding equality comparison mechanisms in .NET collection types. The changes fix incorrect references to Comparer<T> and IComparer<T> (which are for ordering comparisons) by replacing them with the correct EqualityComparer<T> and IEqualityComparer<T> types (which are for equality comparisons). Additionally, the documentation for Array and List<T> methods is simplified to reference EqualityComparer<T>.Default instead of providing potentially misleading explanations about how equality is determined.

Changes:

  • Corrected ICollection<T>.Contains and Remove documentation to reference equality comparers instead of ordering comparers
  • Updated Array.IndexOf overloads documentation to link to EqualityComparer<T>.Default
  • Updated List<T>.Contains and IndexOf documentation to link to EqualityComparer<T>.Default

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
xml/System/Array.xml Updated six IndexOf method overload remarks to reference EqualityComparer<T>.Default instead of explaining Equals method behavior
xml/System.Collections.Generic/List`1.xml Corrected Contains and IndexOf remarks to reference EqualityComparer<T>.Default
xml/System.Collections.Generic/ICollection`1.xml Fixed incorrect references from Comparer<T>/IComparer<T> to EqualityComparer<T>/IEqualityComparer<T> in Contains and Remove remarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Collections community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant