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 a Dictionary<ISymbol, _> with the constructor override accepting an IEqualityComparer, passing in either SymbolEqualityComparer.Default or SymbolEqualityComparer.IncludeNullability still results is a warning.
Steps To Reproduce
- Create an new source generator project
- Within the
Execute metod of the generator, write the line:
HashSet<ISymbol> childTypes = new(SymbolEqualityComparer.Default);
- A warning will get reported on the constructor call
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
- The warning gets reported both for
HashSet<T> and Dictionary<K, V>
- Using a qualified constructor insead of a target-typed constuctor makes no difference
- The warning gets reported whenever the generic parameter is/derives from
ISymbol
Analyzer
Diagnostic ID: RS1024:
Compare symbols correctlyAnalyzer 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.DefaultorSymbolEqualityComparer.IncludeNullabilitystill results is a warning.Steps To Reproduce
Executemetod 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