platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

Incorrect Syntax generated for Parameters with multiple Positions

Open Herrmel opened this issue 4 years ago • 2 comments

Steps to reproduce

have function like this:

function ConvertTo-Type{
	param(
		[Parameter(Position = 0,Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName,ParameterSetName='ExplicitType')]
                [Parameter(Position = 1,Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName,ParameterSetName='NamedType')][AllowNull()]$InputObject,
		[Parameter(Position = 1,Mandatory,ParameterSetName='ExplicitType')][ValidateNotNull()][type]$TargetType,
		[Parameter(Position = 0,Mandatory,ParameterSetName='NamedType')][ValidateNotNullOrEmpty()][string]$TargetTypeIdentifier
	)
	process
	{
		#TODO
	}
}

Generate new-MarkdownHelp

Expected behavior

Syntax is like Get-Command ConvertTo-Type -Syntax:

ConvertTo-Type [-TargetTypeIdentifier] <string> [-InputObject] <Object> [<CommonParameters>]

ConvertTo-Type [-InputObject] <Object> [-TargetType] <type> [<CommonParameters>]

Actual behavior

Output Syntax in Markdown is:

    ### NamedType
    ```
    ConvertTo-Type [-InputObject] <Object> [-TargetTypeIdentifier] <String> [<CommonParameters>]
    ```

    ### ExplicitType
    ```
    ConvertTo-Type [-InputObject] <Object> [-TargetType] <Type> [<CommonParameters>]
    ```

Paramterinfo for $InputObject is also only available once (there should be multiple yamls right?):

    ### -InputObject
    {{ Fill InputObject Description }}
    ```yaml
    Type: Object
    Parameter Sets: (All)
    Aliases:
    
    Required: True
    Position: 1
    Default value: None
    Accept pipeline input: True (ByPropertyName, ByValue)
    Accept wildcard characters: False
    ```

Environment data

PSVersion: 7.1.2 OS: Windows

I know this is probably a wierd edgecase 😅

Herrmel avatar Apr 16 '21 14:04 Herrmel

@Herrmel Thanks you for adding this issue - can you tell me what version of PlatyPS you are using for this?

theJasonHelmick avatar Jul 20 '21 15:07 theJasonHelmick

I just tested this with PlatyPS 0.14.2 and got the same result.

sdwheeler avatar Jul 20 '21 15:07 sdwheeler

Microsoft.PowerShell.PlatyPS v1 now creates parameter metadata for each parameter set.

sdwheeler avatar May 31 '24 16:05 sdwheeler