Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/System.Management.Automation/engine/PSVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ static PSVersionInfo()
s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion);
s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion();
s_psVersionTable["Platform"] = Environment.OSVersion.Platform.ToString();
#if CORECLR
s_psVersionTable["OS"] = Runtime.InteropServices.RuntimeInformation.OSDescription.ToString();
s_psVersionTable["CLRVersion"] = null;
#else
s_psVersionTable["CLRVersion"] = Environment.Version;
s_psVersionTable["OS"] = Environment.OSVersion.ToString();
#endif
}

Expand Down Expand Up @@ -800,4 +803,4 @@ internal Exception GetVersionParseException()
}
}
}
}
}
44 changes: 32 additions & 12 deletions test/powershell/Host/PSVersionTable.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
Describe "PSVersionTable" -Tags "CI" {
It "Should have version table entries" {
$PSVersionTable.Count | Should Be 9
$PSVersionTable.Count | Should Be 11
}

It "Should have the right version table entries" {
$PSVersionTable.ContainsKey("PSVersion") | Should Be True
$PSVersionTable.ContainsKey("PSEdition") | Should Be True
$PSVersionTable.ContainsKey("WSManStackVersion") | Should Be True
$PSVersionTable.ContainsKey("SerializationVersion") | Should Be True
$PSVersionTable.ContainsKey("CLRVersion") | Should Be True
$PSVersionTable.ContainsKey("BuildVersion") | Should Be True
$PSVersionTable.ContainsKey("PSCompatibleVersions") | Should Be True
$PSVersionTable.ContainsKey("PSRemotingProtocolVersion") | Should Be True
$PSVersionTable.ContainsKey("GitCommitId") | Should Be True
$PSVersionTable.ContainsKey("PSVersion") | Should Be True
$PSVersionTable.ContainsKey("PSEdition") | Should Be True
$PSVersionTable.ContainsKey("WSManStackVersion") | Should Be True
$PSVersionTable.ContainsKey("SerializationVersion") | Should Be True
$PSVersionTable.ContainsKey("CLRVersion") | Should Be True
$PSVersionTable.ContainsKey("BuildVersion") | Should Be True
$PSVersionTable.ContainsKey("PSCompatibleVersions") | Should Be True
$PSVersionTable.ContainsKey("PSRemotingProtocolVersion") | Should Be True
$PSVersionTable.ContainsKey("GitCommitId") | Should Be True
$PSVersionTable.ContainsKey("Platform") | Should Be True
$PSVersionTable.ContainsKey("OS") | Should Be True

}
It "GitCommitId property should not contain an error" {
$PSVersionTable.GitCommitId | Should not match "powershell.version"
$PSVersionTable.GitCommitId | Should not match "powershell.version"
}

It "Should have the correct edition" -Skip:(!$IsCoreCLR) {
$PSVersionTable["PSEdition"] | Should Be "Core"
$PSVersionTable["PSEdition"] | Should Be "Core"
}

It "Should have the correct platform info" {
$platform = [String][System.Environment]::OSVersion.Platform
[String]$PSVersionTable["Platform"] | Should Be $platform
}

It "Should have the correct OS info" {
if ($IsCoreCLR)
{
$OSDescription = [String][System.Runtime.InteropServices.RuntimeInformation]::OSDescription
[String]$PSVersionTable["OS"] | Should Be $OSDescription
}
else
{
$OSDescription = [String][System.Environment]::OSVersion
[String]$PSVersionTable["OS"] | Should Be $OSDescription
}
}
}