File tree 1 file changed +23
-3
lines changed
1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -2079,6 +2079,26 @@ function GetTypeString
2079
2079
return $TypeObjectHash.Name
2080
2080
}
2081
2081
2082
+ <#
2083
+ You cannot just write 0..($n-1) because if $n == 0 you are screwed.
2084
+ Hence this helper.
2085
+ #>
2086
+ function GetRange
2087
+ {
2088
+ Param (
2089
+ [CmdletBinding ()]
2090
+ [parameter (mandatory = $true )]
2091
+ [int ]$n
2092
+ )
2093
+ if ($n -lt 0 ) {
2094
+ throw " GetRange $n is unsupported: value less then 0"
2095
+ }
2096
+ if ($n -eq 0 ) {
2097
+ return
2098
+ }
2099
+ 0 .. ($n - 1 )
2100
+ }
2101
+
2082
2102
<#
2083
2103
This function proxies Get-Command call.
2084
2104
@@ -2174,7 +2194,7 @@ function MyGetCommand
2174
2194
Write-Error $errStr
2175
2195
}
2176
2196
2177
- foreach ($i in 0 .. ( $parameters.Length - 1 )) {
2197
+ foreach ($i in (GetRange $parameters.Length )) {
2178
2198
$typeObjectHash = New-Object - TypeName pscustomobject - Property @ {
2179
2199
Name = $parameterType [$i ].Name
2180
2200
IsGenericType = $parameterType [$i ].IsGenericType
@@ -2195,8 +2215,8 @@ function MyGetCommand
2195
2215
2196
2216
$psets = expand ' ParameterSets'
2197
2217
$psetsArray = @ ()
2198
- foreach ($i in 0 .. ( $psets.Count - 1 )) {
2199
- $parameters = getParams $i $psets .Count
2218
+ foreach ($i in (GetRange $psets.Count )) {
2219
+ $parameters = getParams $i
2200
2220
$psetsArray += @ (New-Object - TypeName pscustomobject - Property @ {
2201
2221
Name = $psets [$i ].Name
2202
2222
IsDefault = $psets [$i ].IsDefault
You can’t perform that action at this time.
0 commit comments