From ebf4d1a44234ae0e7963e5b90bb34d9fe1e7886e Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 14 Feb 2023 10:01:06 -0800 Subject: [PATCH] Revert " Requires.NotNull-->ArgumentNullException.ThrowIfNull (#18820)" This reverts commit 078866987b3a0abe7a12b8d1950c4296ef61990d. --- .../Subsystem/PredictionSubsystem/CommandPrediction.cs | 2 +- .../Subsystem/PredictionSubsystem/ICommandPredictor.cs | 4 ++-- .../engine/Subsystem/SubsystemManager.cs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs b/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs index 7ed70e247a5..7a87b259314 100644 --- a/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs +++ b/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs @@ -142,7 +142,7 @@ await Task.WhenAny( /// History command lines provided as references for prediction. public static void OnCommandLineAccepted(PredictionClient client, IReadOnlyList history) { - ArgumentNullException.ThrowIfNull(history); + Requires.NotNull(history, nameof(history)); var predictors = SubsystemManager.GetSubsystems(); if (predictors.Count == 0) diff --git a/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/ICommandPredictor.cs b/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/ICommandPredictor.cs index 95e8487bbad..d528067452c 100644 --- a/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/ICommandPredictor.cs +++ b/src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/ICommandPredictor.cs @@ -181,8 +181,8 @@ public sealed class PredictionContext /// The objects from parsing the current command line input. public PredictionContext(Ast inputAst, Token[] inputTokens) { - ArgumentNullException.ThrowIfNull(inputAst); - ArgumentNullException.ThrowIfNull(inputTokens); + Requires.NotNull(inputAst, nameof(inputAst)); + Requires.NotNull(inputTokens, nameof(inputTokens)); var cursor = inputAst.Extent.EndScriptPosition; var astContext = CompletionAnalysis.ExtractAstContext(inputAst, inputTokens, cursor); diff --git a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs index e389040899e..c832ec46601 100644 --- a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs +++ b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs @@ -131,7 +131,7 @@ public static ReadOnlyCollection GetAllSubsystemInfo() /// The object that represents the concrete subsystem. public static SubsystemInfo GetSubsystemInfo(Type subsystemType) { - ArgumentNullException.ThrowIfNull(subsystemType); + Requires.NotNull(subsystemType, nameof(subsystemType)); if (s_subSystemTypeMap.TryGetValue(subsystemType, out SubsystemInfo? subsystemInfo)) { @@ -180,7 +180,7 @@ public static void RegisterSubsystem(TImple where TConcreteSubsystem : class, ISubsystem where TImplementation : class, TConcreteSubsystem { - ArgumentNullException.ThrowIfNull(proxy); + Requires.NotNull(proxy, nameof(proxy)); RegisterSubsystem(GetSubsystemInfo(typeof(TConcreteSubsystem)), proxy); } @@ -192,7 +192,7 @@ public static void RegisterSubsystem(TImple /// An instance of the implementation. public static void RegisterSubsystem(SubsystemKind kind, ISubsystem proxy) { - ArgumentNullException.ThrowIfNull(proxy); + Requires.NotNull(proxy, nameof(proxy)); SubsystemInfo info = GetSubsystemInfo(kind); if (!info.SubsystemType.IsAssignableFrom(proxy.GetType()))