Skip to content

Conversation

@samtrion
Copy link
Contributor

@samtrion samtrion commented Jan 3, 2026

Replaced all uses of custom Argument.ThrowIfNull and Argument.ThrowIfNullOrWhiteSpace with the standard .NET methods ArgumentNullException.ThrowIfNull and ArgumentException.ThrowIfNullOrWhiteSpace. This update improves code clarity, consistency, and leverages built-in .NET validation utilities across the codebase.

Summary by CodeRabbit

  • Refactor
    • Enhanced input validation across builder components with improved exception handling for better error diagnostics.

✏️ Tip: You can customize this high-level summary in your review settings.

Replaced all uses of custom Argument.ThrowIfNull and Argument.ThrowIfNullOrWhiteSpace with the standard .NET methods ArgumentNullException.ThrowIfNull and ArgumentException.ThrowIfNullOrWhiteSpace. This update improves code clarity, consistency, and leverages built-in .NET validation utilities across the codebase.
@samtrion samtrion self-assigned this Jan 3, 2026
@samtrion samtrion added state:ready for merge Indicates that a pull request has been reviewed and approved, and is ready to be merged into the mai type:chore Indicates some housework that needs to be done. labels Jan 3, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 3, 2026

Walkthrough

The pull request replaces custom argument validation calls across multiple builder, model, and factory files with built-in .NET exception types. Specifically, Argument.ThrowIfNullOrWhiteSpace() calls are replaced with ArgumentException.ThrowIfNullOrWhiteSpace(), and Argument.ThrowIfNull() calls are replaced with ArgumentNullException.ThrowIfNull(). Control flow and public APIs remain unchanged.

Changes

Cohort / File(s) Summary
Builder validation refactoring
src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilder.cs, GlobalJsonBuilderExtensions.cs, ProjectBuilderExtensions.cs, ProjectFactoryExtensions.cs, SubdirectoryBuilder.cs, TemporaryDirectoryBuilder.cs, TestPackageBuilder.cs
Replaced generic Argument validation calls with specific exception types: ArgumentException.ThrowIfNullOrWhiteSpace() and ArgumentNullException.ThrowIfNull() across multiple validation points for runtime versions, builder instances, file names, content, and package paths.
Model validation refactoring
src/NetEvolve.ProjectBuilders/Models/PropertyGroup.cs, TargetFramework.cs
Changed key and name/value validation from Argument.ThrowIfNullOrWhiteSpace() to ArgumentException.ThrowIfNullOrWhiteSpace() in Add and Create methods respectively.
Factory validation refactoring
src/NetEvolve.ProjectBuilders/ProjectFactory.cs
Updated environment variable parameter validation from Argument.ThrowIfNullOrWhiteSpace() and Argument.ThrowIfNull() to ArgumentException.ThrowIfNullOrWhiteSpace() and ArgumentNullException.ThrowIfNull() respectively.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop, skip, and refactor away,
We've swapped generic calls for exceptions bright—
From custom Argument to built-in types today,
No logic changed, just validations made right!
Let the .NET exceptions take flight! ✨

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing custom argument validation helpers with standard .NET exception helpers across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 94.12% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (10)
src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilderExtensions.cs (1)

3-3: Remove unused import.

The NetEvolve.Arguments namespace is no longer referenced in this file after switching to built-in .NET exception helpers.

🔎 Proposed fix
-using NetEvolve.Arguments;
 using NetEvolve.ProjectBuilders.Abstractions;
src/NetEvolve.ProjectBuilders/Builders/TestPackageBuilder.cs (1)

4-4: Remove unused import.

The NetEvolve.Arguments namespace is no longer referenced in this file after switching to built-in .NET exception helpers.

🔎 Proposed fix
 using CliWrap;
-using NetEvolve.Arguments;
 using NetEvolve.ProjectBuilders.Abstractions;
src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilder.cs (1)

8-8: Remove unused import.

The NetEvolve.Arguments namespace is no longer referenced in this file after switching to built-in .NET exception helpers.

🔎 Proposed fix
 using System.Threading.Tasks;
-using NetEvolve.Arguments;
 using NetEvolve.ProjectBuilders.Abstractions;
src/NetEvolve.ProjectBuilders/Builders/ProjectFactoryExtensions.cs (1)

5-5: Remove unused import.

The NetEvolve.Arguments namespace is no longer referenced in this file after switching to built-in .NET exception helpers.

🔎 Proposed fix
 using System.Diagnostics.CodeAnalysis;
-using NetEvolve.Arguments;
 using NetEvolve.ProjectBuilders.Abstractions;
src/NetEvolve.ProjectBuilders/Builders/SubdirectoryBuilder.cs (1)

7-7: Remove unused import.

The NetEvolve.Arguments namespace is no longer referenced in this file after switching to built-in .NET exception helpers.

🔎 Proposed fix
 using System.Threading.Tasks;
-using NetEvolve.Arguments;
 using NetEvolve.ProjectBuilders.Abstractions;
src/NetEvolve.ProjectBuilders/Models/TargetFramework.cs (1)

128-129: LGTM! Clean migration to .NET built-in validation.

The replacement of custom validation with ArgumentException.ThrowIfNullOrWhiteSpace is correct and maintains identical behavior.

Optional: Consider removing unused import

If NetEvolve.Arguments is no longer used in this file after these changes, consider removing the import on line 6:

-using NetEvolve.Arguments;
src/NetEvolve.ProjectBuilders/Models/PropertyGroup.cs (1)

51-51: LGTM! Consistent with .NET validation patterns.

The switch to ArgumentException.ThrowIfNullOrWhiteSpace is correct for the key parameter validation.

Optional: Consider removing unused import

If NetEvolve.Arguments is no longer used in this file, consider removing the import on line 5:

