|
28 | 28 | [System.Reflection.BindingFlags]$script:InstanceBindingFlags = [System.Reflection.BindingFlags]::Public -bor [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::FlattenHierarchy
|
29 | 29 |
|
30 | 30 | # Common/ubiquitous cmdlet parameters which we don't want to repeat over and over
|
31 |
| -[string[]]$script:CommonParams = @( |
| 31 | +[System.Collections.Generic.HashSet[string]]$script:CommonParameters = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase) |
| 32 | + |
| 33 | +$commonParams = @( |
32 | 34 | 'Verbose'
|
33 | 35 | 'Debug'
|
34 | 36 | 'ErrorAction'
|
|
42 | 44 | 'PipelineVariable'
|
43 | 45 | )
|
44 | 46 |
|
45 |
| -# The file name for the any-platform reference generated from the union of all other platforms |
46 |
| -[string]$script:AnyPlatformReferenceProfileFilePath = [System.IO.Path]::Combine($script:CompatibilityProfileDir, 'anyplatform_union.json') |
47 |
| - |
48 |
| -<# |
49 |
| -.SYNOPSIS |
50 |
| -Turn the common parameters into a hashset for faster matching. |
51 |
| -#> |
52 |
| -function New-CommonParameterSet |
| 47 | +foreach ($p in $commonParams) |
53 | 48 | {
|
54 |
| - $set = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase) |
55 |
| - |
56 |
| - foreach ($p in $script:commonParams) |
57 |
| - { |
58 |
| - $set.Add($p) |
59 |
| - } |
60 |
| - |
61 |
| - return $set |
| 49 | + $null = $script:CommonParameters.Add($p) |
62 | 50 | }
|
63 | 51 |
|
64 |
| -# Set of the common cmdlet parameters to exclude from cmdlet data |
65 |
| -[System.Collections.Generic.HashSet[string]]$script:CommonParameters = New-CommonParameterSet |
66 |
| - |
67 |
| -# User module path location |
68 |
| -[string]$script:UserModulePath = [System.Management.Automation.ModuleIntrinsics].GetMethod('GetPersonalModulePath', [System.Reflection.BindingFlags]'static,nonpublic').Invoke($null, @()) |
| 52 | +# The file name for the any-platform reference generated from the union of all other platforms |
| 53 | +[string]$script:AnyPlatformReferenceProfileFilePath = [System.IO.Path]::Combine($script:CompatibilityProfileDir, 'anyplatform_union.json') |
69 | 54 |
|
70 |
| -# Shared module path location |
| 55 | +# User and Shared module path locations |
71 | 56 | if ($PSVersionTable.PSVersion.Major -ge 6)
|
72 | 57 | {
|
| 58 | + [string]$script:UserModulePath = [System.Management.Automation.ModuleIntrinsics].GetMethod('GetPersonalModulePath', [System.Reflection.BindingFlags]'static,nonpublic').Invoke($null, @()) |
73 | 59 | [string]$script:SharedModulePath = [System.Management.Automation.ModuleIntrinsics].GetMethod('GetSharedModulePath', [System.Reflection.BindingFlags]'static,nonpublic').Invoke($null, @())
|
74 | 60 | }
|
75 | 61 | else
|
76 | 62 | {
|
| 63 | + $documentsFolder = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Personal) |
| 64 | + [string]$script:UserModulePath = "$documentsFolder\PowerShell\Modules" |
77 | 65 | [string]$script:SharedModulePath = "$env:ProgramFiles\WindowsPowerShell\Modules"
|
78 | 66 | }
|
79 | 67 |
|
@@ -210,8 +198,10 @@ function New-PowerShellCompatibilityProfile
|
210 | 198 | $OutFile = Join-Path $script:CompatibilityProfileDir "$platformNameStr.json"
|
211 | 199 | }
|
212 | 200 |
|
213 |
| - $json = ConvertTo-CompatibilityJson -Item $reportData -NoWhitespace:(-not $Readable) |
214 |
| - return New-Item -Path $OutFile -Value $json -Force |
| 201 | + ConvertTo-CompatibilityJson -Item $reportData -NoWhitespace:(-not $Readable) ` |
| 202 | + | Out-File -Force -LiteralPath $OutFile -Encoding Utf8 |
| 203 | + |
| 204 | + return Get-Item -LiteralPath $OutFile |
215 | 205 | }
|
216 | 206 |
|
217 | 207 | function New-AllPlatformReferenceProfile
|
@@ -1107,7 +1097,7 @@ function New-AvailableTypeData
|
1107 | 1097 | function Get-FullTypeName
|
1108 | 1098 | {
|
1109 | 1099 | param(
|
1110 |
| - [Parameter(ValueFromPipeline=$true)] |
| 1100 | + [Parameter(Position=0,ValueFromPipeline=$true)] |
1111 | 1101 | [type]
|
1112 | 1102 | $Type
|
1113 | 1103 | )
|
|
0 commit comments