mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
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:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user