Skip to content

Commit f1222ef

Browse files
authored
Add CommandData files of PowerShell Core 6.0.2 for Windows/Linux/macOS and WMF3/4 that are used by UseCompatibleCmdlets rule (#954)
* add typedate for pwsh 6.0.2 on Windows 10.0.16299.251 and for Linux from Ubuntu 16 (LTS) * update docs and remove old alpha versions for windows/linux * add v3 command data file from Tyler. And add v5.1 to docs as well * add wmf4 command data file produced on new vanilla winserver2012r2 azure machine * add mac command data file from James and correct it from osx to macOs
1 parent c632ea1 commit f1222ef

13 files changed

+18780
-5887
lines changed

Engine/Settings/core-6.0.0-alpha-linux.json

Lines changed: 0 additions & 1821 deletions
This file was deleted.

Engine/Settings/core-6.0.0-alpha-osx.json

Lines changed: 0 additions & 1821 deletions
This file was deleted.

Engine/Settings/core-6.0.0-alpha-windows.json

Lines changed: 0 additions & 2238 deletions
This file was deleted.

Engine/Settings/core-6.0.2-linux.json

Lines changed: 1648 additions & 0 deletions
Large diffs are not rendered by default.

Engine/Settings/core-6.0.2-macos.json

Lines changed: 1648 additions & 0 deletions
Large diffs are not rendered by default.

Engine/Settings/core-6.0.2-windows.json

Lines changed: 2075 additions & 0 deletions
Large diffs are not rendered by default.

Engine/Settings/desktop-3.0-windows.json

Lines changed: 6268 additions & 0 deletions
Large diffs are not rendered by default.

Engine/Settings/desktop-4.0-windows.json

Lines changed: 7133 additions & 0 deletions
Large diffs are not rendered by default.

RuleDocumentation/UseCompatibleCmdlets.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
## Description
66

7-
This rule flags cmdlets that are not available in a given Edition/Version of PowerShell on a given Operating System. It works by comparing a cmdlet against a set of whitelists which ship with PSScriptAnalyzer. They can be found at `/path/to/PSScriptAnalyzerModule/Settings`. These files are of the form, `PSEDITION-PSVERSION-OS.json` where `PSEDITION` can be either `core` or `desktop`, `OS` can be either `windows`, `linux` or `osx`, and `version` is the PowerShell version. To enable the rule to check if your script is compatible on PowerShell Core on windows, put the following your settings file:
7+
This rule flags cmdlets that are not available in a given Edition/Version of PowerShell on a given Operating System. It works by comparing a cmdlet against a set of whitelists which ship with PSScriptAnalyzer. They can be found at `/path/to/PSScriptAnalyzerModule/Settings`. These files are of the form, `PSEDITION-PSVERSION-OS.json` where `PSEDITION` can be either `Core` or `Desktop`, `OS` can be either `Windows`, `Linux` or `MacOS`, and `Version` is the PowerShell version. To enable the rule to check if your script is compatible on PowerShell Core on windows, put the following your settings file:
8+
89
```PowerShell
910
@{
1011
'Rules' = @{
1112
'PSUseCompatibleCmdlets' = @{
12-
'compatibility' = @("core-6.0.0-alpha-windows")
13+
'compatibility' = @("core-6.0.2-windows")
1314
}
1415
}
1516
}
1617
```
1718

18-
The parameter `compatibility` is a list that contain any of the following `{core-6.0.0-alpha-windows, core-6.0.0-alpha-linux, core-6.0.0-alpha-osx}`.
19+
The parameter `compatibility` is a list that contain any of the following `{desktop-3.0-windows, desktop-4.0-windows, desktop-5.1.14393.206-windows, core-6.0.2-windows, core-6.0.2-linux, core-6.0.2-macos}`.

Rules/UseCompatibleCmdlets.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private bool GetVersionInfoFromPlatformString(
395395
psedition = null;
396396
psversion = null;
397397
os = null;
398-
const string pattern = @"^(?<psedition>core|desktop)-(?<psversion>[\S]+)-(?<os>windows|linux|osx)$";
398+
const string pattern = @"^(?<psedition>core|desktop)-(?<psversion>[\S]+)-(?<os>windows|linux|macos)$";
399399
var match = Regex.Match(fileName, pattern, RegexOptions.IgnoreCase);
400400
if (match == Match.Empty)
401401
{

Tests/Rules/UseCompatibleCmdlets.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Describe "UseCompatibleCmdlets" {
3333
}
3434
}
3535

36-
$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("core-6.0.0-alpha-windows")}}}
36+
$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("core-6.0.2-windows")}}}
3737

3838
Context "Microsoft.PowerShell.Core" {
3939
@('Enter-PSSession', 'Foreach-Object', 'Get-Command') | `
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@{
22
'Rules' = @{
33
'PSUseCompatibleCmdlets' = @{
4-
'compatibility' = @("core-6.0.0-alpha-windows")
4+
'compatibility' = @("core-6.0.2-windows")
55
}
66
}
77
}

Utils/New-CommandDataFile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
.EXAMPLE
66
C:\PS> ./New-CommandDataFile.ps1
77
8-
Suppose this file is run on the following version of PowerShell: PSVersion = 6.0.0-aplha, PSEdition = Core, and Windows 10 operating system. Then this script will create a file named core-6.0.0-alpha-windows.json that contains a JSON object of the following form:
8+
Suppose this file is run on the following version of PowerShell: PSVersion = 6.0.2, PSEdition = Core, and Windows 10 operating system. Then this script will create a file named core-6.0.2-windows.json that contains a JSON object of the following form:
99
{
1010
"Modules" : [
1111
"Module1" : {

0 commit comments

Comments
 (0)