Replace Requires.NotNullOrEmpty(string) with ArgumentException.ThrowIfNullOrEmpty (#19197)

This commit is contained in:
xtqqczze
2023-02-24 09:45:33 -08:00
committed by GitHub
parent 4314e634ca
commit 744127608e
4 changed files with 4 additions and 12 deletions
@@ -89,7 +89,7 @@ namespace System.Management.Automation.Subsystem.Feedback
/// <param name="layout">The layout for displaying the actions.</param>
public FeedbackItem(string header, List<string>? actions, string? footer, FeedbackDisplayLayout layout)
{
Requires.NotNullOrEmpty(header, nameof(header));
ArgumentException.ThrowIfNullOrEmpty(header);
Header = header;
RecommendedActions = actions;
@@ -249,7 +249,7 @@ namespace System.Management.Automation.Subsystem.Prediction
/// <param name="suggestionText">The accepted suggestion text.</param>
public static void OnSuggestionAccepted(PredictionClient client, Guid predictorId, uint session, string suggestionText)
{
Requires.NotNullOrEmpty(suggestionText, nameof(suggestionText));
ArgumentException.ThrowIfNullOrEmpty(suggestionText);
var predictors = SubsystemManager.GetSubsystems<ICommandPredictor>();
if (predictors.Count == 0)
@@ -201,7 +201,7 @@ namespace System.Management.Automation.Subsystem.Prediction
/// <returns>A <see cref="PredictionContext"/> object.</returns>
public static PredictionContext Create(string input)
{
Requires.NotNullOrEmpty(input, nameof(input));
ArgumentException.ThrowIfNullOrEmpty(input);
Ast ast = Parser.ParseInput(input, out Token[] tokens, out _);
return new PredictionContext(ast, tokens);
@@ -239,7 +239,7 @@ namespace System.Management.Automation.Subsystem.Prediction
/// <param name="toolTip">The tooltip of the suggestion.</param>
public PredictiveSuggestion(string suggestion, string? toolTip)
{
Requires.NotNullOrEmpty(suggestion, nameof(suggestion));
ArgumentException.ThrowIfNullOrEmpty(suggestion);
SuggestionText = suggestion;
ToolTip = toolTip;
@@ -1733,14 +1733,6 @@ namespace System.Management.Automation.Internal
/// </summary>
internal static class Requires
{
internal static void NotNullOrEmpty(string value, string paramName)
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentNullException(paramName);
}
}
internal static void NotNullOrEmpty(ICollection value, string paramName)
{
if (value is null || value.Count == 0)