Skip to content

Pseudobinding assumes all ValueFromPipeline parameters get a value from the pipeline #27121

@MartinGC94

Description

@MartinGC94

Prerequisites

Steps to reproduce

If you define a function with 2 pipeline inputs like this:

function Test
{
    Param
    (
        [Parameter(ValueFromPipeline)]
        [string]
        $Param1,

        [Parameter(ValueFromPipeline)]
        [int]
        $Param2
    )

    $PSBoundParameters
}

When you try to tab complete the parameters for the function like this: "Hej" | Test -<Tab> it won't show Param2 as an available parameter even though it should be available because I'm passing in a string. This disincentivizes adding pipeline support to parameters because if the user uses the pipeline they'll get annoyed and confused at the missing parameters.

A real world example of this is a module I'm working on where I'd like to be able to do: $Driver | Install-DeviceDriver -Device XYZ or $Device | Install-DeviceDriver -Driver ABC but now I have to choose one of them.

Expected behavior

Pseudobinding takes the inferred type of the pipeline input into consideration when determining which parameters are bound. Allowing the unbound parameters to show up in tab completion.

Actual behavior

Pseudobinding does not take the inferred type of the pipeline input into consideration when determining which parameters are bound. This prevents the unbound parameters from showing up in tab completion.

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.0-preview.5
PSEdition                      Core
GitCommitId                    7.6.0-preview.5
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions