@@ -132,15 +132,22 @@ private List<CorrectionExtent> GetCorrections(
132
132
correctionExtents . Add ( GetCorrectionToRemoveParam ( confirmIndex , parameterAsts ) ) ;
133
133
}
134
134
135
- AttributeAst attributeAst ;
135
+ AttributeAst attributeAst = paramBlockAst . GetCmdletBindingAttributeAst ( ) ;
136
136
137
137
// check if it has cmdletbinding attribute
138
- if ( TryGetCmdletBindingAttribute ( paramBlockAst , out attributeAst ) )
138
+ if ( attributeAst != null )
139
139
{
140
140
NamedAttributeArgumentAst shouldProcessAst = attributeAst . GetSupportsShouldProcessAst ( ) ;
141
141
if ( shouldProcessAst != null )
142
142
{
143
-
143
+ ExpressionAst argAst ;
144
+ if ( ! shouldProcessAst . IsTrue ( out argAst )
145
+ && argAst != null )
146
+ {
147
+ // SupportsShouldProcess is set to something other than $true.
148
+ // Set it to $true
149
+ correctionExtents . Add ( GetCorrectionsToSetShouldProcessToTrue ( argAst ) ) ;
150
+ }
144
151
}
145
152
else
146
153
{
@@ -198,6 +205,17 @@ private List<CorrectionExtent> GetCorrections(
198
205
return result ;
199
206
}
200
207
208
+ private CorrectionExtent GetCorrectionsToSetShouldProcessToTrue ( ExpressionAst argAst )
209
+ {
210
+ return new CorrectionExtent (
211
+ argAst . Extent . StartLineNumber ,
212
+ argAst . Extent . EndLineNumber ,
213
+ argAst . Extent . StartColumnNumber ,
214
+ argAst . Extent . EndColumnNumber ,
215
+ "$true" ,
216
+ argAst . Extent . File ) ;
217
+ }
218
+
201
219
private CorrectionExtent GetCorrectionToAddParamBlock (
202
220
FunctionDefinitionAst funcDefnAst ,
203
221
ParameterAst [ ] parameterAsts )
@@ -281,14 +299,6 @@ private CorrectionExtent Normalize(
281
299
correctionExtent . Description ) ;
282
300
}
283
301
284
- private static bool TryGetCmdletBindingAttribute (
285
- ParamBlockAst paramBlockAst ,
286
- out AttributeAst attributeAst )
287
- {
288
- attributeAst = paramBlockAst . GetCmdletBindingAttributeAst ( ) ;
289
- return attributeAst != null ;
290
- }
291
-
292
302
private static CorrectionExtent GetCorrectionToAddAttribute ( ParamBlockAst paramBlockAst )
293
303
{
294
304
return new CorrectionExtent (
0 commit comments