Skip to content

Conversation

@Tyrrrz
Copy link
Owner

@Tyrrrz Tyrrrz commented Nov 16, 2025

No description provided.

…Exception.ThrowIfNullOrEmpty(...)` and `ArgumentException.ThrowIfNullOrWhiteSpace(...)`
Copilot AI review requested due to automatic review settings November 16, 2025 16:25
@Tyrrrz Tyrrrz added the enhancement New feature or request label Nov 16, 2025
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 adds polyfills for three argument validation helper methods introduced in .NET 6.0 and .NET 7.0: ArgumentNullException.ThrowIfNull, ArgumentException.ThrowIfNullOrEmpty, and ArgumentException.ThrowIfNullOrWhiteSpace. These polyfills enable projects targeting older .NET versions to use these modern convenience methods for argument validation.

Key changes:

  • Added ArgumentNullException.ThrowIfNull polyfill for .NET versions prior to 6.0
  • Added ArgumentException.ThrowIfNullOrEmpty and ArgumentException.ThrowIfNullOrWhiteSpace polyfills for .NET versions prior to 7.0
  • Comprehensive test coverage for all three methods verifying correct exception types and parameter names

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
PolyShim/Net60/ArgumentNullException.cs Implements ThrowIfNull static method polyfill for .NET < 6.0, using CallerArgumentExpression to capture parameter names
PolyShim/Net70/ArgumentException.cs Implements ThrowIfNullOrEmpty and ThrowIfNullOrWhiteSpace static method polyfills for .NET < 7.0, with proper null vs empty/whitespace exception handling
PolyShim.Tests/Net60/ArgumentNullExceptionTests.cs Tests ThrowIfNull with null and non-null values, verifying correct exception and parameter name capture
PolyShim.Tests/Net70/ArgumentExceptionTests.cs Tests both ThrowIfNullOrEmpty and ThrowIfNullOrWhiteSpace with appropriate test cases for null, empty/whitespace, and valid values

💡 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

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants