Source-generated
A Roslyn incremental generator finds every handler at build time and emits the
dispatcher and AddVitreousHandlers(). No assembly scanning at startup.
dotnet add package Vitreousdotnet add package Vitreous.SourceGenerationSource-generated
A Roslyn incremental generator finds every handler at build time and emits the
dispatcher and AddVitreousHandlers(). No assembly scanning at startup.
Zero reflection, zero allocations
Dispatch is one lookup on the message’s concrete type. A plain send with no behaviors allocates 0 B.
Result type
Handlers return Result<T> or an Error (NotFound, Validation, Conflict, …)
instead of throwing for expected failures.
Caching
Mark a query ICacheableQuery<T> and it is cached in any IDistributedCache, or in
Redis with tag-based invalidation.
Developer UI
An embedded dashboard with live traces, handler logs, inputs, outputs and cache hits for every dispatch.
OpenTelemetry
Spans and metrics through System.Diagnostics, with nothing to install and no cost
until a listener subscribes.
Native AOT
The core and caching packages are trim- and AOT-compatible, including open-generic behaviors over value types.
.NET 8, 9, 10 and 11
One multi-targeted package per library, with every supported runtime in it.
Define a message and its handler anywhere in your project:
using Vitreous;using Vitreous.Abstractions;
public sealed record CreateOrderCommand(string Customer) : ICommand<Guid>;
public sealed class CreateOrderHandler : ICommandHandler<CreateOrderCommand, Guid>{ public ValueTask<Result<Guid>> Handle(CreateOrderCommand command, CancellationToken ct = default) { if (string.IsNullOrWhiteSpace(command.Customer)) return new(Error.Validation("Customer is required."));
return new(Guid.NewGuid()); // T converts to Result<T> implicitly }}Register and dispatch:
var builder = WebApplication.CreateBuilder(args);builder.Services.AddVitreousHandlers(); // generated at build time — finds every handler
var app = builder.Build();
app.MapPost("/orders", async (CreateOrderCommand cmd, ISender sender, CancellationToken ct) =>{ var result = await sender.Send(cmd, ct); return result.Match( id => Results.Created($"/orders/{id}", new { id }), err => Results.BadRequest(new { err.Code, err.Message }));});
app.Run();Vitreous is MIT-licensed. Source, issues and releases are on GitHub.