ModernBCL.Core.BLC 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ModernBCL.Core.BLC --version 1.2.0
                    
NuGet\Install-Package ModernBCL.Core.BLC -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ModernBCL.Core.BLC" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ModernBCL.Core.BLC" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ModernBCL.Core.BLC" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ModernBCL.Core.BLC --version 1.2.0
                    
#r "nuget: ModernBCL.Core.BLC, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ModernBCL.Core.BLC@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ModernBCL.Core.BLC&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=ModernBCL.Core.BLC&version=1.2.0
                    
Install as a Cake Tool

๐Ÿ“˜ ModernBCL.Core.BLC

Modern Polyfills for Legacy .NET Framework 4.8 / 4.8.1

ModernBCL.Core.BLC brings high-performance, zero-allocation replacements for missing modern BCL APIs to legacy .NET Framework apps โ€” enabling performance and clarity normally available only in .NET 7/8.

This library is especially useful for:

  • Enterprise systems that must stay on .NET Framework 4.8 / 4.8.1
  • Developers wanting modern C# coding patterns on legacy frameworks
  • Teams needing high-quality hashing or safe guard clauses
  • Projects migrating from .NET Framework โ†’ .NET Core but needing parity

๐ŸŽฏ Project Goals

ModernBCL.Core.BLC provides:

โœ” High-performance hashing

  • Drop-in System.HashCode polyfill (for .NET Framework only)
  • Modern, order-sensitive HashCode.Combine()
  • HashAccumulator (32-bit) and HashAccumulator64 (64-bit)
  • Extremely low collision rates
  • Zero allocations

โœ” Modern guard clauses

  • Clean replacement for repetitive null/empty/whitespace checks
  • Fluent Guard.Against() API
  • Polyfilled [CallerArgumentExpression] attribute
  • No need to manually pass parameter names

โœ” Cleaner code, safer APIs

  • Modern BCL patterns for older frameworks
  • Full parity with .NET 6/7/8 guard & hashing behavior (where appropriate)

๐Ÿš€ Installation

Install via NuGet:

.NET CLI

dotnet add package ModernBCL.Core.BLC --version 1.2.0

Visual Studio Package Manager Console

Install-Package ModernBCL.Core.BLC -Version 1.2.0

๐Ÿ“ฆ Compatibility

Target Status Notes
.NET Framework 4.8 / 4.8.1 โœ” Supported HashCode polyfill is active
.NET 8+ / .NET Core โœ” Supported Uses native System.HashCode (polyfill disabled)
NuGet Package โœ” Multi-target net48; net481; net8.0

ModernBCL intelligently switches behavior:

  • Under net48/net481 โ†’ uses ModernBCL HashCode polyfill
  • Under net8+ โ†’ uses native framework HashCode

๐Ÿ’ป Usage Examples


1. โšก High-Performance Hash Codes

using System;

public class ProductKey
{
    public string ProductId { get; }
    public string Color { get; }
    public int Size { get; }

    public override int GetHashCode()
    {
        return HashCode.Combine(ProductId, Color, Size);
    }
}

2. ๐Ÿ” Modern Guard Clauses

using ModernBCL.Core.Guards;

public class DependencyContainer
{
    public DependencyContainer(object service, string clientName)
    {
        _service = Guard.Against(service).Null();
        _clientName = Guard.Against(clientName).NullOrWhiteSpace();
    }
}

โš™๏ธ How It Works

๐Ÿงฎ HashCode Polyfill

  • Only used under .NET Framework
  • Fully deterministic
  • Zero allocations
  • Based on HashAccumulator

๐Ÿ›ก Guard Polyfills

  • Provides [CallerArgumentExpression] for .NET Framework
  • Modern fluent API on legacy runtimes

๐Ÿ“Š Benchmarks Included

Benchmark results generated to:

BenchmarkDotNet.Artifacts/results/

Formats:

  • .html
  • .md
  • .csv

๐Ÿงพ Changelog

Version 1.2.0 (Latest)

โœ” Added multi-targeting: net48; net481; net8.0
โœ” Added HashAccumulator64 (64-bit hashing)
โœ” Added comparer suite
โœ” Added full Guard API
โœ” Added fuzz tests
โœ” Added benchmarks
โœ” Improved HashCode polyfill

Version 1.1.1

โœ” Support for both net48 and net481

Version 1.1.0

โœ” ThrowHelper + polyfill attributes

Version 1.0.0

โœ” Initial release with HashCode polyfill


๐Ÿ“„ License

MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 106 1/2/2026
1.2.0 104 11/29/2025
1.1.1 181 11/25/2025
1.1.0 185 11/25/2025