nightroman/Helps

Bug with a parameter named 'Keys'

LaurentDardenne opened this issue · 3 comments

A function with a parameter named Keys does not generates a list of parameter.

function New-MatchesObject{
param (
[Parameter(Mandatory=$true,position=0)]
[ValidateNotNullOrEmpty()]
$InputObject,
[Parameter(Mandatory=$true,position=1)]
[ValidateNotNullOrEmpty()]
[String] $TypeName,
[Parameter(Mandatory=$true,position=2)]
[ValidateNotNullOrEmpty()]
[String] $Regex,
[Parameter(Mandatory=$false,position=3)]
[ValidateNotNullOrEmpty()]
[object[]] $Keys
)
{ write-host "test" }

See file Helps.ps1 :
function Helps.NewCommand(
...
$parameters = @($Command.Parameters.Keys | Sort-Object)

'$Command.Parameters' is a dictionnary...

Change :
$parameters = @($Command.Parameters.Keys | Sort-Object)

with
$parameters = @($Command.Parameters.PSBase.Keys | Sort-Object)

And the others calls of the members of 'Parameters' : ( .values, .count...)

I'll take a look at this shortly. Thank you for reporting this.

Fixed and uploaded to NuGet. So far only the name Keys seems to be problematic.