Skip to content

[System.Management.Automation.CompletionResult]::new considered empty string as null #26620

@sharpchen

Description

@sharpchen

Prerequisites

Steps to reproduce

completionText, listItemText and toolTip are considered $null when is a empty string
This is undocumented and confusing.

[System.Management.Automation.CompletionResult]::new(
    'foo', # completionText
    'foo', # listItemText
    [System.Management.Automation.CompletionResultType]::ParameterValue,
    '' # toolTip
)
MethodInvocationException: Exception calling ".ctor" with "4" argument(s): "Cannot process argument because the value of argument "toolTip" is null. Change the
value of argument "toolTip" to a non-null value."

Expected behavior

Correct error message

Actual behavior

empty string is considered null

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.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