Fix parameter name in the Get-Variable cmdlet error message. (#7384)

Before the fix when using Get-Variable or Get-Alias cmdlets with the -Scope parameter with wrong value, the error message refers to 'scopeID' parameter instead of 'Scope'.
This commit is contained in:
Sergey Vasin
2018-07-31 08:50:41 +05:00
committed by Ilya
parent ca7f103a15
commit fcc519bb08
2 changed files with 10 additions and 5 deletions
@@ -21,6 +21,11 @@ namespace System.Management.Automation
/// </summary>
private SessionStateScope _currentScope;
/// <summary>
/// Cmdlet parameter name to return in the error message instead of "scopeID".
/// </summary>
internal const string ScopeParameterName = "Scope";
/// <summary>
/// Given a scope identifier, returns the proper session state scope.
/// </summary>
@@ -92,18 +97,18 @@ namespace System.Management.Automation
if (scopeNumericID < 0)
{
throw PSTraceSource.NewArgumentOutOfRangeException("scopeID", scopeID);
throw PSTraceSource.NewArgumentOutOfRangeException(ScopeParameterName, scopeID);
}
result = GetScopeByID(scopeNumericID) ?? _currentScope;
}
catch (FormatException)
{
throw PSTraceSource.NewArgumentException("scopeID", AutomationExceptions.InvalidScopeIdArgument, "scopeID");
throw PSTraceSource.NewArgumentException(ScopeParameterName, AutomationExceptions.InvalidScopeIdArgument, ScopeParameterName);
}
catch (OverflowException)
{
throw PSTraceSource.NewArgumentOutOfRangeException("scopeID", scopeID);
throw PSTraceSource.NewArgumentOutOfRangeException(ScopeParameterName, scopeID);
}
}
}
@@ -144,7 +149,7 @@ namespace System.Management.Automation
{
ArgumentOutOfRangeException outOfRange =
PSTraceSource.NewArgumentOutOfRangeException(
"scopeID",
ScopeParameterName,
originalID,
SessionStateStrings.ScopeIDExceedsAvailableScopes,
originalID);
@@ -121,7 +121,7 @@
<value>Cannot process argument because the value of argument "{0}" is not valid. Change the value of the "{0}" argument and run the operation again.</value>
</data>
<data name="InvalidScopeIdArgument" xml:space="preserve">
<value>Cannot process argument because the value of argument "{0}" is not valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). Change the value of the "{0}" argument and run the operation again.</value>
<value>Cannot process argument because the value of parameter "{0}" is not valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). Change the value of the "{0}" parameter and run the operation again.</value>
</data>
<data name="ArgumentNull" xml:space="preserve">
<value>Cannot process argument because the value of argument "{0}" is null. Change the value of argument "{0}" to a non-null value.</value>