Skip to content

Add Command data files of PowerShell 6.1.0 and remove 6.0 command data files #1075

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

Merged
merged 10 commits into from
Mar 2, 2019
Merged

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions RuleDocumentation/UseCompatibleCmdlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ This rule flags cmdlets that are not available in a given Edition/Version of Pow
@{
'Rules' = @{
'PSUseCompatibleCmdlets' = @{
'compatibility' = @("core-6.0.2-windows")
'compatibility' = @("core-6.1.0-windows")
}
}
}
```

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}`.
The parameter `compatibility` is a list that contain any of the following

- desktop-3.0-windows
- desktop-4.0-windows (taken from Windows Server 2012R2)
- desktop-5.1.14393.206-windows
- core-6.1.0-windows (taken from Windows 10 - 1803)
- core-6.1.0-linux (taken from Ubuntu 18.04)
- core-6.1.0-linux-arm (taken from Raspbian)
- core-6.1.0-macos

Usually, patched versions of PowerShell have the same cmdlet data, therefore only settings of major and minor versions of PowerShell are supplied. One can also create a custom settings file as well with the [New-CommandDataFile.ps1](https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Utils/New-CommandDataFile.ps1) script and use it by placing the created `JSON` into the `Settings` folder of the `PSScriptAnalyzer` module installation folder, then the `compatibility` parameter is just its file name (that can also be changed if desired).
Note that the `core-6.0.2-*` files were removed in PSScriptAnalyzer 1.18 since PowerShell 6.0 reached it's end of life.
2 changes: 1 addition & 1 deletion Rules/UseCompatibleCmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private struct RuleParameters
private bool hasInitializationError;
private string reference;
private readonly string defaultReference = "desktop-5.1.14393.206-windows";
private readonly string alternativeDefaultReference = "core-6.0.2-windows";
private readonly string alternativeDefaultReference = "core-6.1.0-windows";
private RuleParameters ruleParameters;

public UseCompatibleCmdlets()
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 @@ -35,7 +35,7 @@ Describe "UseCompatibleCmdlets" {
}
}

$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("core-6.0.2-windows")}}}
$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("core-6.1.0-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.2-windows")
'compatibility' = @("core-6.1.0-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.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:
Suppose this file is run on the following version of PowerShell: PSVersion = 6.1.0, PSEdition = Core, and Windows 10 operating system. Then this script will create a file named core-6.1.0-windows.json that contains a JSON object of the following form:
{
"Modules" : [
"Module1" : {
Expand Down