Skip to content

xavierjohn/Trellis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

527 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trellis

Build codecov NuGet NuGet Downloads License: MIT .NET C# GitHub Stars Documentation

Trellis — Structured building blocks for AI-driven enterprise software

Structured building blocks for AI-driven enterprise software.

Trellis helps AI create consistent, reliable .NET services by turning typed errors, validated value objects, and composable application pipelines into compiler-enforced guardrails.

Before / After

Without Trellis

if (string.IsNullOrWhiteSpace(request.Email))
    return Results.BadRequest(new { code = "validation.error", detail = "Email is required." });

if (!request.Email.Contains('@'))
    return Results.BadRequest(new { code = "validation.error", detail = "Email is invalid." });

return Results.Ok(new User(request.Email.Trim().ToLowerInvariant()));

With Trellis

using Trellis.Asp;
using Trellis.Primitives;

return EmailAddress.TryCreate(request.Email)
    .Map(email => new User(email))
    .ToHttpResponse();

What You Get

  • Result<T> and Maybe<T> pipelines that make failures explicit.
  • Strongly typed value objects that remove primitive obsession.
  • DDD building blocks: Aggregate, Entity, ValueObject, Specification, and domain events.
  • ASP.NET Core, EF Core, Mediator, HttpClient, FluentValidation, and Stateless integrations.
  • Roslyn analyzers and test helpers that keep teams on the happy path.
  • AOT-friendly, allocation-conscious APIs built for modern .NET. (Per-package APIs are AOT- and trim-safe; the optional Trellis.ServiceDefaults composition builder exposes both AOT-safe per-type overloads — e.g. UseFluentValidation<TValidator, TMessage>() — and assembly-scanning overloads annotated with [RequiresUnreferencedCode] / [RequiresDynamicCode] so the AOT analyzer surfaces the choice at the consumer's call site. Trellis.EntityFrameworkCore follows EF Core's own AOT policy and is intentionally excluded from the AOT publish gate.)

Quick Start

dotnet add package Trellis.Core
using Trellis;

var result = Result.Ok("ada@example.com")
    .Ensure(email => email.Contains('@'),
        Error.InvalidInput.ForField("email", "validation.error", "Email is invalid."))
    .Map(email => email.Trim().ToLowerInvariant());

Packages

Core

Package What it gives you
Trellis.Core Result<T>, Maybe<T>, typed errors, and pipeline operators
Trellis.Primitives Ready-to-use concrete value objects plus JSON/tracing infrastructure
Trellis.Analyzers Compile-time guidance for Result, Maybe, and EF Core usage

Integration

Package What it gives you
Trellis.Asp Result-to-HTTP mapping, scalar validation, JSON/model binding (bundles the AOT-friendly JSON converter generator), and ASP.NET actor providers (Claims, Entra, Development)
Trellis.Authorization Actor, permission checks, and resource authorization primitives
Trellis.Http HttpClient extensions that stay inside the Result pipeline
Trellis.Http.Abstractions HTTP-aware boundary primitives (HttpError.* cases, EntityTagValue, PreconditionKind, RetryAfterValue, AuthChallenge) shared by Trellis.Asp and Trellis.Http
Trellis.Mediator Result-aware pipeline behaviors for Mediator
Trellis.FluentValidation FluentValidation output converted into Trellis results
Trellis.EntityFrameworkCore EF Core conventions, converters, Maybe queries, and safe save helpers (bundles the Maybe<T> / owned value-object source generator)
Trellis.ServiceDefaults Opinionated composition builder for wiring Trellis web-service modules in the canonical order
Trellis.StateMachine Stateless transitions that return Result<TState>
Trellis.Testing FluentAssertions extensions for Result<T> and Maybe<T>

Performance

Typical overhead is measured in single-digit to low double-digit nanoseconds—tiny next to a database call or HTTP request. Benchmarks

Documentation

Contributing

Contributions are welcome. For major changes, please open an issue first and run dotnet test before sending a PR.

License

MIT

About

Functional programming with Domain Driven Design.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages