-
Notifications
You must be signed in to change notification settings - Fork 4.2k
allow third party codfixers to be run in code cleanup #59631
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
allow third party codfixers to be run in code cleanup #59631
Conversation
6d115eb to
5f62616
Compare
5f62616 to
811e06b
Compare
5bc89f6 to
024a5df
Compare
src/Features/Core/Portable/CodeCleanup/AbstractCodeCleanupService.cs
Outdated
Show resolved
Hide resolved
| if (enabledDiagnostics.RunThirdPartyFixers) | ||
| { | ||
| progressTracker.AddItems(1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add an item per 3rd party fixer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unresolving :)
src/Features/Core/Portable/CodeCleanup/AbstractCodeCleanupService.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/CodeCleanup/AbstractCodeCleanupService.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/CodeCleanup/AbstractCodeCleanupService.cs
Outdated
Show resolved
Hide resolved
| return null; | ||
|
|
||
| using var resultDisposer = ArrayBuilder<CodeFixCollection>.GetInstance(out var result); | ||
| var spanToDiagnostics = new SortedDictionary<TextSpan, List<DiagnosticData>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a List and not an ImmutableArray?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StreamFixesAsync takes an argument of type SortedDictionary<TextSpan, List<DiagnosticData>> here
| SortedDictionary<TextSpan, List<DiagnosticData>> spanToDiagnostics, |
@CyrusNajmabadi I believe you wrote this code, do you recall why you used List<DiagnosticData>? Happy to change it to ImmutableArray<<DiagnosticData>>
src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.TestFixers.cs
Outdated
Show resolved
Hide resolved
sharwell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In every analyzer package I've seen, at most a strict subset of analyzers had code fixes which could be safely applied without the risk of breaking code (or silently changing behavior). This feature blanket assumes that all code fixes are safe, and will either be unusable or require a complete rewrite of the analyzer severity in projects.
|
I feel like we need an opt in or opt out option here. Preferably the former. Also, i mean: each fixer should opt into if it is safe to be used in this fashion. |
…ice.cs Co-authored-by: CyrusNajmabadi <[email protected]>
…ything in one list
6e67de4 to
73f608a
Compare
ryzngard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. Hope to get start testing this soon!
|
|
||
| // If changes were made to the solution snap shot outside the current document discard the changes. | ||
| // The assumption here is that if we are applying a third party code fix to a document it only affects the document. | ||
| // Symbol renames and other complex refactorings we do not want to include in code cleanup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do a follow up item to potentially log telemetry when this happens and notify the user?
Fixes #58089
This options looks like this in the UI:
To enable this functionality the user needs to

3. Run the code cleanup profile where they modified that settingRules for whether we apply a code fix with this option are as follows:
TODO: