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

Create analyzer to detect calls to SemanticModel.GetDeclaredSymbol() with fields and other invalid syntax #336

Closed
JoshVarty opened this issue Nov 5, 2015 · 1 comment · Fixed by #6779
Labels
Area-Microsoft.CodeAnalysis.Analyzers Feature Request help wanted The issue is up-for-grabs, and can be claimed by commenting
Milestone

Comments

@JoshVarty
Copy link
Contributor

Using SemanticModel.GetDeclaredSymbol() will always return null for certain pieces of syntax. According to the comments this is the case for GlobalStatementSyntax, IncompleteMemberSyntax, and BaseFieldDeclarationSyntax.

In order to guide new people using the API, we should provide an analyzer that checks for invalid calls to GetDeclaredSymbol() and issues a warning. (In particular the field syntax can be confusing for people who don't realize fields consist of multiple variables).

@srivatsn srivatsn added this to the Unknown milestone Dec 30, 2015
@sharwell sharwell added help wanted The issue is up-for-grabs, and can be claimed by commenting and removed Up for Grabs labels Aug 1, 2019
@Evangelink
Copy link
Member

Although I like rules helping you to use an API correctly, I think these use cases are rare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Microsoft.CodeAnalysis.Analyzers Feature Request help wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants