Skip to content

Commit b194731

Browse files
SteveL-MSFTdaxian-dbw
authored andcommitted
Revert refactoring changes that broke remoting to Windows PowerShell 5.1 (PowerShell#5321)
- Revert refactoring changes so that it doesn't break remoting to Windows PowerShell 5.1 - Fix the rest of the supported types for remoting - Put remoting sensitive private members in a descriptive region
1 parent 7a78fec commit b194731

5 files changed

Lines changed: 305 additions & 136 deletions

File tree

src/System.Management.Automation/engine/ProgressRecord.cs

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ class ProgressRecord
6666
throw PSTraceSource.NewArgumentException("activity", ProgressRecordStrings.ArgMayNotBeNullOrEmpty, "statusDescription");
6767
}
6868

69-
_id = activityId;
70-
_activity = activity;
71-
_status = statusDescription;
69+
this.id = activityId;
70+
this.activity = activity;
71+
this.status = statusDescription;
7272
}
7373

7474
/// <summary>
@@ -77,14 +77,14 @@ class ProgressRecord
7777
/// <param name="other"></param>
7878
internal ProgressRecord(ProgressRecord other)
7979
{
80-
_activity = other._activity;
81-
_currentOperation = other._currentOperation;
82-
_id = other._id;
83-
_parentId = other._parentId;
84-
_percent = other._percent;
85-
_secondsRemaining = other._secondsRemaining;
86-
_status = other._status;
87-
_type = other._type;
80+
this.activity = other.activity;
81+
this.currentOperation = other.currentOperation;
82+
this.id = other.id;
83+
this.parentId = other.parentId;
84+
this.percent = other.percent;
85+
this.secondsRemaining = other.secondsRemaining;
86+
this.status = other.status;
87+
this.type = other.type;
8888
}
8989

9090
/// <summary>
@@ -100,7 +100,7 @@ internal ProgressRecord(ProgressRecord other)
100100
{
101101
get
102102
{
103-
return _id;
103+
return id;
104104
}
105105
}
106106

@@ -133,15 +133,15 @@ internal ProgressRecord(ProgressRecord other)
133133
{
134134
get
135135
{
136-
return _parentId;
136+
return parentId;
137137
}
138138
set
139139
{
140140
if (value == ActivityId)
141141
{
142142
throw PSTraceSource.NewArgumentException("value", ProgressRecordStrings.ParentActivityIdCantBeActivityId);
143143
}
144-
_parentId = value;
144+
parentId = value;
145145
}
146146
}
147147

@@ -165,15 +165,15 @@ internal ProgressRecord(ProgressRecord other)
165165
{
166166
get
167167
{
168-
return _activity;
168+
return activity;
169169
}
170170
set
171171
{
172172
if (String.IsNullOrEmpty(value))
173173
{
174174
throw PSTraceSource.NewArgumentException("value", ProgressRecordStrings.ArgMayNotBeNullOrEmpty, "value");
175175
}
176-
_activity = value;
176+
activity = value;
177177
}
178178
}
179179

@@ -191,15 +191,15 @@ internal ProgressRecord(ProgressRecord other)
191191
{
192192
get
193193
{
194-
return _status;
194+
return status;
195195
}
196196
set
197197
{
198198
if (String.IsNullOrEmpty(value))
199199
{
200200
throw PSTraceSource.NewArgumentException("value", ProgressRecordStrings.ArgMayNotBeNullOrEmpty, "value");
201201
}
202-
_status = value;
202+
status = value;
203203
}
204204
}
205205

@@ -219,13 +219,13 @@ internal ProgressRecord(ProgressRecord other)
219219
{
220220
get
221221
{
222-
return _currentOperation;
222+
return currentOperation;
223223
}
224224
set
225225
{
226226
// null or empty string is allowed
227227

228-
_currentOperation = value;
228+
currentOperation = value;
229229
}
230230
}
231231

@@ -244,7 +244,7 @@ internal ProgressRecord(ProgressRecord other)
244244
{
245245
get
246246
{
247-
return _percent;
247+
return percent;
248248
}
249249
set
250250
{
@@ -257,7 +257,7 @@ internal ProgressRecord(ProgressRecord other)
257257
"value", value, ProgressRecordStrings.PercentMayNotBeMoreThan100, "PercentComplete");
258258
}
259259

260-
_percent = value;
260+
percent = value;
261261
}
262262
}
263263

@@ -283,13 +283,13 @@ internal ProgressRecord(ProgressRecord other)
283283
{
284284
get
285285
{
286-
return _secondsRemaining;
286+
return secondsRemaining;
287287
}
288288
set
289289
{
290290
// negative values are allowed
291291

292-
_secondsRemaining = value;
292+
secondsRemaining = value;
293293
}
294294
}
295295

@@ -307,7 +307,7 @@ internal ProgressRecord(ProgressRecord other)
307307
{
308308
get
309309
{
310-
return _type;
310+
return type;
311311
}
312312
set
313313
{
@@ -316,7 +316,7 @@ internal ProgressRecord(ProgressRecord other)
316316
throw PSTraceSource.NewArgumentException("value");
317317
}
318318

319-
_type = value;
319+
type = value;
320320
}
321321
}
322322

@@ -343,14 +343,14 @@ public override
343343
String.Format(
344344
System.Globalization.CultureInfo.CurrentCulture,
345345
"parent = {0} id = {1} act = {2} stat = {3} cur = {4} pct = {5} sec = {6} type = {7}",
346-
_parentId,
347-
_id,
348-
_activity,
349-
_status,
350-
_currentOperation,
351-
_percent,
352-
_secondsRemaining,
353-
_type);
346+
parentId,
347+
id,
348+
activity,
349+
status,
350+
currentOperation,
351+
percent,
352+
secondsRemaining,
353+
type);
354354
}
355355

356356
#endregion
@@ -467,29 +467,33 @@ internal static int GetPercentageComplete(DateTime startTime, TimeSpan expectedD
467467

468468
#endregion
469469

470+
#region DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting compatibility with Windows PowerShell
471+
470472
[DataMemberAttribute()]
471-
private int _id;
473+
private int id;
472474

473475
[DataMemberAttribute()]
474-
private int _parentId = -1;
476+
private int parentId = -1;
475477

476478
[DataMemberAttribute()]
477-
private string _activity;
479+
private string activity;
478480

479481
[DataMemberAttribute()]
480-
private string _status;
482+
private string status;
481483

482484
[DataMemberAttribute()]
483-
private string _currentOperation;
485+
private string currentOperation;
484486

485487
[DataMemberAttribute()]
486-
private int _percent = -1;
488+
private int percent = -1;
487489

488490
[DataMemberAttribute()]
489-
private int _secondsRemaining = -1;
491+
private int secondsRemaining = -1;
490492

491493
[DataMemberAttribute()]
492-
private ProgressRecordType _type = ProgressRecordType.Processing;
494+
private ProgressRecordType type = ProgressRecordType.Processing;
495+
496+
#endregion
493497

494498
#region Serialization / deserialization for remoting
495499

src/System.Management.Automation/engine/hostifaces/ChoiceDescription.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ namespace System.Management.Automation.Host
1919
public sealed
2020
class ChoiceDescription
2121
{
22+
23+
#region DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting compatibility with Windows PowerShell compatibility with Windows PowerShell
24+
25+
private readonly string label = null;
26+
private string helpMessage = "";
27+
28+
#endregion
29+
2230
/// <summary>
2331
///
2432
/// Initializes an new instance of ChoiceDescription and defines the Label value.
@@ -46,7 +54,7 @@ class ChoiceDescription
4654
throw PSTraceSource.NewArgumentException("label", DescriptionsStrings.NullOrEmptyErrorTemplate, "label");
4755
}
4856

49-
_label = label;
57+
this.label = label;
5058
}
5159

5260
/// <summary>
@@ -92,8 +100,8 @@ class ChoiceDescription
92100
throw PSTraceSource.NewArgumentNullException("helpMessage");
93101
}
94102

95-
_label = label;
96-
_helpMessage = helpMessage;
103+
this.label = label;
104+
this.helpMessage = helpMessage;
97105
}
98106

99107
/// <summary>
@@ -118,9 +126,9 @@ class ChoiceDescription
118126
{
119127
get
120128
{
121-
Dbg.Assert(_label != null, "label should not be null");
129+
Dbg.Assert(this.label != null, "label should not be null");
122130

123-
return _label;
131+
return this.label;
124132
}
125133
}
126134

@@ -149,9 +157,9 @@ class ChoiceDescription
149157
{
150158
get
151159
{
152-
Dbg.Assert(_helpMessage != null, "helpMessage should not be null");
160+
Dbg.Assert(this.helpMessage != null, "helpMessage should not be null");
153161

154-
return _helpMessage;
162+
return this.helpMessage;
155163
}
156164
set
157165
{
@@ -160,12 +168,9 @@ class ChoiceDescription
160168
throw PSTraceSource.NewArgumentNullException("value");
161169
}
162170

163-
_helpMessage = value;
171+
this.helpMessage = value;
164172
}
165173
}
166-
167-
private readonly string _label = null;
168-
private string _helpMessage = "";
169174
}
170175
}
171176

0 commit comments

Comments
 (0)