Constructing a HashSet<ISymbol>
with SymbolEqualityComparer
should not generate any warnings
#4568
Labels
Area-Microsoft.CodeAnalysis.Analyzers
False_Positive
A diagnostic is reported for non-problematic case
Analyzer
Diagnostic ID: RS1024:
Compare symbols correctly
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.Analyzers
Version: 3.3.2 (Latest)
Describe the bug
When constructing a
HashSet<ISymbol>
or aDictionary<ISymbol, _>
with the constructor override accepting anIEqualityComparer
, passing in eitherSymbolEqualityComparer.Default
orSymbolEqualityComparer.IncludeNullability
still results is a warning.Steps To Reproduce
Execute
metod of the generator, write the line:HashSet<ISymbol> childTypes = new(SymbolEqualityComparer.Default);
See here for an example of a (non-minimal) repro.
Expected behavior
No warning should be reported.
Actual behavior
A warning about improper Symbol comparison is reported.
Additional context
HashSet<T>
andDictionary<K, V>
ISymbol
The text was updated successfully, but these errors were encountered: