Skip to content

Conversation

@daxian-dbw
Copy link
Member

PR Summary

Fix #26620

Use ArgumentException.ThrowIfNullOrEmpty instead of throw PSTraceSource.NewArgumentNullException(string paramname) for not-null-not-empty argument validation. This simplifies the argument validation.

Potential breaking change: the exception throw for invalid argument value becomes System.ArgumentException from the old System.Management.Automation.PSArgumentNullException. I think this falls in bucket 3 (grey area).

PR Checklist

@daxian-dbw daxian-dbw requested a review from a team as a code owner January 7, 2026 22:09
Copilot AI review requested due to automatic review settings January 7, 2026 22:09
@daxian-dbw daxian-dbw added CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log labels Jan 7, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes argument validation in the CompletionResult constructor by replacing the legacy PowerShell-specific null/empty string validation pattern with the standard .NET ArgumentException.ThrowIfNullOrEmpty method. This simplifies the validation code while introducing a minor breaking change in the exception type thrown from PSArgumentNullException to ArgumentException.

Key Changes

  • Replaced manual string.IsNullOrEmpty checks followed by PSTraceSource.NewArgumentNullException calls with ArgumentException.ThrowIfNullOrEmpty calls
  • Consolidated validation logic to be more concise (from ~15 lines to 3 lines)
  • Maintained the same validation behavior (null or empty strings are rejected)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[System.Management.Automation.CompletionResult]::new considered empty string as null

2 participants