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