High-performance .NET libraries

Zero allocations.
Native AOT.
Compile-time correctness.

A family of source-generated .NET libraries that eliminate runtime allocations, reflection, and dynamic dispatch from your hot paths.

Packages

ZeroAlloc.Analyzers

42+ Roslyn analyzers that detect allocation-heavy patterns at build time.

Build-time allocation detection

ZeroAlloc.Inject

Compile-time dependency injection via Roslyn source generator. No reflection, fully Native AOT safe.

~3 ns vs ~35 ns (Microsoft DI)

ZeroAlloc.Mediator

Zero-allocation source-generated mediator for request/response and notifications.

~2 ns vs ~88 ns (MediatR)

ZeroAlloc.ValueObjects

Source-generated Equals, GetHashCode, == and ToString for existing partial class/struct types.

3.1 ns vs 45.2 ns (CFE)

ZeroAlloc.Validation

Source-generated, attribute-based validation for .NET. Zero heap allocations on the valid path — no reflection, no runtime overhead, Native AOT safe.

6.7 ns vs 327 ns (FluentValidation), 0 B

ZeroAlloc.Pipeline

Shared building block for pipeline-aware source generators. Compile-time behavior wiring, no reflection, no heap allocation, Native AOT compatible.

6.4× faster at 5 behaviors, 0 B allocated

ZeroAlloc.Specification

Source-generated, zero-allocation specification pattern for .NET 8+.

Struct composition, 0 B allocated

ZeroAlloc.Results

Zero-allocation, no-boxing Result<T,E> library for .NET 9 with full CSharpFunctionalExtensions API parity.

8.7× faster vs CSharpFunctionalExtensions, 0 B allocated

ZeroAlloc.Rest

Source-generated, Native AOT-compatible REST client for .NET 10+. Define your HTTP API as a C# interface — the Roslyn generator emits a fully type-safe, zero-reflection implementation at compile time.

3.2×–5.5× faster vs Refit

ZeroAlloc.Collections

Zero-allocation, high-performance collection types for .NET — pooled lists, ring buffers, span dictionaries, stacks, queues, and fixed-size lists with ref struct and heap variants.

2× faster, 0 B vs List<T>

ZeroAlloc.AsyncEvents

Zero-allocation async event primitives for .NET. ValueTask-based AsyncEvent<T> with sequential and parallel invocation modes, source-generated dispatch, no reflection.

0 B sequential, 3× faster parallel vs naive async

ZeroAlloc.Notify

Zero-allocation async INPC library for .NET. Roslyn source generator wires PropertyChanged/PropertyChanging dispatch at compile time — no reflection, fully awaitable.

Only fully-awaitable INPC, ValueTask dispatch

ZeroAlloc.Telemetry

Source-generated OpenTelemetry proxy for .NET. Annotate an interface — the Roslyn generator emits a BCL-based ActivitySource + Meter decorator. No OpenTelemetry SDK dependency, fully Native AOT safe.

Zero-alloc spans + metrics, no OTel SDK

ZeroAlloc.EventSourcing

Zero-allocation event sourcing for .NET 8+. Struct-based aggregate state, in-memory and SQL backends, source-generated aggregate boilerplate, optional OpenTelemetry instrumentation.

Struct state, 0 B on the read path

ZeroAlloc.Serialisation

Source-generated, zero-allocation serialization for .NET 8+. Annotate a type — the Roslyn generator emits a sealed ISerializer<T> implementation. No reflection, no boxing, Native AOT safe.

0 B intermediate allocation, AOT safe

ZeroAlloc.Scheduling

Source-generated background job scheduler for .NET. [Job] annotation wires up executor, DI registration, and recurring startup at compile time — no convention scanning at runtime. InMemory, EF Core, and Redis backends.

[Job] attribute, no runtime scanning

ZeroAlloc.Cache

Source-generated zero-allocation caching proxy for .NET. Annotate an interface with [Cache] — Roslyn emits a transparent proxy with zero allocation on the cache-hit path. IMemoryCache and HybridCache backends.

0 B on cache-hit path, generator-emitted proxy

ZeroAlloc.Resilience

Source-generated, zero-allocation resilience policies for .NET. [Retry], [Timeout], [RateLimit], and [CircuitBreaker] compose into a generated proxy with zero heap allocation on the happy path. AOT-safe.

0 B happy-path retry / timeout / circuit-breaker

ZeroAlloc.StateMachine

Source-generated, zero-allocation finite state machines for .NET. [StateMachine] and [Transition<TState, TTrigger>] attributes lower to a switch expression over tuples. No dictionary, no delegate dispatch, AOT-safe.

switch-expression dispatch, 0 B per transition

ZeroAlloc.Outbox

Source-generated transactional outbox for .NET. [OutboxMessage] emits a typed writer and dispatcher bridge — no reflection, no boxing, AOT-safe. EF Core (production) and InMemory (tests) stores, polling worker, exponential-backoff retry, dead-letter.

Typed writers + dispatcher bridge, AOT-safe

ZeroAlloc.Saga

Source-generated long-running process orchestration. Declare a saga as a partial class — the generator emits the state machine, notification handlers, and dispatch wiring. Compensation runs in reverse on failure. Native AOT compatible.

Source-generated saga FSM, compensation in reverse

ZeroAlloc.Authorization

Authorization primitives for .NET — IAuthorizationPolicy contract, [Authorize] / [AuthorizationPolicy] attributes, ISecurityContext for hosts to extend. Source-of-truth contract package consumed by AI.Sentinel and ZeroAlloc.Mediator.Authorization.

Contract-only, AOT-safe, hosts dispatch