Skip to content

Use suppressors when applying code fixes - #53268

Merged
JoeRobich merged 3 commits into
dotnet:mainfrom
corngood:dotnet-format-codefix-supressor
Jun 4, 2026
Merged

JoeRobich merged 3 commits into
dotnet:mainfrom
corngood:dotnet-format-codefix-supressor

Conversation

@corngood

@corngood corngood commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

#48512 fixed suppressors during analysis, but they aren't run when applying code fixes, which can cause fixes to be applied for diagnostics that should have been suppressed.

This only happens when there's a mix of suppressed and unsuppressed diagnostics, because if all diagnostics of a certain type are suppressed, it will bail out earlier.

I'll try to write a test for this when I get a chance.

@corngood
corngood requested a review from a team as a code owner March 4, 2026 23:38
@corngood
corngood force-pushed the dotnet-format-codefix-supressor branch from 16ee5d8 to 0809e6b Compare March 9, 2026 15:35
@corngood
corngood force-pushed the dotnet-format-codefix-supressor branch from 0809e6b to ad13707 Compare March 9, 2026 15:37
@corngood

corngood commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

I added a test.

@github-actions

Copy link
Copy Markdown
Contributor

Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label.

@github-actions github-actions Bot added the stale label May 27, 2026
@corngood

Copy link
Copy Markdown
Contributor Author

Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label.

This still merges cleanly and is just sitting here waiting for review.

@github-actions github-actions Bot removed the stale label May 28, 2026
@pantosha

Copy link
Copy Markdown

Pinging @sharwell, @KirillOsenkov, @baywet, @JoeRobich for review

@baywet

baywet commented May 29, 2026 •

Copy link
Copy Markdown

Hi @pantosha
Thank you for your patience.

It's odd this PR was not assigned reviewers automatically.
However, while I do work at Microsoft, I'm not on the dotnet team and can't approve/merge this PR.

Kirill and Joe might be able to help here, but just in case CC @marcpopMSFT @Cosifne @MichaelSimons @sailro @MiYanni who might be able to help and have contributed to this file in the past.

@sailro

sailro commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

I do work at Microsoft as well (Visual Studio Tools for Unity), I'm not on the dotnet team and can't merge this PR. I made the previous one #48512 that fixes the analysis phase, and this one complement this work with the applying-code-fixes one. Thank you @corngood for this, and sorry to have missed this part.

@JoeRobich should be the one helping us finalizing the review.

I think this should solve #50978

cc @jbevain

{
class Program : MonoBehaviour
{
[SerializeField] int notReadOnly;

@sailro sailro May 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optionally we can add a comment like

Suggested change
[SerializeField] int notReadOnly;
// This field should trigger IDE0044 (make field readonly) in a regular project.
// But given we simulate a Unity MonoBehavior and we include Microsoft.Unity.Analyzers nuget,
// And given SerializeField is a well-known Unity serialization attribute, this IDE0044 should be suppressed by USP0004.
// see https://github.com/microsoft/Microsoft.Unity.Analyzers/blob/main/doc/USP0004.md
[SerializeField] int notReadOnly;

@sailro sailro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@JoeRobich JoeRobich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @corngood!

@pantosha

pantosha commented Jun 4, 2026

Copy link
Copy Markdown

@JoeRobich, kindly reminder. Can you merge PR?
Also, it would be nice to port to dotnet 10 sdk (as it was with #48512)

@JoeRobich
JoeRobich merged commit a73c109 into dotnet:main Jun 4, 2026
23 of 25 checks passed
@JoeRobich

Copy link
Copy Markdown
Member

/backport to release/10.0.3xx

@dotnet dotnet deleted a comment from github-actions Bot Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.3xx (link to workflow run)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants