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

Support for DiagnosticSuppressors #1998

Open
WhippetsAintDogs opened this issue Oct 25, 2023 · 1 comment
Open

Support for DiagnosticSuppressors #1998

WhippetsAintDogs opened this issue Oct 25, 2023 · 1 comment
Labels
Bug This issue describes behavior that is not working as expected Help Wanted This issue is up for grabs by the community

Comments

@WhippetsAintDogs
Copy link

WhippetsAintDogs commented Oct 25, 2023

Running dotnet format on a project with 3rd-party analyzers doesn't seem to take DiagnosticSuppressors like those shipped with Microsoft.Unity.Analyzers into consideration.

Am I wrong? Is there any documentation on how to make that work or it's simply not supported yet? If so, any plans to support these?

Thank you!

@corngood
Copy link

Here's what I've found:

  • suppressors don't get run reliably because of this block:
                    var severity = await analyzer.GetSeverityAsync(project, formattablePaths, cancellationToken).ConfigureAwait(false);
                    if (severity >= minimumSeverity)
                    {
                        analyzers.Add(analyzer);
                    }

My fix for that is corngood@fa99c15

We treat suppressors separately and use them unconditionally if they may suppress any of the diagnostics that have been referenced by the other analysers.

  • analysers and 'style' stuff are not run in the same pass

I only have a hack for this: corngood@89fff84

You have CodeStyleFormatter and ThirdPartyFormatter, which are run separately, so suppressors in the latter (e.g. ones referenced in a .csproj) aren't aware of diagnostics from the former.

My hack combines the passes together, and I am now able to suppress style diagnostics.

IMO To get this to a PR, that second change needs to be cleaned up, and we need tests.

@sharwell sharwell added Bug This issue describes behavior that is not working as expected Help Wanted This issue is up for grabs by the community labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This issue describes behavior that is not working as expected Help Wanted This issue is up for grabs by the community
Projects
None yet
Development

No branches or pull requests

3 participants