From 078866987b3a0abe7a12b8d1950c4296ef61990d Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Sat, 7 Jan 2023 16:11:01 +0100 Subject: [PATCH] Requires.NotNull-->ArgumentNullException.ThrowIfNull (#18820) --- .../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 7a87b25931..7ed70e247a 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 @@ namespace System.Management.Automation.Subsystem.Prediction /// History command lines provided as references for prediction. public static void OnCommandLineAccepted(PredictionClient client, IReadOnlyList history) { - Requires.NotNull(history, nameof(history)); + ArgumentNullException.ThrowIfNull(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 d528067452..95e8487bba 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 @@ namespace System.Management.Automation.Subsystem.Prediction /// The objects from parsing the current command line input. public PredictionContext(Ast inputAst, Token[] inputTokens) { - Requires.NotNull(inputAst, nameof(inputAst)); - Requires.NotNull(inputTokens, nameof(inputTokens)); + ArgumentNullException.ThrowIfNull(inputAst); + ArgumentNullException.ThrowIfNull(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 1af41a6745..022c163a16 100644 --- a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs +++ b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs @@ -131,7 +131,7 @@ namespace System.Management.Automation.Subsystem /// The object that represents the concrete subsystem. public static SubsystemInfo GetSubsystemInfo(Type subsystemType) { - Requires.NotNull(subsystemType, nameof(subsystemType)); + ArgumentNullException.ThrowIfNull(subsystemType); if (s_subSystemTypeMap.TryGetValue(subsystemType, out SubsystemInfo? subsystemInfo)) { @@ -180,7 +180,7 @@ namespace System.Management.Automation.Subsystem where TConcreteSubsystem : class, ISubsystem where TImplementation : class, TConcreteSubsystem { - Requires.NotNull(proxy, nameof(proxy)); + ArgumentNullException.ThrowIfNull(proxy); RegisterSubsystem(GetSubsystemInfo(typeof(TConcreteSubsystem)), proxy); } @@ -192,7 +192,7 @@ namespace System.Management.Automation.Subsystem /// An instance of the implementation. public static void RegisterSubsystem(SubsystemKind kind, ISubsystem proxy) { - Requires.NotNull(proxy, nameof(proxy)); + ArgumentNullException.ThrowIfNull(proxy); SubsystemInfo info = GetSubsystemInfo(kind); if (!info.SubsystemType.IsAssignableFrom(proxy.GetType()))