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

ACL1010 highlights the whole file as a warning #18

Open
jackpercy-acl opened this issue Feb 22, 2024 · 2 comments
Open

ACL1010 highlights the whole file as a warning #18

jackpercy-acl opened this issue Feb 22, 2024 · 2 comments

Comments

@jackpercy-acl
Copy link
Contributor

If the project you are in does not have nullable reference types enabled, then ACL1010 highlights every line in every file:

image

Pretty sure this is because the location of the diagnostic is being set to the root of the syntax tree, i.e. the whole file

var location = context.SemanticModel
.SyntaxTree
.GetRoot()
.GetLocation();
var diagnostic = Diagnostic.Create(Rule, location);

Instead, I think the location can be set a Location.None to indicate the whole file has an issue.

For example, this is how AV2210 is reported - only once in the whole file:

image

And here is how the diagnostic for it is created:

https://github.com/bkoelman/CSharpGuidelinesAnalyzer/blob/e84590e1b0c0682a9a932d6fdd3f4ac1637cd730/src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer/Rules/Framework/BuildWithTheHighestWarningLevelAnalyzer.cs#L46

@andrewgaze
Copy link

Has this issue been resolved? Just update the package to the latest version (1.11.0) and experiencing the problem.

@jackpercy-acl
Copy link
Contributor Author

@andrewgaze not managed to resolve this unfortunately - I tried the suggested fix, but that gave no warning at all. There might need to be another config step to get the Location.None to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants