ModernBCL.Core.BLC
1.2.0
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
<PackageReference Include="ModernBCL.Core.BLC" Version="1.2.0" />
<PackageVersion Include="ModernBCL.Core.BLC" Version="1.2.0" />
<PackageReference Include="ModernBCL.Core.BLC" />
paket add ModernBCL.Core.BLC --version 1.2.0
#r "nuget: ModernBCL.Core.BLC, 1.2.0"
#:package ModernBCL.Core.BLC@1.2.0
#addin nuget:?package=ModernBCL.Core.BLC&version=1.2.0
#tool nuget:?package=ModernBCL.Core.BLC&version=1.2.0
๐ 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) andHashAccumulator64(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 | Versions 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. |
-
.NETFramework 4.8
- System.Memory (>= 4.6.3)
-
.NETFramework 4.8.1
- System.Memory (>= 4.6.3)
-
net8.0
- System.Memory (>= 4.6.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.