◐ Shell
clean mode source ↗

Fix to use accurate message for validating a string argument is not null and not an empty string by daxian-dbw · Pull Request #26668 · PowerShell/PowerShell

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.