Skip to content

Commit 1c0cfef

Browse files
authored
Remove legacy methods (#1387)
1 parent 6a5d2ff commit 1c0cfef

File tree

4 files changed

+2
-31
lines changed

4 files changed

+2
-31
lines changed

Engine/CommandInfoCache.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,6 @@ public CommandInfo GetCommandInfo(string commandName, CommandTypes? commandTypes
7070
return _commandInfoCache.GetOrAdd(key, new Lazy<CommandInfo>(() => GetCommandInfoInternal(commandName, commandTypes))).Value;
7171
}
7272

73-
/// <summary>
74-
/// Retrieve a command info object about a command.
75-
/// </summary>
76-
/// <param name="commandName">Name of the command to get a commandinfo object for.</param>
77-
/// <param name="commandTypes">What types of command are needed. If omitted, all types are retrieved.</param>
78-
/// <returns></returns>
79-
[Obsolete("Alias lookup is expensive and should not be relied upon for command lookup")]
80-
public CommandInfo GetCommandInfoLegacy(string commandOrAliasName, CommandTypes? commandTypes = null)
81-
{
82-
string commandName = _helperInstance.GetCmdletNameFromAlias(commandOrAliasName);
83-
84-
return string.IsNullOrEmpty(commandName)
85-
? GetCommandInfo(commandOrAliasName, commandTypes: commandTypes)
86-
: GetCommandInfo(commandName, commandTypes: commandTypes);
87-
}
8873

8974
/// <summary>
9075
/// Get a CommandInfo object of the given command name

Engine/Helper.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -667,20 +667,6 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanTwoPositiona
667667
return moreThanTwoPositional ? argumentsWithoutProcedingParameters > 2 : argumentsWithoutProcedingParameters > 0;
668668
}
669669

670-
/// <summary>
671-
/// Legacy method, new callers should use <see cref="GetCommandInfo"/> instead.
672-
/// Given a command's name, checks whether it exists. It does not use the passed in CommandTypes parameter, which is a bug.
673-
/// But existing method callers are already depending on this behaviour and therefore this could not be simply fixed.
674-
/// It also populates the commandInfoCache which can have side effects in some cases.
675-
/// </summary>
676-
/// <param name="name">Command Name.</param>
677-
/// <param name="commandType">Not being used.</param>
678-
/// <returns></returns>
679-
[Obsolete]
680-
public CommandInfo GetCommandInfoLegacy(string name, CommandTypes? commandType = null)
681-
{
682-
return CommandInfoCache.GetCommandInfoLegacy(commandOrAliasName: name, commandTypes: commandType);
683-
}
684670

685671
/// <summary>
686672
/// Given a command's name, checks whether it exists.

Rules/UseCmdletCorrectly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private bool MandatoryParameterExists(CommandAst cmdAst)
8585
{
8686
#region Compares parameter list and mandatory parameter list.
8787

88-
CommandInfo cmdInfo = Helper.Instance.GetCommandInfoLegacy(cmdAst.GetCommandName());
88+
CommandInfo cmdInfo = Helper.Instance.GetCommandInfo(cmdAst.GetCommandName());
8989

9090
// If we can't resolve the command or it's not a cmdlet, we are done
9191
if (cmdInfo == null || (cmdInfo.CommandType != System.Management.Automation.CommandTypes.Cmdlet))

Rules/UseShouldProcessCorrectly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ private bool SupportsShouldProcess(string cmdName)
299299
return false;
300300
}
301301

302-
var cmdInfo = Helper.Instance.GetCommandInfoLegacy(cmdName);
302+
var cmdInfo = Helper.Instance.GetCommandInfo(cmdName);
303303
if (cmdInfo == null)
304304
{
305305
return false;

0 commit comments

Comments
 (0)