From ac20884d1d942eaa90732fec401d24768540b7f2 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 29 May 2017 06:37:00 +0300 Subject: [PATCH 1/3] Remove BuildVersion from PSVersionInfo type --- .../engine/PSVersionInfo.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index bdd9364c528..f01c89cb567 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -20,7 +20,6 @@ internal class PSVersionInfo internal const string PSRemotingProtocolVersionName = "PSRemotingProtocolVersion"; internal const string PSVersionName = "PSVersion"; internal const string PSEditionName = "PSEdition"; - internal const string PSBuildVersionName = "BuildVersion"; internal const string PSGitCommitIdName = "GitCommitId"; internal const string PSCompatibleVersionsName = "PSCompatibleVersions"; internal const string PSCLRVersionName = "CLRVersion"; @@ -65,7 +64,6 @@ static PSVersionInfo() s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; - s_psVersionTable[PSBuildVersionName] = GetBuildVersion(); s_psVersionTable[PSGitCommitIdName] = GetCommitInfo(); s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version }; s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion); @@ -94,13 +92,6 @@ internal static Hashtable GetPSVersionTableForDownLevel() return result; } - internal static Version GetBuildVersion() - { - string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; - string buildVersion = FileVersionInfo.GetVersionInfo(assemblyPath).FileVersion; - return new Version(buildVersion); - } - // Get the commit id from the powershell.version file. If the powershell.version file doesn't exist, use the string "N/A" internal static string GetCommitInfo() { @@ -179,14 +170,6 @@ internal static Version CLRVersion } } - internal static Version BuildVersion - { - get - { - return (Version)GetPSVersionTable()[PSBuildVersionName]; - } - } - internal static Version[] PSCompatibleVersions { get From e2b868521d9f7e8b97a281f2d5c0b5d1fd08be55 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 29 May 2017 07:59:34 +0300 Subject: [PATCH 2/3] Fix error messages --- .../engine/remoting/client/clientremotesession.cs | 6 +++--- .../remoting/client/remotingprotocolimplementation.cs | 2 +- .../engine/remoting/fanin/WSManPlugin.cs | 6 +++--- .../engine/remoting/server/serverremotesession.cs | 8 ++++---- .../server/serverremotingprotocolimplementation.cs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs b/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs index bdd4f62fa1b..61be0720690 100644 --- a/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs @@ -531,7 +531,7 @@ private bool RunClientNegotiationAlgorithm(RemoteSessionCapability serverRemoteS new PSRemotingDataStructureException(RemotingErrorIdStrings.ClientNegotiationFailed, RemoteDataNameStrings.PS_STARTUP_PROTOCOL_VERSION_NAME, serverProtocolVersion, - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } @@ -545,7 +545,7 @@ private bool RunClientNegotiationAlgorithm(RemoteSessionCapability serverRemoteS new PSRemotingDataStructureException(RemotingErrorIdStrings.ClientNegotiationFailed, RemoteDataNameStrings.PSVersion, serverPSVersion.ToString(), - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } @@ -559,7 +559,7 @@ private bool RunClientNegotiationAlgorithm(RemoteSessionCapability serverRemoteS new PSRemotingDataStructureException(RemotingErrorIdStrings.ClientNegotiationFailed, RemoteDataNameStrings.SerializationVersion, serverSerVersion.ToString(), - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } diff --git a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs index 7ace574f9ad..b6dc41ba9c0 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs @@ -638,7 +638,7 @@ private void ProcessSessionMessages(RemoteDataEventArgs arg) // this will happen if expected properties are not // received for session capability throw new PSRemotingDataStructureException(RemotingErrorIdStrings.ClientNotFoundCapabilityProperties, - dse.Message, PSVersionInfo.BuildVersion, RemotingConstants.ProtocolVersion); + dse.Message, PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); } RemoteSessionStateMachineEventArgs capabilityArg = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationReceived); diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index be79b6a1253..8ea46369a7c 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -1056,7 +1056,7 @@ protected internal bool EnsureOptionsComply( StringUtil.Format( RemotingErrorIdStrings.WSManPluginOptionNotUnderstood, option.name, - System.Management.Automation.PSVersionInfo.BuildVersion, + System.Management.Automation.PSVersionInfo.GitCommitId, WSManPluginConstants.PowerShellStartupProtocolVersionValue)); return false; } @@ -1071,7 +1071,7 @@ protected internal bool EnsureOptionsComply( StringUtil.Format( RemotingErrorIdStrings.WSManPluginProtocolVersionNotFound, WSManPluginConstants.PowerShellStartupProtocolVersionName, - System.Management.Automation.PSVersionInfo.BuildVersion, + System.Management.Automation.PSVersionInfo.GitCommitId, WSManPluginConstants.PowerShellStartupProtocolVersionValue)); return false; } @@ -1113,7 +1113,7 @@ protected internal bool EnsureProtocolVersionComplies( StringUtil.Format( RemotingErrorIdStrings.WSManPluginProtocolVersionNotMatch, WSManPluginConstants.PowerShellStartupProtocolVersionValue, - System.Management.Automation.PSVersionInfo.BuildVersion, + System.Management.Automation.PSVersionInfo.GitCommitId, clientVersionString)); return false; } diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs index 41d7ce78f56..dc3aba6c407 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs @@ -1042,7 +1042,7 @@ private bool RunServerNegotiationAlgorithm(RemoteSessionCapability clientCapabil new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerConnectFailedOnNegotiation, RemoteDataNameStrings.PS_STARTUP_PROTOCOL_VERSION_NAME, clientProtocolVersion, - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } @@ -1092,7 +1092,7 @@ private bool RunServerNegotiationAlgorithm(RemoteSessionCapability clientCapabil new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerNegotiationFailed, RemoteDataNameStrings.PS_STARTUP_PROTOCOL_VERSION_NAME, clientProtocolVersion, - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } @@ -1108,7 +1108,7 @@ private bool RunServerNegotiationAlgorithm(RemoteSessionCapability clientCapabil new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerNegotiationFailed, RemoteDataNameStrings.PSVersion, clientPSVersion, - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } @@ -1123,7 +1123,7 @@ private bool RunServerNegotiationAlgorithm(RemoteSessionCapability clientCapabil new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerNegotiationFailed, RemoteDataNameStrings.SerializationVersion, clientSerVersion, - PSVersionInfo.BuildVersion, + PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); throw reasonOfFailure; } diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs index 368c76b6df2..da8b38ba95a 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs @@ -211,7 +211,7 @@ internal override void RaiseDataReceivedEvent(RemoteDataEventArgs dataArg) // this will happen if expected properties are not // received for session capability throw new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerNotFoundCapabilityProperties, - dse.Message, PSVersionInfo.BuildVersion, RemotingConstants.ProtocolVersion); + dse.Message, PSVersionInfo.GitCommitId, RemotingConstants.ProtocolVersion); } RemoteSessionStateMachineEventArgs capabilityArg = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationReceived); From da609cecc6634bc1b11c32699d74f1e28a796662 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 29 May 2017 08:27:57 +0300 Subject: [PATCH 3/3] Remove BuildVersion from tests --- test/powershell/Host/PSVersionTable.Tests.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index e034b8f2d02..b2624f3b19b 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -1,6 +1,6 @@ Describe "PSVersionTable" -Tags "CI" { It "Should have version table entries" { - $PSVersionTable.Count | Should Be 11 + $PSVersionTable.Count | Should Be 10 } It "Should have the right version table entries" { @@ -9,7 +9,6 @@ Describe "PSVersionTable" -Tags "CI" { $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