Skip to content

Commit 124a59b

Browse files
authored
Merge pull request PowerShell#2363 from lzybkr/maxvars
Remove most Maximum* capacity variables
2 parents 0c9abbc + 39db1ec commit 124a59b

21 files changed

Lines changed: 63 additions & 685 deletions

src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,11 +1732,6 @@ protected override void ProcessRecord()
17321732
pathNotFound));
17331733
return;
17341734
}
1735-
catch (SessionStateOverflowException)
1736-
{
1737-
// This is terminating condition
1738-
throw;
1739-
}
17401735
catch (SessionStateException sessionStateException)
17411736
{
17421737
WriteError(

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ public PSDriveInfo Current
114114
/// <exception cref="ProviderInvocationException">
115115
/// If the provider threw an exception or returned null.
116116
/// </exception>
117-
///
118-
/// <exception cref="SessionStateOverflowException">
119-
/// If creating the drive will overflow the MaximumDriveCount limit.
120-
/// </exception>
121117
public PSDriveInfo New(PSDriveInfo drive, string scope)
122118
{
123119
Dbg.Diagnostics.Assert(
@@ -173,11 +169,6 @@ public PSDriveInfo New(PSDriveInfo drive, string scope)
173169
/// <exception cref="ProviderInvocationException">
174170
/// If the provider threw an exception or returned null.
175171
/// </exception>
176-
///
177-
/// <exception cref="SessionStateOverflowException">
178-
/// If creating the drive will overflow the MaximumDriveCount limit.
179-
/// </exception>
180-
///
181172
internal void New(
182173
PSDriveInfo drive,
183174
string scope,

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

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -802,39 +802,8 @@ internal void AppendDollarError(object obj)
802802
return;
803803
}
804804

805-
// 1045384-2004/12/14-JonN implementing $MaximumErrorCount
806-
object maxcountobj = EngineSessionState.CurrentScope.ErrorCapacity.FastValue;
807-
if (null != maxcountobj)
808-
{
809-
try
810-
{
811-
maxcountobj = LanguagePrimitives.ConvertTo(maxcountobj, typeof(int), CultureInfo.InvariantCulture);
812-
}
813-
catch (PSInvalidCastException)
814-
{
815-
}
816-
catch (System.OverflowException)
817-
{
818-
}
819-
catch (Exception e)
820-
{
821-
Diagnostics.Assert(false,
822-
"Unexpected exception in LanguagePrimitives.ConvertTo: "
823-
+ e.GetType().FullName);
824-
throw;
825-
}
826-
}
827-
int maxErrorCount = (maxcountobj is int) ? (int)maxcountobj : 256;
828-
if (0 > maxErrorCount)
829-
maxErrorCount = 0;
830-
else if (32768 < maxErrorCount)
831-
maxErrorCount = 32768;
805+
const int maxErrorCount = 256;
832806

833-
if (0 >= maxErrorCount)
834-
{
835-
arraylist.Clear();
836-
return;
837-
}
838807
int numToErase = arraylist.Count - (maxErrorCount - 1);
839808
if (0 < numToErase)
840809
{

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,6 @@ private Exception ProcessUserDrive(Runspace initializedRunspace)
31383138
catch (NotSupportedException e) { ex = e; }
31393139
catch (ProviderNotFoundException e) { ex = e; }
31403140
catch (ProviderInvocationException e) { ex = e; }
3141-
catch (SessionStateOverflowException e) { ex = e; }
31423141
catch (KeyNotFoundException e) { ex = e; }
31433142
catch (IOException e) { ex = e; }
31443143
catch (UnauthorizedAccessException e) { ex = e; }

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ public object[] ArgumentList
158158
/// <summary>
159159
/// Execute the begin scriptblock at the start of processing
160160
/// </summary>
161-
/// <exception cref="SessionStateOverflowException">
162-
/// The maximum scope depth would be exceeded
163-
/// </exception>
164161
/// <exception cref="ParseException">could not parse script</exception>
165162
/// <exception cref="RuntimeException">see Pipeline.Invoke</exception>
166163
/// <exception cref="ParameterBindingException">see Pipeline.Invoke</exception>
@@ -242,9 +239,6 @@ protected override void BeginProcessing()
242239
/// Execute the processing script blocks on the current pipeline object
243240
/// which is passed as it's only parameter.
244241
/// </summary>
245-
/// <exception cref="SessionStateOverflowException">
246-
/// The maximum scope depth would be exceeded
247-
/// </exception>
248242
/// <exception cref="ParseException">could not parse script</exception>
249243
/// <exception cref="RuntimeException">see Pipeline.Invoke</exception>
250244
/// <exception cref="ParameterBindingException">see Pipeline.Invoke</exception>
@@ -733,9 +727,6 @@ internal static ErrorRecord GenerateNameParameterError(string paraName, string r
733727
/// <summary>
734728
/// Execute the end scriptblock when the pipeline is complete
735729
/// </summary>
736-
/// <exception cref="SessionStateOverflowException">
737-
/// The maximum scope depth would be exceeded
738-
/// </exception>
739730
/// <exception cref="ParseException">could not parse script</exception>
740731
/// <exception cref="RuntimeException">see Pipeline.Invoke</exception>
741732
/// <exception cref="ParameterBindingException">see Pipeline.Invoke</exception>
@@ -1456,9 +1447,6 @@ protected override void BeginProcessing()
14561447
/// Execute the script block passing in the current pipeline object as
14571448
/// it's only parameter.
14581449
/// </summary>
1459-
/// <exception cref="SessionStateOverflowException">
1460-
/// The maximum scope depth would be exceeded
1461-
/// </exception>
14621450
/// <exception cref="ParseException">could not parse script</exception>
14631451
/// <exception cref="RuntimeException">see Pipeline.Invoke</exception>
14641452
/// <exception cref="ParameterBindingException">see Pipeline.Invoke</exception>

src/System.Management.Automation/engine/Modules/PSModuleInfo.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,7 @@ private static void AddModuleToList(PSModuleInfo module, List<PSModuleInfo> modu
10581058
}
10591059

10601060
internal static string[] _builtinVariables = new string[] { "_", "this", "input", "args", "true", "false", "null",
1061-
"MaximumErrorCount", "MaximumVariableCount", "MaximumFunctionCount","MaximumAliasCount", "PSDefaultParameterValues",
1062-
"MaximumDriveCount", "Error", "PSScriptRoot", "PSCommandPath", "MyInvocation", "ExecutionContext", "StackTrace" };
1061+
"PSDefaultParameterValues", "Error", "PSScriptRoot", "PSCommandPath", "MyInvocation", "ExecutionContext", "StackTrace" };
10631062

10641063
/// <summary>
10651064
/// Lists the variables exported by this module.

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,10 +1846,6 @@ internal object InvokeSetter(object scriptThis, object value)
18461846
args: new object[] { value });
18471847
return value;
18481848
}
1849-
catch (SessionStateOverflowException e)
1850-
{
1851-
throw NewSetValueException(e, "ScriptSetValueSessionStateOverflowException");
1852-
}
18531849
catch (RuntimeException e)
18541850
{
18551851
throw NewSetValueException(e, "ScriptSetValueRuntimeException");
@@ -1881,10 +1877,6 @@ internal object InvokeGetter(object scriptThis)
18811877
scriptThis: scriptThis,
18821878
args: Utils.EmptyArray<object>());
18831879
}
1884-
catch (SessionStateOverflowException e)
1885-
{
1886-
throw NewGetValueException(e, "ScriptGetValueSessionStateOverflowException");
1887-
}
18881880
catch (RuntimeException e)
18891881
{
18901882
throw NewGetValueException(e, "ScriptGetValueRuntimeException");
@@ -2424,14 +2416,6 @@ internal static object InvokeScript(string methodName, ScriptBlock script, objec
24242416
scriptThis: @this,
24252417
args: arguments);
24262418
}
2427-
catch (SessionStateOverflowException e)
2428-
{
2429-
throw new MethodInvocationException(
2430-
"ScriptMethodSessionStateOverflowException",
2431-
e,
2432-
ExtendedTypeSystem.MethodInvocationException,
2433-
methodName, arguments.Length, e.Message);
2434-
}
24352419
catch (RuntimeException e)
24362420
{
24372421
throw new MethodInvocationException(

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ internal AliasInfo GetAliasAtScope(string aliasName, string scopeID)
277277
/// If the alias is read-only or constant.
278278
/// </exception>
279279
///
280-
/// <exception cref="SessionStateOverflowException">
281-
/// If the maximum number of aliases has been reached for this scope.
282-
/// </exception>
283-
///
284280
internal AliasInfo SetAliasValue(string aliasName, string value, bool force, CommandOrigin origin)
285281
{
286282
if (String.IsNullOrEmpty(aliasName))
@@ -328,10 +324,6 @@ internal AliasInfo SetAliasValue(string aliasName, string value, bool force, Com
328324
/// If the alias is read-only or constant.
329325
/// </exception>
330326
///
331-
/// <exception cref="SessionStateOverflowException">
332-
/// If the maximum number of aliases has been reached for this scope.
333-
/// </exception>
334-
///
335327
internal AliasInfo SetAliasValue(string aliasName, string value, bool force)
336328
{
337329
return SetAliasValue(aliasName, value, force, CommandOrigin.Internal);
@@ -373,10 +365,6 @@ internal AliasInfo SetAliasValue(string aliasName, string value, bool force)
373365
/// If the alias is read-only or constant.
374366
/// </exception>
375367
///
376-
/// <exception cref="SessionStateOverflowException">
377-
/// If the maximum number of aliases has been reached for this scope.
378-
/// </exception>
379-
///
380368
internal AliasInfo SetAliasValue(
381369
string aliasName,
382370
string value,
@@ -432,10 +420,6 @@ internal AliasInfo SetAliasValue(
432420
/// If the alias is read-only or constant.
433421
/// </exception>
434422
///
435-
/// <exception cref="SessionStateOverflowException">
436-
/// If the maximum number of aliases has been reached for this scope.
437-
/// </exception>
438-
///
439423
internal AliasInfo SetAliasValue(
440424
string aliasName,
441425
string value,
@@ -474,10 +458,6 @@ internal AliasInfo SetAliasValue(
474458
/// If the alias is read-only or constant.
475459
/// </exception>
476460
///
477-
/// <exception cref="SessionStateOverflowException">
478-
/// If the maximum number of aliases has been reached for this scope.
479-
/// </exception>
480-
///
481461
internal AliasInfo SetAliasItem(AliasInfo alias, bool force, CommandOrigin origin)
482462
{
483463
if (alias == null)
@@ -535,10 +515,6 @@ internal AliasInfo SetAliasItem(AliasInfo alias, bool force, CommandOrigin origi
535515
/// If the alias is read-only or constant.
536516
/// </exception>
537517
///
538-
/// <exception cref="SessionStateOverflowException">
539-
/// If the maximum number of aliases has been reached for this scope.
540-
/// </exception>
541-
///
542518
internal AliasInfo SetAliasItemAtScope(AliasInfo alias, string scopeID, bool force, CommandOrigin origin)
543519
{
544520
if (alias == null)
@@ -602,10 +578,6 @@ internal AliasInfo SetAliasItemAtScope(AliasInfo alias, string scopeID, bool for
602578
/// If the alias is read-only or constant.
603579
/// </exception>
604580
///
605-
/// <exception cref="SessionStateOverflowException">
606-
/// If the maximum number of aliases has been reached for this scope.
607-
/// </exception>
608-
///
609581
internal AliasInfo SetAliasItemAtScope(AliasInfo alias, string scopeID, bool force)
610582
{
611583
return SetAliasItemAtScope(alias, scopeID, force, CommandOrigin.Internal);

0 commit comments

Comments
 (0)