From 7f99fa1bf3ecbb4a16e70c90e6736f584df19ef9 Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Mon, 3 Jun 2024 09:20:55 -0700 Subject: [PATCH] Get-Help may report parameters with `ValueFromRemainingArguments` attribute as pipeline-able (#23871) * Remove FromRemainingArguments as an inputs indicator. The parameter attribute FromRemainingArguments is not an indicator of pipeline input. --- .../help/DefaultCommandHelpObjectBuilder.cs | 4 +--- .../engine/Help/HelpSystem.Tests.ps1 | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs b/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs index d553f242c1..bce76b005a 100644 --- a/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs +++ b/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs @@ -605,9 +605,7 @@ namespace System.Management.Automation.Help foreach (ParameterAttribute attrib in attribs) { - if (attrib.ValueFromPipeline || - attrib.ValueFromPipelineByPropertyName || - attrib.ValueFromRemainingArguments) + if (attrib.ValueFromPipeline || attrib.ValueFromPipelineByPropertyName) { if (!inputs.Contains(parameter.Value.ParameterType.FullName)) { diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index 380aca1e2b..a17394c1d9 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -695,3 +695,21 @@ Describe 'Update-Help allows partial culture matches' -Tags 'CI' { Test-UpdateHelpAux $null $Pass } } + +Describe 'InputTypes accurately describe pipelinable input' { + BeforeAll { + function invoke-inputtypetest { + [CmdletBinding()] + param ( + [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string]$a, + [Parameter(Position=1,ValueFromRemainingArguments=$true)][object[]]$c) + Process { "$a $c" } + } + } + + It 'Should have only 1 input type' { + $inputTypes = (Get-Help -full invoke-inputtypetest).inputtypes.inputtype.type.name.trim().split("`n") + $inputTypes.Count | Should -Be 1 + $inputTypes | Should -Be "System.String" + } +}