Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make CompletionItem implement IEquatable<CompletionItem> #1991

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

adamsitnik
Copy link
Member

No description provided.

@adamsitnik adamsitnik merged commit f449c2d into dotnet:main Dec 14, 2022
@adamsitnik adamsitnik deleted the CompletionItemMinor branch December 14, 2022 07:08
return true;
}

if (obj.GetType() != GetType())

Choose a reason for hiding this comment

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

The new implementation does not check obj.GetType() != GetType(). That makes it difficult for derived classes to override the Equals methods correctly. CompletionItem is not a sealed class and should not be, as noted in #1962 (comment).

@KalleOlaviNiemitalo
Copy link

What is the rationale for this change? CompletionItem is a reference type, so implementing IEquatable<CompletionItem> does not help avoid any boxing.

@adamsitnik
Copy link
Member Author

What is the rationale for this change?

It helps to avoid casting and EqualityComparer<CompletionItem>.Default returns GenericEqualityComparer rather than ObjectEqualityComparer (better perf when used in dictionaries/hashsets).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants