Skip to content

GetParamBlock method of ProxyCommand fails #9058

Closed

Description

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

Activity

  1. added
    Issue-Question
    on Mar 5, 2019
  2. changed the title [-]My bug report[/-] [+]GetParamBlock method of ProxyCommand fails[/+] on Mar 5, 2019
  3. added
    Issue-Bug
    WG-Engine
    and removed
    Issue-Question
    on Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugResolution-FixedWG-Engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions