Skip to content

Commit 7441276

Browse files
authored
Replace Requires.NotNullOrEmpty(string) with ArgumentException.ThrowIfNullOrEmpty (PowerShell#19197)
1 parent 4314e63 commit 7441276

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/IFeedbackProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public FeedbackItem(string header, List<string>? actions, FeedbackDisplayLayout
8989
/// <param name="layout">The layout for displaying the actions.</param>
9090
public FeedbackItem(string header, List<string>? actions, string? footer, FeedbackDisplayLayout layout)
9191
{
92-
Requires.NotNullOrEmpty(header, nameof(header));
92+
ArgumentException.ThrowIfNullOrEmpty(header);
9393

9494
Header = header;
9595
RecommendedActions = actions;

src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/CommandPrediction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static Action<ICommandPredictor> GetCallBack(PredictionClient client, uint sessi
249249
/// <param name="suggestionText">The accepted suggestion text.</param>
250250
public static void OnSuggestionAccepted(PredictionClient client, Guid predictorId, uint session, string suggestionText)
251251
{
252-
Requires.NotNullOrEmpty(suggestionText, nameof(suggestionText));
252+
ArgumentException.ThrowIfNullOrEmpty(suggestionText);
253253

254254
var predictors = SubsystemManager.GetSubsystems<ICommandPredictor>();
255255
if (predictors.Count == 0)

src/System.Management.Automation/engine/Subsystem/PredictionSubsystem/ICommandPredictor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public PredictionContext(Ast inputAst, Token[] inputTokens)
201201
/// <returns>A <see cref="PredictionContext"/> object.</returns>
202202
public static PredictionContext Create(string input)
203203
{
204-
Requires.NotNullOrEmpty(input, nameof(input));
204+
ArgumentException.ThrowIfNullOrEmpty(input);
205205

206206
Ast ast = Parser.ParseInput(input, out Token[] tokens, out _);
207207
return new PredictionContext(ast, tokens);
@@ -239,7 +239,7 @@ public PredictiveSuggestion(string suggestion)
239239
/// <param name="toolTip">The tooltip of the suggestion.</param>
240240
public PredictiveSuggestion(string suggestion, string? toolTip)
241241
{
242-
Requires.NotNullOrEmpty(suggestion, nameof(suggestion));
242+
ArgumentException.ThrowIfNullOrEmpty(suggestion);
243243

244244
SuggestionText = suggestion;
245245
ToolTip = toolTip;

src/System.Management.Automation/engine/Utils.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,14 +1733,6 @@ internal ReadOnlyBag(HashSet<T> hashset)
17331733
/// </summary>
17341734
internal static class Requires
17351735
{
1736-
internal static void NotNullOrEmpty(string value, string paramName)
1737-
{
1738-
if (string.IsNullOrEmpty(value))
1739-
{
1740-
throw new ArgumentNullException(paramName);
1741-
}
1742-
}
1743-
17441736
internal static void NotNullOrEmpty(ICollection value, string paramName)
17451737
{
17461738
if (value is null || value.Count == 0)

0 commit comments

Comments
 (0)