-using NetEvolve.Arguments;
src/NetEvolve.ProjectBuilders/ProjectFactory.cs (1)

137-137: LGTM! Correct null check for array parameter.

Using ArgumentNullException.ThrowIfNull is the appropriate validation for the variables array parameter.

Optional: Consider removing unused import

If NetEvolve.Arguments is no longer used in this file after these changes, consider removing the import on line 14:

-using NetEvolve.Arguments;
src/NetEvolve.ProjectBuilders/Builders/ProjectBuilderExtensions.cs (1)

282-282: LGTM! Correct string validation.

Using ArgumentException.ThrowIfNullOrWhiteSpace is appropriate for the package name parameter.

Optional: Consider removing unused import

If NetEvolve.Arguments is no longer used in this file after these changes, consider removing the import on line 6:

-using NetEvolve.Arguments;
src/NetEvolve.ProjectBuilders/Builders/TemporaryDirectoryBuilder.cs (1)

47-47: LGTM! Consistent validation across directory operations.

All three string parameter validations correctly use ArgumentException.ThrowIfNullOrWhiteSpace, maintaining consistency with the related SubdirectoryBuilder class.

Optional: Consider removing unused import

If NetEvolve.Arguments is no longer used in this file after these changes, consider removing the import on line 7:

-using NetEvolve.Arguments;

Also applies to: 55-55, 75-75

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between bfbaee3 and 1c7d64f.

📒 Files selected for processing (10)
  • src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilder.cs
  • src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilderExtensions.cs
  • src/NetEvolve.ProjectBuilders/Builders/ProjectBuilderExtensions.cs
  • src/NetEvolve.ProjectBuilders/Builders/ProjectFactoryExtensions.cs
  • src/NetEvolve.ProjectBuilders/Builders/SubdirectoryBuilder.cs
  • src/NetEvolve.ProjectBuilders/Builders/TemporaryDirectoryBuilder.cs
  • src/NetEvolve.ProjectBuilders/Builders/TestPackageBuilder.cs
  • src/NetEvolve.ProjectBuilders/Models/PropertyGroup.cs
  • src/NetEvolve.ProjectBuilders/Models/TargetFramework.cs
  • src/NetEvolve.ProjectBuilders/ProjectFactory.cs
🧰 Additional context used
🧬 Code graph analysis (2)
src/NetEvolve.ProjectBuilders/Builders/TemporaryDirectoryBuilder.cs (3)
src/NetEvolve.ProjectBuilders/Builders/SubdirectoryBuilder.cs (3)
  • SubdirectoryBuilder (35-75)
  • SubdirectoryBuilder (42-42)
  • Stream (56-68)
src/NetEvolve.ProjectBuilders/Abstractions/ISubdirectoryBuilder.cs (1)
  • Stream (72-72)
src/NetEvolve.ProjectBuilders/Builders/ProjectBuilder.cs (1)
  • Stream (82-82)
src/NetEvolve.ProjectBuilders/Builders/SubdirectoryBuilder.cs (1)
src/NetEvolve.ProjectBuilders/Builders/TemporaryDirectoryBuilder.cs (1)
  • Stream (53-70)
🔇 Additional comments (9)
src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilderExtensions.cs (1)

40-40: LGTM!

The replacement of the custom validation helper with the built-in ArgumentNullException.ThrowIfNull is correct and improves code clarity.

src/NetEvolve.ProjectBuilders/Builders/TestPackageBuilder.cs (1)

90-90: LGTM!

The replacement with ArgumentNullException.ThrowIfNull is correct and maintains the same validation behavior.

src/NetEvolve.ProjectBuilders/Builders/ProjectFactoryExtensions.cs (1)

125-125: LGTM!

The replacement with ArgumentException.ThrowIfNullOrWhiteSpace is correct and improves consistency with the .NET framework.

src/NetEvolve.ProjectBuilders/Builders/SubdirectoryBuilder.cs (1)

50-50: LGTM!

Both replacements with ArgumentException.ThrowIfNullOrWhiteSpace are correct and align with the .NET framework's built-in validation methods.

Also applies to: 58-58

src/NetEvolve.ProjectBuilders/Builders/GlobalJsonBuilder.cs (1)

66-66: Verify .NET 8.0+ target framework.

The replacement with ArgumentException.ThrowIfNullOrWhiteSpace is correct. The project targets net8.0, net9.0, and net10.0, as defined in Directory.Build.props, so this method is available in all target frameworks.

src/NetEvolve.ProjectBuilders/ProjectFactory.cs (1)

123-124: LGTM! Appropriate exception types for parameter validation.

The validation changes are correct:

  • ArgumentException.ThrowIfNullOrWhiteSpace for name (string)
  • ArgumentException.ThrowIfNullOrWhiteSpace for value (string?, requires non-null when explicitly adding)
src/NetEvolve.ProjectBuilders/Builders/ProjectBuilderExtensions.cs (3)

56-58: LGTM! Proper validation with .NET exception helpers.

The validation pattern is correct:

  • ArgumentNullException.ThrowIfNull for the builder object
  • ArgumentException.ThrowIfNullOrWhiteSpace for fileName and content strings

98-100: LGTM! Consistent validation pattern.

Identical validation pattern as AddCSharpFile, which is correct and consistent.


133-133: LGTM! Appropriate null check for builder parameter.

The validation correctly uses ArgumentNullException.ThrowIfNull for the builder object parameter.

@samtrion samtrion merged commit a556470 into main Jan 3, 2026
5 checks passed
@samtrion samtrion deleted the chore/argument-modernization branch January 3, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:ready for merge Indicates that a pull request has been reviewed and approved, and is ready to be merged into the mai type:chore Indicates some housework that needs to be done.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants