Repository navigation
Use suppressors when applying code fixes - #53268
Conversation
16ee5d8 to
0809e6b
Compare
0809e6b to
ad13707
Compare
|
I added a test. |
|
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. |
|
Pinging @sharwell, @KirillOsenkov, @baywet, @JoeRobich for review |
|
Hi @pantosha It's odd this PR was not assigned reviewers automatically. 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. |
|
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; |
There was a problem hiding this comment.
Optionally we can add a comment like
| [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; |
|
@JoeRobich, kindly reminder. Can you merge PR? |
|
/backport to release/10.0.3xx |
|
Started backporting to |
#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.