Skip to content

GetParamBlock method of ProxyCommand fails #9058

@indented-automation

Description

@indented-automation

Steps to reproduce

[System.Management.Automation.ProxyCommand]::GetParamBlock((Get-Command Test-Connection))

Expected behavior

Emits a param block.

Actual behavior

Exception calling "GetParamBlock" with "1" argument(s): "Object reference not set to an instance of an object."
At line:1 char:1
+ [System.Management.Automation.ProxyCommand]::GetParamBlock((Get-Comma ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0-preview.3
PSEdition                      Core
GitCommitId                    6.2.0-preview.3
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Description

The Test-Connection command uses the new ValidateRangeKind type to force a positive integer.

The GetProxyAttributeData method of ParameterMetadata cannot parse and generate a string to represent this attribute. It is the method responsible for raising the error shown above.

ValidateRangeAttribute validRangeAttrib = attrib as ValidateRangeAttribute;
if (validRangeAttrib != null)
{
Type rangeType = validRangeAttrib.MinRange.GetType();
string format;
if (rangeType == typeof(float) || rangeType == typeof(double))
{
format = ValidateRangeFloatFormat;
}
else
{
format = ValidateRangeFormat;
}
result = string.Format(CultureInfo.InvariantCulture,
format, prefix,
validRangeAttrib.MinRange, validRangeAttrib.MaxRange);
return result;
}

PR

#9059

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions