@@ -263,72 +263,6 @@ public override SwitchParameter UseSSL
263
263
}
264
264
}
265
265
266
- private sealed class ArgumentToPSVersionTransformationAttribute : ArgumentToVersionTransformationAttribute
267
- {
268
- protected override bool TryConvertFromString ( string versionString , [ NotNullWhen ( true ) ] out Version version )
269
- {
270
- if ( string . Equals ( "off" , versionString , StringComparison . OrdinalIgnoreCase ) )
271
- {
272
- version = new Version ( 0 , 0 ) ;
273
- return true ;
274
- }
275
-
276
- if ( string . Equals ( "latest" , versionString , StringComparison . OrdinalIgnoreCase ) )
277
- {
278
- version = PSVersionInfo . PSVersion ;
279
- return true ;
280
- }
281
-
282
- return base . TryConvertFromString ( versionString , out version ) ;
283
- }
284
- }
285
-
286
- private static readonly Version s_OffVersion = new Version ( 0 , 0 ) ;
287
-
288
- private sealed class ValidateVersionAttribute : ValidateArgumentsAttribute
289
- {
290
- protected override void Validate ( object arguments , EngineIntrinsics engineIntrinsics )
291
- {
292
- Version version = arguments as Version ;
293
- if ( version == s_OffVersion )
294
- {
295
- return ;
296
- }
297
-
298
- if ( version == null || ! PSVersionInfo . IsValidPSVersion ( version ) )
299
- {
300
- // No conversion succeeded so throw an exception...
301
- throw new ValidationMetadataException (
302
- "InvalidPSVersion" ,
303
- null ,
304
- Metadata . ValidateVersionFailure ,
305
- arguments ) ;
306
- }
307
- }
308
- }
309
-
310
- /// <summary>
311
- /// Gets or sets strict mode.
312
- /// </summary>
313
- [ Experimental ( ExperimentalFeature . PSStrictModeAssignment , ExperimentAction . Show ) ]
314
- [ Parameter ( ParameterSetName = InvokeCommandCommand . InProcParameterSet ) ]
315
- [ ArgumentToPSVersionTransformation ]
316
- [ ValidateVersion ]
317
- public Version StrictMode
318
- {
319
- get
320
- {
321
- return _strictmodeversion ;
322
- }
323
-
324
- set
325
- {
326
- _strictmodeversion = value ;
327
- }
328
- }
329
-
330
- private Version _strictmodeversion = null ;
331
-
332
266
/// <summary>
333
267
/// For WSMan session:
334
268
/// If this parameter is not specified then the value specified in
@@ -908,8 +842,6 @@ public virtual SwitchParameter RemoteDebug
908
842
909
843
#endregion
910
844
911
- private Version _savedStrictModeVersion ;
912
-
913
845
#endregion Parameters
914
846
915
847
#region Overrides
@@ -1033,12 +965,6 @@ protected override void BeginProcessing()
1033
965
}
1034
966
}
1035
967
1036
- if ( _strictmodeversion != null )
1037
- {
1038
- _savedStrictModeVersion = Context . EngineSessionState . CurrentScope . StrictModeVersion ;
1039
- Context . EngineSessionState . CurrentScope . StrictModeVersion = _strictmodeversion ;
1040
- }
1041
-
1042
968
return ;
1043
969
}
1044
970
@@ -1255,19 +1181,7 @@ protected override void ProcessRecord()
1255
1181
}
1256
1182
else if ( ParameterSetName . Equals ( InvokeCommandCommand . InProcParameterSet ) && ( _steppablePipeline != null ) )
1257
1183
{
1258
- try
1259
- {
1260
- _steppablePipeline . Process ( InputObject ) ;
1261
- }
1262
- catch
1263
- {
1264
- if ( _strictmodeversion != null )
1265
- {
1266
- Context . EngineSessionState . CurrentScope . StrictModeVersion = _savedStrictModeVersion ;
1267
- }
1268
-
1269
- throw ;
1270
- }
1184
+ _steppablePipeline . Process ( InputObject ) ;
1271
1185
}
1272
1186
else
1273
1187
{
@@ -1298,30 +1212,20 @@ protected override void EndProcessing()
1298
1212
{
1299
1213
if ( ParameterSetName . Equals ( InvokeCommandCommand . InProcParameterSet ) )
1300
1214
{
1301
- try
1302
- {
1303
- if ( _steppablePipeline != null )
1304
- {
1305
- _steppablePipeline . End ( ) ;
1306
- }
1307
- else
1308
- {
1309
- ScriptBlock . InvokeUsingCmdlet (
1310
- contextCmdlet : this ,
1311
- useLocalScope : ! NoNewScope ,
1312
- errorHandlingBehavior : ScriptBlock . ErrorHandlingBehavior . WriteToCurrentErrorPipe ,
1313
- dollarUnder : AutomationNull . Value ,
1314
- input : _input ,
1315
- scriptThis : AutomationNull . Value ,
1316
- args : ArgumentList ) ;
1317
- }
1215
+ if ( _steppablePipeline != null )
1216
+ {
1217
+ _steppablePipeline . End ( ) ;
1318
1218
}
1319
- finally
1219
+ else
1320
1220
{
1321
- if ( _strictmodeversion != null )
1322
- {
1323
- Context . EngineSessionState . CurrentScope . StrictModeVersion = _savedStrictModeVersion ;
1324
- }
1221
+ ScriptBlock . InvokeUsingCmdlet (
1222
+ contextCmdlet : this ,
1223
+ useLocalScope : ! NoNewScope ,
1224
+ errorHandlingBehavior : ScriptBlock . ErrorHandlingBehavior . WriteToCurrentErrorPipe ,
1225
+ dollarUnder : AutomationNull . Value ,
1226
+ input : _input ,
1227
+ scriptThis : AutomationNull . Value ,
1228
+ args : ArgumentList ) ;
1325
1229
}
1326
1230
}
1327
1231
else
0 commit comments