diff --git a/Engine/CommandInfoCache.cs b/Engine/CommandInfoCache.cs index 61e78d86b..02e926b53 100644 --- a/Engine/CommandInfoCache.cs +++ b/Engine/CommandInfoCache.cs @@ -70,21 +70,6 @@ public CommandInfo GetCommandInfo(string commandName, CommandTypes? commandTypes return _commandInfoCache.GetOrAdd(key, new Lazy(() => GetCommandInfoInternal(commandName, commandTypes))).Value; } - /// - /// Retrieve a command info object about a command. - /// - /// Name of the command to get a commandinfo object for. - /// What types of command are needed. If omitted, all types are retrieved. - /// - [Obsolete("Alias lookup is expensive and should not be relied upon for command lookup")] - public CommandInfo GetCommandInfoLegacy(string commandOrAliasName, CommandTypes? commandTypes = null) - { - string commandName = _helperInstance.GetCmdletNameFromAlias(commandOrAliasName); - - return string.IsNullOrEmpty(commandName) - ? GetCommandInfo(commandOrAliasName, commandTypes: commandTypes) - : GetCommandInfo(commandName, commandTypes: commandTypes); - } /// /// Get a CommandInfo object of the given command name diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 71be95b4b..ae5858587 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -667,20 +667,6 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanTwoPositiona return moreThanTwoPositional ? argumentsWithoutProcedingParameters > 2 : argumentsWithoutProcedingParameters > 0; } - /// - /// Legacy method, new callers should use instead. - /// Given a command's name, checks whether it exists. It does not use the passed in CommandTypes parameter, which is a bug. - /// But existing method callers are already depending on this behaviour and therefore this could not be simply fixed. - /// It also populates the commandInfoCache which can have side effects in some cases. - /// - /// Command Name. - /// Not being used. - /// - [Obsolete] - public CommandInfo GetCommandInfoLegacy(string name, CommandTypes? commandType = null) - { - return CommandInfoCache.GetCommandInfoLegacy(commandOrAliasName: name, commandTypes: commandType); - } /// /// Given a command's name, checks whether it exists. diff --git a/Rules/UseCmdletCorrectly.cs b/Rules/UseCmdletCorrectly.cs index 7762538e4..a0d08e2c1 100644 --- a/Rules/UseCmdletCorrectly.cs +++ b/Rules/UseCmdletCorrectly.cs @@ -85,7 +85,7 @@ private bool MandatoryParameterExists(CommandAst cmdAst) { #region Compares parameter list and mandatory parameter list. - CommandInfo cmdInfo = Helper.Instance.GetCommandInfoLegacy(cmdAst.GetCommandName()); + CommandInfo cmdInfo = Helper.Instance.GetCommandInfo(cmdAst.GetCommandName()); // If we can't resolve the command or it's not a cmdlet, we are done if (cmdInfo == null || (cmdInfo.CommandType != System.Management.Automation.CommandTypes.Cmdlet)) diff --git a/Rules/UseShouldProcessCorrectly.cs b/Rules/UseShouldProcessCorrectly.cs index 6cacc2634..e08ca098a 100644 --- a/Rules/UseShouldProcessCorrectly.cs +++ b/Rules/UseShouldProcessCorrectly.cs @@ -299,7 +299,7 @@ private bool SupportsShouldProcess(string cmdName) return false; } - var cmdInfo = Helper.Instance.GetCommandInfoLegacy(cmdName); + var cmdInfo = Helper.Instance.GetCommandInfo(cmdName); if (cmdInfo == null) { return false;