ModernBCL.Core.BLC v1.1.0: Introducing ThrowHelper Guard Clauses
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): ThrowsArgumentNullException.ThrowHelper.ThrowIfNullOrEmpty(string value): ThrowsArgumentExceptionif the string is null or"".ThrowHelper.ThrowIfNullOrWhiteSpace(string value): ThrowsArgumentExceptionif 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.HashCodetoModernBCL.Core.BLC. - Version Bump: Updated project file (
.csproj) and documentation to v1.1.0. - Documentation: Updated
README.mdwith clear usage examples forThrowHelper.
📦 Installation
To get this version, install it via NuGet:
Install-Package ModernBCL.Core.BLC -Version 1.1.0