Skip to content

Commit 4314e63

Browse files
authored
Use ArgumentOutOfRangeException.ThrowIfNegativeOrZero when applicable (PowerShell#19201)
1 parent 0a11f79 commit 4314e63

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/FeedbackHub.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static class FeedbackHub
6060
/// </summary>
6161
public static List<FeedbackResult>? GetFeedback(Runspace runspace, int millisecondsTimeout)
6262
{
63-
Requires.Condition(millisecondsTimeout > 0, nameof(millisecondsTimeout));
63+
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(millisecondsTimeout);
6464

6565
var localRunspace = runspace as LocalRunspace;
6666
if (localRunspace is null)

src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static class CommandPrediction
7474
/// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
7575
public static async Task<List<PredictionResult>?> PredictInputAsync(PredictionClient client, Ast ast, Token[] astTokens, int millisecondsTimeout)
7676
{
77-
Requires.Condition(millisecondsTimeout > 0, nameof(millisecondsTimeout));
77+
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(millisecondsTimeout);
7878

7979
var predictors = SubsystemManager.GetSubsystems<ICommandPredictor>();
8080
if (predictors.Count == 0)

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,13 +1748,5 @@ internal static void NotNullOrEmpty(ICollection value, string paramName)
17481748
throw new ArgumentNullException(paramName);
17491749
}
17501750
}
1751-
1752-
internal static void Condition([DoesNotReturnIf(false)] bool precondition, string paramName)
1753-
{
1754-
if (!precondition)
1755-
{
1756-
throw new ArgumentException(paramName);
1757-
}
1758-
}
17591751
}
17601752
}

0 commit comments

Comments
 (0)