File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,8 @@ commandInfo is CmdletInfo ||
100
100
// We can also simplify the string if desired.
101
101
private string GetAdjustedTypename ( Type t , bool simplify = false )
102
102
{
103
- string tName = simplify ? LanguagePrimitives . ConvertTo < string > ( t ) : t . FullName ;
103
+ var t2 = Nullable . GetUnderlyingType ( t ) ?? t ;
104
+ string tName = simplify ? LanguagePrimitives . ConvertTo < string > ( t2 ) : t2 . FullName ;
104
105
return tName ;
105
106
}
106
107
@@ -847,7 +848,14 @@ protected List<InputOutput> GetInputOutputItemsFromHelp(dynamic typesInfo)
847
848
// We also will remove trailing [] because we should generally return singletons
848
849
private string FixUpTypeName ( string typename )
849
850
{
850
- string fixedString = typename . Trim ( ) ;
851
+ // If the type is a generic type, we need to remove the backtick and the number.
852
+ string fixedString = typename . Replace ( "System.Nullable`1[[" , string . Empty ) . Trim ( ) ;
853
+ int commaIndex = fixedString . IndexOf ( ',' ) ;
854
+ if ( commaIndex >= 0 )
855
+ {
856
+ fixedString = fixedString . Substring ( 0 , commaIndex ) . Trim ( ) ;
857
+ }
858
+
851
859
if ( fixedString . EndsWith ( "[]" ) )
852
860
{
853
861
fixedString = fixedString . Remove ( fixedString . Length - 2 ) ;
Original file line number Diff line number Diff line change @@ -141,6 +141,20 @@ Describe "New-CommandHelp tests" {
141
141
BeforeAll {
142
142
$cmd = Get-Command Get-Command
143
143
$ch = $cmd | New-CommandHelp
144
+
145
+ function global :Test-InputOutputTypes
146
+ {
147
+ [CmdletBinding ()]
148
+ [OutputType ()]
149
+ param (
150
+ [Parameter (Mandatory = $true , ValueFromPipeline = $true )]
151
+ [Nullable [int ]]$InputString
152
+ )
153
+
154
+ Write-Output " Processed: $InputString "
155
+ }
156
+
157
+ $io = New-CommandHelp - Command (Get-Command Test-InputOutputTypes )
144
158
}
145
159
146
160
It " Should have the proper number of output types" {
@@ -176,12 +190,16 @@ Describe "New-CommandHelp tests" {
176
190
@ { Type = " System.Management.Automation.CommandTypes" }
177
191
@ { Type = " System.Int32" }
178
192
@ { Type = " Microsoft.PowerShell.Commands.ModuleSpecification[]" }
179
- @ { Type = " System.String" }
193
+ @ { Type = " System.String[] " }
180
194
@ { Type = " System.Management.Automation.SwitchParameter" }
181
195
) {
182
196
param ($type )
183
197
$ch.inputs.typename | Should - Contain $type
184
198
}
185
- }
186
199
200
+ It " Should not have Nullable in the input type" {
201
+ $io.inputs.typename | Should -Not - Contain " Nullable"
202
+ $io.inputs.typename | Should - Be " System.Int32"
203
+ }
204
+ }
187
205
}
You can’t perform that action at this time.
0 commit comments