Skip to content

ModernBCL.Core.BLC v1.1.0: Introducing ThrowHelper Guard Clauses

Choose a tag to compare

@livedcode livedcode released this 25 Nov 13:57
· 5 commits to master since this release

This release marks a significant expansion of the ModernBCL.Core library beyond just hashing, focusing on improving developer quality-of-life and code cleanliness in .NET Framework 4.8 projects.

The main feature introduced is a comprehensive polyfill for modern argument validation.

🚀 Key Features and Improvements (v1.1.0)

1. Modern Argument Validation

Introduced the static ThrowHelper class which provides concise, modern guard clauses, eliminating the need for verbose if (null) checks in constructors and methods.

  • ThrowHelper.ThrowIfNull(T value): Throws ArgumentNullException.
  • ThrowHelper.ThrowIfNullOrEmpty(string value): Throws ArgumentException if the string is null or "".
  • ThrowHelper.ThrowIfNullOrWhiteSpace(string value): Throws ArgumentException if the string is null, empty, or only whitespace.

These methods leverage polyfilled attributes (like [CallerArgumentExpression]) to automatically capture the parameter name (nameof(arg)), simplifying code dramatically.

2. Core Updates

  • Package ID Change: Renamed the primary package ID from ModernBCL.Core.HashCode to ModernBCL.Core.BLC.
  • Version Bump: Updated project file (.csproj) and documentation to v1.1.0.
  • Documentation: Updated README.md with clear usage examples for ThrowHelper.

📦 Installation

To get this version, install it via NuGet:

Install-Package ModernBCL.Core.BLC -Version 1.1.0