@@ -263,72 +263,6 @@ public override SwitchParameter UseSSL
263263 }
264264 }
265265
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-
332266 /// <summary>
333267 /// For WSMan session:
334268 /// If this parameter is not specified then the value specified in
@@ -908,8 +842,6 @@ public virtual SwitchParameter RemoteDebug
908842
909843 #endregion
910844
911- private Version _savedStrictModeVersion ;
912-
913845 #endregion Parameters
914846
915847 #region Overrides
@@ -1033,12 +965,6 @@ protected override void BeginProcessing()
1033965 }
1034966 }
1035967
1036- if ( _strictmodeversion != null )
1037- {
1038- _savedStrictModeVersion = Context . EngineSessionState . CurrentScope . StrictModeVersion ;
1039- Context . EngineSessionState . CurrentScope . StrictModeVersion = _strictmodeversion ;
1040- }
1041-
1042968 return ;
1043969 }
1044970
@@ -1255,19 +1181,7 @@ protected override void ProcessRecord()
12551181 }
12561182 else if ( ParameterSetName . Equals ( InvokeCommandCommand . InProcParameterSet ) && ( _steppablePipeline != null ) )
12571183 {
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 ) ;
12711185 }
12721186 else
12731187 {
@@ -1298,30 +1212,20 @@ protected override void EndProcessing()
12981212 {
12991213 if ( ParameterSetName . Equals ( InvokeCommandCommand . InProcParameterSet ) )
13001214 {
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 ( ) ;
13181218 }
1319- finally
1219+ else
13201220 {
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 ) ;
13251229 }
13261230 }
13271231 else
0 commit comments