mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Replace Requires.NotNullOrEmpty(string) with ArgumentException.ThrowIfNullOrEmpty (#19197)
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user