Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mpidash
Copy link
Contributor

@mpidash mpidash commented Jul 28, 2023

The new analyzer CA1868: 'Unnecessary call to 'Contains' for sets'
checks when an Add or Remove is guarded by Contains.

This commit removes these calls to Contains.
@ghost ghost added area-Meta community-contribution Indicates that the PR has been added by a community member labels Jul 28, 2023
@ghost
Copy link

ghost commented Jul 28, 2023

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

See dotnet/roslyn-analyzers#6767 and #85490.

Author: mpidash
Assignees: -
Labels:

area-Meta

Milestone: -

dotnet_diagnostic.CA1864.severity = warning

# CA1868: Unnecessary call to 'Contains' for sets
dotnet_diagnostic.CA1868.severity = warning
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a corresponding entry to the .test.globalconfig file? That one would be at level none.

Comment on lines 188 to 190
if (!candidates.Add(candidatePart))
{
alreadyProcessed = true;
Copy link
Member

Choose a reason for hiding this comment

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

alreadyProcessed |= !candidates.Add(candidatePart);

?

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks!

@marek-safar marek-safar merged commit 4ed3550 into dotnet:main Jul 29, 2023
@mpidash mpidash deleted the remove-guarded-set-calls branch July 29, 2023 13:01
@ghost ghost locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta 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.

3 participants