PowerShell / platyPS

Write PowerShell External Help in Markdown
MIT License
778 stars 152 forks source link

Mandatory parameters are generated inconsistently #543

Closed chscott closed 5 months ago

chscott commented 3 years ago

Steps to reproduce

I have two function signatures, like so:

function Function1 {
  [CmdletBinding()]
  [OutputType([Void])]
  Param(
    [Parameter(Mandatory)][String] $Csv,
    [Parameter(Mandatory)][String][ValidateSet('Google')] $Target,
    [Parameter(Mandatory)][String] $TargetKey,
    [Parameter()][Switch] $DryRun = $false,
    [Parameter()][String][ValidateSet('None', 'Normal', 'Detailed', 'Diagnostic')] $Verbosity = 'Detailed'
  )
function Function2 {
  [CmdletBinding()]
  [OutputType([Void])]
  Param(
    [Parameter(Mandatory)][String] $Csv,
    [Parameter(Mandatory)][String][ValidateSet('Google')] $Target,
    [Parameter(Mandatory)][String] $TargetKey,
    [Parameter()][Switch] $ServerSide = $false,
    [Parameter()][Switch] $DryRun = $false,
    [Parameter()][String][ValidateSet('None', 'Normal', 'Detailed', 'Diagnostic')] $Verbosity = 'Detailed'
  )

The generated syntax looks like this:

Function1 [-Csv] <String> [-Target] <String> [-TargetKey] <String> [-DryRun]
 [[-Verbosity] <String>] [<CommonParameters>]
Function2 [-Csv] <String> -Target <String> [-TargetKey] <String> [-ServerSide] [-DryRun]
 [[-Verbosity] <String>] [<CommonParameters>]

Expected behavior

I expect them to be the same. Since I don't have positions specified, I would think the second example is correct, but that would make other parameters like $TargetKey wrong, too.

Actual behavior

As shown above.

Environment data

v0.14.0

theJasonHelmick commented 3 years ago

@chscott, thanks for reporting this issue. We were not able to reproduce your results with 0.14.1 and our newer preview of 2.0.0. Can you upgrade to 0.14.1 and let me know if you get the same results?

sdwheeler commented 5 months ago

Not able to reproduce the issue shown.