You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't guard Dictionary<K, V>.Remove(key) by ContainsKey(key) #33797
api-approvedAPI was approved in API review, it can be implementedarea-System.Collectionscode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixerin-prThere is an active PR which will close this issue when it is merged
api-approvedAPI was approved in API review, it can be implementedarea-System.Collectionscode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixerin-prThere is an active PR which will close this issue when it is merged
Activity
jeffhandley commentedon Mar 21, 2020
Estimates:
carlossanlop commentedon Jan 8, 2021
Suggested severity: Info
Example
Avoid triggering the analyzer if there's additional code inside the if statement:
terrajobst commentedon Feb 4, 2021
Video
We could further improve the fixer to handle this as well:
But it's not necessary -- we can start simple and take it from there.
2 remaining items
carlossanlop commentedon Feb 11, 2021
Thanks for your help, @chucker! I'm assigning the issue to you. Feel free to submit a PR whenever you get a chance, and we can take a look.
chucker commentedon Feb 11, 2021
(The PR linked above does now include the fixer, too.)
paulomorgado commentedon Sep 3, 2021
is there an issue like this for
HashSet<T>?HashSet<T>.Remove(item)byHashSet<T>.Contains(item)?HashSet<T>.Add(item)byHashSet<T>.Contains(item)?carlossanlop commentedon Sep 14, 2021
@paulomorgado if you can't find any issue, please create an API proposal.
paulomorgado commentedon Sep 15, 2021
An API proposal????
chucker commentedon Oct 13, 2021
@paulomorgado yes — make a new issue over here
See also these guidelines.