15
15
using Microsoft . CodeAnalysis . Editor . Shared . Utilities ;
16
16
using Microsoft . CodeAnalysis . Host ;
17
17
using Microsoft . CodeAnalysis . Options ;
18
- using Microsoft . CodeAnalysis . PooledObjects ;
19
18
using Microsoft . CodeAnalysis . Progress ;
20
19
using Microsoft . CodeAnalysis . Shared . Extensions ;
21
20
using Microsoft . CodeAnalysis . Shared . Utilities ;
@@ -66,7 +65,15 @@ private async Task<bool> FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h
66
65
{
67
66
var hierarchy = hierarchyContent . Hierarchy ;
68
67
if ( hierarchy == null )
69
- return await FixSolutionAsync ( _workspace . CurrentSolution , context ) . ConfigureAwait ( true ) ;
68
+ {
69
+ var solution = _workspace . CurrentSolution ;
70
+ return await FixAsync (
71
+ _workspace ,
72
+ // Just defer to FixProjectsAsync, passing in all fixable projects in the solution.
73
+ ( progress , cancellationToken ) => FixProjectsAsync (
74
+ _globalOptions , solution , solution . Projects . Where ( p => p . SupportsCompilation ) . ToImmutableArray ( ) , context . EnabledFixIds , progress , cancellationToken ) ,
75
+ context ) . ConfigureAwait ( false ) ;
76
+ }
70
77
71
78
// Map the hierarchy to a ProjectId. For hierarchies mapping to multitargeted projects, we first try to
72
79
// get the project in the most recent active context, but fall back to the first target framework if no
@@ -98,7 +105,12 @@ private async Task<bool> FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h
98
105
if ( project == null || ! project . SupportsCompilation )
99
106
return false ;
100
107
101
- return await FixProjectAsync ( project , context ) . ConfigureAwait ( true ) ;
108
+ return await FixAsync (
109
+ _workspace ,
110
+ // Just defer to FixProjectsAsync, passing in this single project to fix.
111
+ ( progress , cancellationToken ) => FixProjectsAsync (
112
+ _globalOptions , project . Solution , [ project ] , context . EnabledFixIds , progress , cancellationToken ) ,
113
+ context ) . ConfigureAwait ( false ) ;
102
114
}
103
115
else if ( hierarchy . GetCanonicalName ( itemId , out var path ) == 0 )
104
116
{
@@ -122,37 +134,21 @@ private async Task<bool> FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h
122
134
123
135
var document = solution . GetRequiredDocument ( documentId ) ;
124
136
var options = _globalOptions . GetCodeActionOptions ( document . Project . Services ) ;
125
- return await FixDocumentAsync ( document , options , context ) . ConfigureAwait ( true ) ;
137
+
138
+ return await FixAsync (
139
+ _workspace ,
140
+ async ( progress , cancellationToken ) =>
141
+ {
142
+ var newDocument = await FixDocumentAsync ( document , context . EnabledFixIds , progress , options , cancellationToken ) . ConfigureAwait ( true ) ;
143
+ return newDocument . Project . Solution ;
144
+ } ,
145
+ context ) . ConfigureAwait ( false ) ;
126
146
}
127
147
}
128
148
129
149
return false ;
130
150
}
131
151
132
- private Task < bool > FixSolutionAsync ( Solution solution , ICodeCleanUpExecutionContext context )
133
- => FixAsync (
134
- solution . Workspace ,
135
- ( progress , cancellationToken ) => FixProjectsAsync (
136
- _globalOptions , solution , solution . Projects . Where ( p => p . SupportsCompilation ) . ToImmutableArray ( ) , context . EnabledFixIds , progress , cancellationToken ) ,
137
- context ) ;
138
-
139
- private Task < bool > FixProjectAsync ( Project project , ICodeCleanUpExecutionContext context )
140
- => FixAsync (
141
- project . Solution . Workspace ,
142
- ( progress , cancellationToken ) => FixProjectsAsync (
143
- _globalOptions , project . Solution , [ project ] , context . EnabledFixIds , progress , cancellationToken ) ,
144
- context ) ;
145
-
146
- private Task < bool > FixDocumentAsync ( Document document , CodeActionOptions options , ICodeCleanUpExecutionContext context )
147
- => FixAsync (
148
- document . Project . Solution . Workspace ,
149
- async ( progress , cancellationToken ) =>
150
- {
151
- var newDocument = await FixDocumentAsync ( document , context . EnabledFixIds , progress , options , cancellationToken ) . ConfigureAwait ( true ) ;
152
- return newDocument . Project . Solution ;
153
- } ,
154
- context ) ;
155
-
156
152
private Task < bool > FixTextBufferAsync ( TextBufferCodeCleanUpScope textBufferScope , ICodeCleanUpExecutionContext context )
157
153
{
158
154
var buffer = textBufferScope . SubjectBuffer ;
0 commit comments