Skip to content

Commit 9c6e03c

Browse files
author
Kapil Borle
committed
Make UseShouldProcessCorrectly use updated getcommandinfo
1 parent a5c12c0 commit 9c6e03c

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

Rules/UseShouldProcessCorrectly.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -297,29 +297,6 @@ private bool DeclaresSupportsShouldProcess(FunctionDefinitionAst ast)
297297
return Helper.Instance.GetNamedArgumentAttributeValue(shouldProcessAttribute);
298298
}
299299

300-
/// <summary>
301-
/// Get a CommandInfo object of the given command name
302-
/// </summary>
303-
/// <returns>Returns null if command does not exists</returns>
304-
private CommandInfo GetCommandInfo(string cmdName)
305-
{
306-
try
307-
{
308-
using (var ps = System.Management.Automation.PowerShell.Create())
309-
{
310-
var cmdInfo = ps.AddCommand("Get-Command")
311-
.AddArgument(cmdName)
312-
.Invoke<CommandInfo>()
313-
.FirstOrDefault();
314-
return cmdInfo;
315-
}
316-
}
317-
catch (System.Management.Automation.CommandNotFoundException)
318-
{
319-
return null;
320-
}
321-
}
322-
323300
/// <summary>
324301
/// Checks if the given command supports ShouldProcess
325302
/// </summary>
@@ -331,7 +308,7 @@ private bool SupportsShouldProcess(string cmdName)
331308
return false;
332309
}
333310

334-
var cmdInfo = GetCommandInfo(cmdName);
311+
var cmdInfo = Helper.Instance.GetCommandInfo(cmdName);
335312
if (cmdInfo == null)
336313
{
337314
return false;

0 commit comments

Comments
 (0)