-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
fix all is just a concept of scope. not something tightly coupled with the concept of diagnostics or code fixer or code refactoring.
we should provide a way to let users select a scope for CodeRefactoringProvider (http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/CodeRefactorings/CodeRefactoringProvider.cs,11)
...
proposal will be
- add RefactoringFixAllProvider as in CodeFixProvider.GetFixAllProvider
http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/CodeFixes/CodeFixProvider.cs,33 to CodeRefactoringProvider
which is the same as FixAllProvider but without GetSupportedFixAllDiagnosticIds.
it would be awesome if we can merge those 2, but if we can't, having new type seems fine.
- FixAllContext for GetFixAsync gets new one RefactoringFixAllContext. again, it would be nice if we can merge those 2 but, if that's a problem (due to it being public API and etc), having new type seems fine to me
and like RefactoringFixAllprovider, RefactoringFixAllContext should not have any API related to DiagnosticIDs but all other ones like Scope, CancellationToken and etc should be provided same.
in this proposal, implementer of RefactoringFixAllProvider will implement the fix all provider almost same way as existing FixAllProvider, only difference will be rather than get code location to apply fix by diagnostics, it will run its own discovery code based on given scope and return fix all code action as existing CodeFix FixAllProvider.
like existing FixAllProvider, we can provide general RefactoringFixAllProvider such as BatchFixAllProvider (http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs,23) by let it accept discoverer that will run on the given scope to find places to call existing CodeRefactoringProvider almost same way as we do for CodeFixProvider.
...
it doesn't need to be the way I proposed above, but the point is us providing a way for user to invoke code refactoring fix all so that it doesn't become a reason to make people to convert refactoring to analyzers.
people should convert one to analyzer if they believe it is something worth to break build in CI. LB or Fix all shouldn't be the reason. in that sense, once we have this, we should consider some of analyzer with hidden diagnostics, whether we should move those to refactoring rather than analyzers.