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.
This commit is contained in:
James Truher [MSFT]
2024-06-03 21:20:55 +05:00
committed by GitHub
parent 51b8e5d1da
commit 7f99fa1bf3
2 changed files with 19 additions and 3 deletions
@@ -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))
{
@@ -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"
}
}