Skip to content

Commit 87a7814

Browse files
author
Kapil Borle
committed
Add param block and cmdletbinding in correction
1 parent 2f88672 commit 87a7814

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

rules/UseSupportsShouldProcess.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ private List<CorrectionExtent> GetCorrections(
179179
else
180180
{
181181
// has no cmdletbinding attribute
182-
// add the attribute and supportsshouldprocess argument
182+
// hence, add the attribute and supportsshouldprocess argument
183+
correctionExtents.Add(GetCorrectionExtent(paramBlockAst));
183184
}
184185
}
185186
else
@@ -238,7 +239,21 @@ private static bool TryGetCmdletBindingAttribute(
238239
return attributeAst != null;
239240
}
240241

242+
private static CorrectionExtent GetCorrectionExtent(ParamBlockAst paramBlockAst)
243+
{
244+
245+
string correctionText = new String(' ', paramBlockAst.Extent.StartColumnNumber - 1)
246+
+ "CmdletBinding(SupportsShouldProcess)"
247+
+ Environment.NewLine;
241248

249+
return new CorrectionExtent(
250+
paramBlockAst.Extent.StartLineNumber,
251+
paramBlockAst.Extent.EndLineNumber,
252+
1,
253+
1,
254+
correctionText,
255+
null);
256+
}
242257
private static CorrectionExtent GetCorrectionExtent(AttributeAst cmdletBindingAttributeAst)
243258
{
244259
// 1 for 1 based offset and 1 for the next position.

0 commit comments

Comments
 (0)