Add FixAll in containing type/member support for code fixes#59989
Add FixAll in containing type/member support for code fixes#59989mavasani merged 32 commits intodotnet:mainfrom
Conversation
Currently, one can apply FixAll operations to Document, Project and Solution scopes. Now, we also support fixing all diagnostics in containing member and type scopes, wherever applicable.
d65e480 to
a774ffc
Compare
src/Features/Core/Portable/UnifiedSuggestions/UnifiedSuggestedActionsSource.cs
Show resolved
Hide resolved
src/EditorFeatures/Core/Shared/Extensions/TelemetryExtensions.cs
Outdated
Show resolved
Hide resolved
| } | ||
| else | ||
| { | ||
| var diagnostics = ImmutableArray<Diagnostic>.Empty; |
There was a problem hiding this comment.
So, for 99% cases we expect a single FixAll span entry here. We get multiple FixAll spans within a document only for the case where a single named type has multiple partial definitions defined in the same file, which is almost never the case in real code bases. I don't think we need to optimize for this corner case.
There was a problem hiding this comment.
my general concern is simply that the builder approach is just as easy to write, and works well for the 1 to many case. I agree it's unlikely, but really rthe ImmutableArray.AddRange approach really stands out like a sort thumb as "this is just waiting for an unfortunate case. Note: sam's TemporaryArray is great here. just do:
using var diagnostics = TemporaryArray<Diagnostic>Empty;As fast for the normal case (<4 items), and no pathlogical dropoff.
...paces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.SpanBasedDiagnosticProvider.cs
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs
Outdated
Show resolved
Hide resolved
...es/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
…e so TS/F# can also opt into ContainingType/Member scope for fix all.
...Workspace/Core/LanguageServices/FixAllSpanMappingService/AbstractFixAllSpanMappingService.cs
Outdated
Show resolved
Hide resolved
...Workspace/Core/LanguageServices/FixAllSpanMappingService/AbstractFixAllSpanMappingService.cs
Outdated
Show resolved
Hide resolved
...Workspace/Core/LanguageServices/FixAllSpanMappingService/AbstractFixAllSpanMappingService.cs
Show resolved
Hide resolved
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
done iwth pass. almost all nits. did see a concern with global statements.
…d using the internal overload instead
|
Thanks @CyrusNajmabadi - feedback addressed |
Currently, one can apply FixAll operations to Document, Project and Solution scopes. Now, we also support fixing all diagnostics in containing member and type scopes, wherever applicable.
Closes #60029
Screenshot
Note
ContainingTypescope fixes all diagnostics in all the partial definitions across files, not just the type declaration in current file from which the fix is triggered.ContainingMemberfix all option (for examplemake class staticcode fix for CA1822).ContainingTypefix all option (for exampleremove unnecessary usingscode fix for IDE0005).Added Tests
FixAllScope.ContainingMemberandFixAllScope.ContainingTypein following buckets:FixAllScope.ContainingMemberandFixAllScope.ContainingType.