-
-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Version of the Meziantou.Analyzer NuGet package
2.0.187
Rule Identifier
MA0002
Target Framework
net9.0
C# Language version
preview
Description
The rule MA002
seems to take linq provided Contains(...)
overloads into account, when it checks, if an equality comparer can be used. In the case of immutable sets, it also suggest manually passing a equality comparer. But that would case the set to be enumerated, so effectively a worse performing overload is suggested.
Reproduction Steps
Minimal code:
#r "nuget: System.Collections.Immutable, 9.0.2"
#r "nuget: Meziantou.Analyzer, 2.0.187"
using System.Collections.Immutable;
IImmutableSet<string> set = ImmutableHashSet.Create<string>(StringComparer.Ordinal);
bool found = [|set.Contains("foo")|];
Other information
Mutable sets do not raise this issue.
Immutable dictionary kind of work, since the contains method has an other signature.
Metadata
Metadata
Assignees
Labels
No labels