Skip to content

New-MarkdownCommandHelp command outputs wrong parameter value type #822

@teramako

Description

@teramako

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

Wrong result is output when the parameter type is nested type from generic class like following:

System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,System.Int64]
PS> function Test-Cmd {
>   param(
>     [Parameter()] [System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,long]] $AAA
>   )
> }

PS> $cmd = Get-Command Test-Cmd

PS> $file1 = New-MarkdownCommandHelp -CommandInfo $cmd -Encoding utf8NoBOM -OutputFolder /tmp/A

PS> Get-Content $file1 | ? { $_ -match "^Test-Cmd|^Type" }

Test-Cmd [[-AAA] <Dictionary`2+Enumerator`2[int,long]>]
Type: System.Collections.Generic.Dictionary`2[System.Int32,System.Int64]

PS> $file2 = New-MarkdownCommandHelp -CommandInfo $cmd -Encoding utf8NoBOM -OutputFolder /tmp/B -AbbreviateParameterTypeName

PS> Get-Content $file2 | ? { $_ -match "^Test-Cmd|^Type" }
Test-Cmd [[-AAA] <Dictionary`2+Enumerator`2[int,long]>]
Type: Enumerator`2[System.Int32,System.Int64]

Expected behavior

FullParameterType

$file1 = New-MarkdownCommandHelp -CommandInfo $cmd -Encoding utf8NoBOM -OutputFolder /tmp/A
Get-Content $file1 | ? { $_ -match "^Test-Cmd|^Type" }
Expected Output:
Test-Cmd [[-AAA] <Dictionary`2+Enumerator[int,long]>]
Type: System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,System.Int64]

AbbreviateParameterType

$file2 = New-MarkdownCommandHelp -CommandInfo $cmd -Encoding utf8NoBOM -OutputFolder /tmp/B -AbbreviateParameterTypeName
Get-Content $file2 | ? { $_ -match "^Test-Cmd|^Type" }
Expected Output:
Test-Cmd [[-AAA] <Dictionary`2+Enumerator[int,long]>]
Type: Dictionary`2+Enumerator[int,long]

Actual behavior

FullParameterType

$file1 = New-MarkdownCommandHelp -CommandInfo $cmd -Encoding utf8NoBOM -OutputFolder /tmp/A
Get-Content $file1 | ? { $_ -match "^Test-Cmd|^Type" }
Actual Output:
Test-Cmd [[-AAA] <Dictionary`2+Enumerator`2[int,long]>]
Type: System.Collections.Generic.Dictionary`2[System.Int32,System.Int64]
  • Syntax:
    • The trailing "`2" is not necessary.
  • Type:
    • "Enumerator" class name is missing.

AbbreviateParameterType

$file2 = New-MarkdownCommandHelp -CommandInfo $cmd -Encoding utf8NoBOM -OutputFolder /tmp/B -AbbreviateParameterTypeName
Get-Content $file2 | ? { $_ -match "^Test-Cmd|^Type" }
Actual Output:
Test-Cmd [[-AAA] <Dictionary`2+Enumerator`2[int,long]>]
Type: Enumerator`2[System.Int32,System.Int64]
  • Syntax:
    • The trailing "`2" is not necessary.
  • Type:
    • The nesting source class name "Dictionary" is missing.
    • Parameters of generic type are not abbreviated.

### Error details

```console

Environment data

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Ubuntu 24.04.3 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

1.0.1

Visuals

In particular, when using the -AbbreviateParameterTypeName parameter, I would like the output to be the same as the Get-Help command.

Image

Metadata

Metadata

Labels

Needs-TriageThe issue is new and needs to be triaged by a work group.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions