dotnet / format

Home for the dotnet-format command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for DiagnosticSuppressors

WhippetsAintDogs opened this issue · comments

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!

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.