Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CommandData files of PowerShell Core 6.0.2 for Windows/Linux/macOS and WMF3/4 that are used by UseCompatibleCmdlets rule #954

Merged
merged 6 commits into from
May 17, 2018
1,821 changes: 0 additions & 1,821 deletions Engine/Settings/core-6.0.0-alpha-linux.json

This file was deleted.

1,821 changes: 0 additions & 1,821 deletions Engine/Settings/core-6.0.0-alpha-osx.json

This file was deleted.

2,238 changes: 0 additions & 2,238 deletions Engine/Settings/core-6.0.0-alpha-windows.json

This file was deleted.

1,648 changes: 1,648 additions & 0 deletions Engine/Settings/core-6.0.2-linux.json

Large diffs are not rendered by default.

1,648 changes: 1,648 additions & 0 deletions Engine/Settings/core-6.0.2-macos.json

Large diffs are not rendered by default.

2,075 changes: 2,075 additions & 0 deletions Engine/Settings/core-6.0.2-windows.json

Large diffs are not rendered by default.

6,268 changes: 6,268 additions & 0 deletions Engine/Settings/desktop-3.0-windows.json

Large diffs are not rendered by default.

7,133 changes: 7,133 additions & 0 deletions Engine/Settings/desktop-4.0-windows.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions RuleDocumentation/UseCompatibleCmdlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

## Description

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:
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:

```PowerShell
@{
'Rules' = @{
'PSUseCompatibleCmdlets' = @{
'compatibility' = @("core-6.0.0-alpha-windows")
'compatibility' = @("core-6.0.2-windows")
}
}
}
```

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}`.
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}`.
2 changes: 1 addition & 1 deletion Rules/UseCompatibleCmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ private bool GetVersionInfoFromPlatformString(
psedition = null;
psversion = null;
os = null;
const string pattern = @"^(?<psedition>core|desktop)-(?<psversion>[\S]+)-(?<os>windows|linux|osx)$";
const string pattern = @"^(?<psedition>core|desktop)-(?<psversion>[\S]+)-(?<os>windows|linux|macos)$";
var match = Regex.Match(fileName, pattern, RegexOptions.IgnoreCase);
if (match == Match.Empty)
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Rules/UseCompatibleCmdlets.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Describe "UseCompatibleCmdlets" {
}
}

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

Context "Microsoft.PowerShell.Core" {
@('Enter-PSSession', 'Foreach-Object', 'Get-Command') | `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@{
'Rules' = @{
'PSUseCompatibleCmdlets' = @{
'compatibility' = @("core-6.0.0-alpha-windows")
'compatibility' = @("core-6.0.2-windows")
}
}
}
2 changes: 1 addition & 1 deletion Utils/New-CommandDataFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.EXAMPLE
C:\PS> ./New-CommandDataFile.ps1

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:
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:
{
"Modules" : [
"Module1" : {
Expand Down