Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructing a HashSet<ISymbol> with SymbolEqualityComparer should not generate any warnings #4568

Closed
Leemyy opened this issue Dec 12, 2020 · 0 comments · Fixed by #4571
Closed
Labels
Area-Microsoft.CodeAnalysis.Analyzers False_Positive A diagnostic is reported for non-problematic case

Comments

@Leemyy
Copy link

Leemyy commented Dec 12, 2020

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

  1. Create an new source generator project
  2. Within the Execute metod of the generator, write the line:
    HashSet<ISymbol> childTypes = new(SymbolEqualityComparer.Default);
  3. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Microsoft.CodeAnalysis.Analyzers False_Positive A diagnostic is reported for non-problematic case
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants