From 41161fa9626eec57d3359b4bff0f7990f35e7149 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Thu, 23 Feb 2023 10:49:39 +0000 Subject: [PATCH] Replace `Requires.Condition` with `ArgumentOutOfRangeException.ThrowIfNegativeOrZero` --- .../engine/Subsystem/FeedbackSubsystem/FeedbackHub.cs | 2 +- .../Subsystem/PredictionSubsystem/CommandPrediction.cs | 2 +- src/System.Management.Automation/engine/Utils.cs | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/FeedbackHub.cs b/src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/FeedbackHub.cs index 6818d25bcdb..fa12c0ca751 100644 --- a/src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/FeedbackHub.cs +++ b/src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/FeedbackHub.cs @@ -60,7 +60,7 @@ public static class FeedbackHub /// public static List? GetFeedback(Runspace runspace, int millisecondsTimeout) { - Requires.Condition(millisecondsTimeout > 0, nameof(millisecondsTimeout)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(millisecondsTimeout); var localRunspace = runspace as LocalRunspace; if (localRunspace is null) diff --git a/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs b/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs index 7ed70e247a5..dcafbbc6233 100644 --- a/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs +++ b/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs @@ -74,7 +74,7 @@ public static class CommandPrediction /// A list of objects. public static async Task?> PredictInputAsync(PredictionClient client, Ast ast, Token[] astTokens, int millisecondsTimeout) { - Requires.Condition(millisecondsTimeout > 0, nameof(millisecondsTimeout)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(millisecondsTimeout); var predictors = SubsystemManager.GetSubsystems(); if (predictors.Count == 0) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 74e3e468246..bb0a50e8bc4 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1748,13 +1748,5 @@ internal static void NotNullOrEmpty(ICollection value, string paramName) throw new ArgumentNullException(paramName); } } - - internal static void Condition([DoesNotReturnIf(false)] bool precondition, string paramName) - { - if (!precondition) - { - throw new ArgumentException(paramName); - } - } } }