platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

Mandatory parameters are generated inconsistently

Open chscott opened this issue 4 years ago • 1 comments

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

chscott avatar Jun 14 '21 19:06 chscott

@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?

theJasonHelmick avatar Jun 21 '21 17:06 theJasonHelmick

Not able to reproduce the issue shown.

sdwheeler avatar May 31 '24 17:05 sdwheeler