From cf40937552977783824810404856272abfeeeecb Mon Sep 17 00:00:00 2001 From: "Jason Shirk (POWERSHELL)" Date: Fri, 5 Aug 2016 17:55:49 -0700 Subject: [PATCH] Fix remoting break caused by refactoring Remoting apparently depends on the names of private fields not changing between versions of PowerShell. Because of this, these refactorings broke remoting: * rename private fields * convert to auto-property --- .../hostifaces/MshHostRawUserInterface.cs | 46 +++++++++++++------ .../WireDataFormat/RemoteSessionCapability.cs | 28 +++++++---- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/System.Management.Automation/engine/hostifaces/MshHostRawUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/MshHostRawUserInterface.cs index a044c23bae..3fb2756fd6 100644 --- a/src/System.Management.Automation/engine/hostifaces/MshHostRawUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/MshHostRawUserInterface.cs @@ -25,21 +25,31 @@ namespace System.Management.Automation.Host public struct Coordinates { + // DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting + private int x; + private int y; + /// /// /// Gets and sets the X coordinate /// /// - - public int X { get; set; } + public int X + { + get { return x; } + set { x = value; } + } /// /// /// Gets and sets the Y coordinate /// /// - - public int Y { get; set; } + public int Y + { + get { return y; } + set { y = value; } + } /// @@ -57,12 +67,11 @@ namespace System.Management.Automation.Host /// The Y coordinate /// /// - public Coordinates(int x, int y) { - X = x; - Y = y; + this.x = x; + this.y = y; } @@ -258,21 +267,31 @@ namespace System.Management.Automation.Host public struct Size { + // DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting + private int width; + private int height; + /// /// /// Gets and sets the Width /// /// - - public int Width { get; set; } + public int Width + { + get { return width; } + set { width = value; } + } /// /// /// Gets and sets the Height /// /// - - public int Height { get; set; } + public int Height + { + get { return height; } + set { height = value; } + } /// @@ -290,12 +309,11 @@ namespace System.Management.Automation.Host /// The Height /// /// - public Size(int width, int height) { - Width = width; - Height = height; + this.width = width; + this.height = height; } diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs index fb3847937e..6f947b0c62 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs @@ -167,14 +167,15 @@ namespace System.Management.Automation.Remoting /// /// Data. /// - private Dictionary _data; + // DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting + private Dictionary data; /// /// Private constructor to force use of Create. /// private HostDefaultData() { - _data = new Dictionary(); + data = new Dictionary(); } /// @@ -193,7 +194,7 @@ namespace System.Management.Automation.Remoting /// internal bool HasValue(HostDefaultDataId id) { - return _data.ContainsKey(id); + return data.ContainsKey(id); } /// @@ -201,7 +202,7 @@ namespace System.Management.Automation.Remoting /// internal void SetValue(HostDefaultDataId id, object dataValue) { - _data[id] = dataValue; + data[id] = dataValue; } /// @@ -210,7 +211,7 @@ namespace System.Management.Automation.Remoting internal object GetValue(HostDefaultDataId id) { object result; - _data.TryGetValue(id, out result); + data.TryGetValue(id, out result); return result; } @@ -340,7 +341,10 @@ namespace System.Management.Automation.Remoting /// /// Host default data. /// - internal HostDefaultData HostDefaultData { get; } + internal HostDefaultData HostDefaultData + { + get { return _hostDefaultData; } + } /// /// Is host null. @@ -373,6 +377,10 @@ namespace System.Management.Automation.Remoting private readonly bool _isHostNull; + // DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting + private readonly HostDefaultData _hostDefaultData; + private bool _useRunspaceHost; + /// /// Is host raw ui null. /// @@ -387,7 +395,11 @@ namespace System.Management.Automation.Remoting /// /// Use runspace host. /// - internal bool UseRunspaceHost { get; set; } + internal bool UseRunspaceHost + { + get { return _useRunspaceHost; } + set { _useRunspaceHost = value; } + } /// /// Constructor for HostInfo. @@ -400,7 +412,7 @@ namespace System.Management.Automation.Remoting // If raw UI is non-null then get the host-info object. if (!_isHostUINull && !_isHostRawUINull) { - HostDefaultData = HostDefaultData.Create(host.UI.RawUI); + _hostDefaultData = HostDefaultData.Create(host.UI.RawUI); } }