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

RS1039 (GetDeclaredSymbol will always return null) has a number of false positives #7436

Open
333fred opened this issue Oct 4, 2024 · 0 comments
Labels
Area-Microsoft.CodeAnalysis.Analyzers False_Positive A diagnostic is reported for non-problematic case

Comments

@333fred
Copy link
Member

333fred commented Oct 4, 2024

Analyzer

Diagnostic ID: RS1039: GetDeclaredSymbol will always return null

Analyzer source

Version: Microsoft.CodeAnalysis.Analyzers 3.11.0

Describe the bug

There are a number of false positives in the analyzer. Some false positives it flags in roslyn:

https://github.com/dotnet/roslyn/blob/62af60c7637252896646f0e0df015d42bb584b7f/src/Compilers/CSharp/Test/Symbol/Compilation/SemanticModelAPITests.cs#L1886 - error RS1039: A call to 'SemanticModel.GetDeclaredSymbol(StatementSyntax)' will always return 'null'
https://github.com/dotnet/roslyn/blob/62af60c7637252896646f0e0df015d42bb584b7f/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs#L8313 - error RS1039: A call to 'SemanticModel.GetDeclaredSymbol(ModifiedIdentifierSyntax)' will always return 'null'
https://github.com/dotnet/roslyn/blob/62af60c7637252896646f0e0df015d42bb584b7f/src/Compilers/CSharp/Test/Symbol/Symbols/Source/DeclaringSyntaxNodeTests.cs#L141 - error RS1039: A call to 'SemanticModel.GetDeclaredSymbol(TNode)' will always return 'null'
https://github.com/dotnet/roslyn/blob/62af60c7637252896646f0e0df015d42bb584b7f/src/Compilers/CSharp/Test/Emit3/Semantics/PatternMatchingTests_ListPatterns.cs#L4259 - error RS1039: A call to 'SemanticModel.GetDeclaredSymbol(VariableDesignationSyntax)' will always return 'null'

These are only a few of the false positives. A full list can be obtained by building dotnet/roslyn and turning RS1039 back on; I've turned it off for now due to the noise.

@333fred 333fred added Area-Microsoft.CodeAnalysis.Analyzers False_Positive A diagnostic is reported for non-problematic case labels Oct 4, 2024
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

No branches or pull requests

1 participant