ZeroPrimitives.Core 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZeroPrimitives.Core --version 1.0.0
                    
NuGet\Install-Package ZeroPrimitives.Core -Version 1.0.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="ZeroPrimitives.Core" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroPrimitives.Core" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ZeroPrimitives.Core" />
                    
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 ZeroPrimitives.Core --version 1.0.0
                    
#r "nuget: ZeroPrimitives.Core, 1.0.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 ZeroPrimitives.Core@1.0.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=ZeroPrimitives.Core&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ZeroPrimitives.Core&version=1.0.0
                    
Install as a Cake Tool

ZeroPrimitives

Architectural Standard: 100% Pure C#, Zero External Dependencies, Multi-Targeting across .NET 8.0, .NET Framework 4.6.2, and .NET Standard 2.0.

ZeroPrimitives is a sovereign, high-throughput .NET library engineered for ultra-fast, zero-allocation primitive conversions, low-level span/pointer number parsing, cryptographic/non-cryptographic hashing, binary buffer manipulation, and expression-compiled object mapping.

It replaces slow legacy conversion methods (Convert.To*, value.ToString(), int.TryParse with intermediate heap allocations) with raw CPU register unboxing, ReadOnlySpan<char> slicing, and pointer arithmetic.


🏛️ Comprehensive Feature Suite

1. Zero-Allocation Type Conversion (FastConvert)

  • Direct Register Unboxing: Immediate unpack for boxed value types (int, long, decimal, double, float, short, byte, bool, Guid, DateTime) without calling .ToString().
  • Nullable Variants: AsNullableInt, AsNullableLong, AsNullableDecimal, AsNullableDouble, AsNullableBool, AsNullableDateTime, AsNullableGuid.
  • Enum Conversion: AsEnum<TEnum>(), AsNullableEnum<TEnum>() (case-insensitive string/number conversion).
  • Delimited Collections: FromDelimitedString<T>() and AsDelimitedString<T>() for fast CSV/list parsing.

2. Low-Level Span/Pointer Parsers (FastNumberParser, FastDateParser)

  • Pointer-based Integer Loops: (acc << 3) + (acc << 1) + (*ptr - '0').
  • Intelligent Separator Analysis: Handles both international and Vietnamese thousand/decimal delimiters (1,234.56 vs 1.234,56 vs 1.500.000 VNĐ).
  • SQL Server DateTime Safety: Zero-allocation ISO 8601 and dd/MM/yyyy parsing with clamping to SQL Server DATETIME range (1753-01-01 to 9999-12-31).

3. Cryptography & Hashing (FastHash)

  • Non-Cryptographic: Ultra-fast 32-bit and 64-bit FNV-1a for hash tables, caching, and span lookup.
  • Cryptographic: Md5Hex, Sha1Hex, and Sha256Hex formatting directly to hexadecimal.

4. Binary Buffers & Endianness (FastBuffer)

  • GZip Compression: GzipCompress and GzipDecompressToString with optimized memory streams.
  • Bit-level Endian Swapping: SwapInt16, SwapUInt16, SwapInt32, SwapUInt32, SwapInt64, SwapUInt64.

5. Calendar & Date Extensions (DateTimeExtensions)

  • Boundaries: FirstDayOfMonth, LastDayOfMonth, FirstDayOfQuarter, LastDayOfQuarter, FirstDayOfYear, LastDayOfYear, StartOfDay, EndOfDay.
  • Unix Timestamps: ToUnixTimestampSeconds, ToUnixTimestampMilliseconds, FromUnixSeconds, FromUnixMilliseconds.
  • Formatters: AsDateString_ddMMyyyy, AsDateString_ddMMyyyyHHmmss, ToOrdinalDateString (6th Jan, 2026).

6. String & Functional Utilities (StringExtensions, FunctionalExtensions)

  • String Manipulation: NullIfEmpty, Truncate, TrimChars, AppendPathSegments, SetQueryParam, RemoveLetterToInt, RemoveDiacritics.
  • Functional Pipeline: Let<T, TResult>, AsTask<T>.
  • Sanitation: ReplaceNullStrings (replaces null string properties with "" before SQL inserts).

7. Compiled Expression Object Mapper (FastMapper)

  • Compiles Expression Trees into native IL delegates cached per type-pair, delivering raw assignment speed with zero reflection overhead.

⚡ Quick Example

using ZeroPrimitives;
using ZeroPrimitives.Buffers;
using ZeroPrimitives.Cryptography;
using ZeroPrimitives.Extensions;

// 1. Direct Unbox (0 bytes allocated)
object boxed = 12345;
int num = boxed.AsInt(); // 12345

// 2. Formatted Currency Parse (0 bytes allocated)
object price = " 1,500,000.50 VNĐ ";
decimal amount = price.AsDecimal(); // 1500000.50m

// 3. Date Parsing & Calendar Helpers
DateTime dt = "25/12/2026 14:30:00".AsDate();
DateTime monthStart = dt.FirstDayOfMonth(); // 2026-12-01
string sqlDate = dt.AsSqlDateString();      // "2026-12-25"

// 4. Fast Hash & Endianness
string md5 = FastHash.Md5Hex("ZeroPlatform");
int beInt = FastBuffer.SwapInt32(0x12345678); // 0x78563412

// 5. Expression-Compiled FastMapper
var dto = FastMapper.Map<SourceEntity, TargetDto>(entity);

Multi-Targeting Support

  • .NET 8.0+ (High-throughput cloud, edge AI & IPC)
  • .NET Framework 4.6.2+ (Enterprise WinForms / WPF applications)
  • .NET Standard 2.0 (Universal cross-platform compatibility)

License

MIT License. Copyright © 2026 Phong Võ (kzxl).

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on ZeroPrimitives.Core:

Package Downloads
ZeroData.Core

Pure C# high-throughput in-memory columnar DataFrame engine (Apache Arrow / Polars equivalent) with zero-GC queries, GroupBy, and time-series resampling for .NET.

ZeroStorage.Core

Package Description

ZeroAudioVisual

Package Description

ZeroIoT

Package Description

ZeroReports

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 75 9/16/2026
1.0.0 182 9/14/2026