Skip to content

Conversation

@sailro
Copy link
Contributor

@sailro sailro commented Apr 16, 2025

Context:

Microsoft.Unity.Analyzers is able to add Unity-specific diagnostics or to remove general C# diagnostics that do not apply to Unity projects (through diagnostic suppressors).

One common usage is to run the dotnet format command on a unity solution to ensure projects obey the .editorconfig linting rules:

dotnet format --verify-no-changes --severity warn

But currently this command does not support diagnostic suppressors, which implies a lack of consistency with our IDEs and command-line build tools, which now manage suppressors.

See microsoft/Microsoft.Unity.Analyzers#387 for a minimal repro.

Other scenarios are likely to be similar, such as the linting of test projects (NUnit and XUnit make use of diagnostic suppressors).

For this PR we tried to have a minimal impact, by just registering local project suppressors, when running the
code-style phase.

Added unit tests as well.

fixes dotnet/format#1998
fixes microsoft/Microsoft.Unity.Analyzers#387
fixes #44867

Copilot AI review requested due to automatic review settings April 16, 2025 07:20
@sailro sailro requested a review from a team as a code owner April 16, 2025 07:20
@ghost ghost added the untriaged Request triage from a team member label Apr 16, 2025
@ghost
Copy link

ghost commented Apr 16, 2025

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

1 similar comment
@ghost
Copy link

ghost commented Apr 16, 2025

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

@sailro sailro changed the title Add suppressor support for dotnet-format Add suppressor support for dotnet-format Apr 16, 2025
@sailro sailro changed the title Add suppressor support for dotnet-format Add suppressor support for dotnet format Apr 16, 2025
@sailro sailro force-pushed the dotnet-format-suppressor-support branch from 457ef9e to 119a5ee Compare April 16, 2025 08:05
@sailro sailro force-pushed the dotnet-format-suppressor-support branch from 119a5ee to 4940ff7 Compare April 16, 2025 12:28
@sailro
Copy link
Contributor Author

sailro commented Apr 16, 2025

Pinging @dotnet-cli @jbevain @sharwell for visibility. Thanks !

@sailro sailro force-pushed the dotnet-format-suppressor-support branch 2 times, most recently from dd365ae to cca26de Compare April 17, 2025 13:00
@sailro sailro force-pushed the dotnet-format-suppressor-support branch from cca26de to 92a8b0d Compare April 17, 2025 21:21
@sailro
Copy link
Contributor Author

sailro commented Apr 18, 2025

cc @tmat

@sailro
Copy link
Contributor Author

sailro commented Apr 24, 2025

cc @KirillOsenkov @baywet @JoeRobich for awareness

@sailro
Copy link
Contributor Author

sailro commented May 13, 2025

Any feedback ? Feel free to share your concerns or ideas. Thanks!

@sailro
Copy link
Contributor Author

sailro commented Aug 29, 2025

Bumping @tmat for awareness, could we find someone to review this one please?
Thanks!

Copy link
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sailro!

@JoeRobich JoeRobich merged commit 662f699 into dotnet:main Aug 29, 2025
27 checks passed
@sailro sailro deleted the dotnet-format-suppressor-support branch August 29, 2025 18:10
@JoeRobich
Copy link
Member

/backport to release/10.0.1xx

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2025

@JoeRobich backporting to "release/10.0.1xx" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Add suppressor support for dotnet-format
Applying: Add unit tests
Applying: Fix format
Applying: Improve comments
Applying: Add suppressor support for dotnet-format
Using index info to reconstruct a base tree...
M	src/BuiltInTools/dotnet-format/Analyzers/AnalyzerFormatter.cs
M	src/BuiltInTools/dotnet-format/Analyzers/CodeStyleInformationProvider.cs
Falling back to patching base and 3-way merge...
Auto-merging src/BuiltInTools/dotnet-format/Analyzers/CodeStyleInformationProvider.cs
CONFLICT (content): Merge conflict in src/BuiltInTools/dotnet-format/Analyzers/CodeStyleInformationProvider.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0005 Add suppressor support for dotnet-format
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

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

Labels

Area-Format untriaged Request triage from a team member

Projects

None yet

3 participants