Trellis.ServiceDefaults 3.0.0-alpha.372

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

Trellis.ServiceDefaults

NuGet Package

Opinionated composition defaults for Trellis web services.

Installation

dotnet add package Trellis.ServiceDefaults

Quick Example

using Trellis.ServiceDefaults;

builder.Services.AddTrellis(options => options
    .UseAsp()
    .UseScalarValueValidation()
    .UseProblemDetails()
    .UseMediator()
    .UseFluentValidation(typeof(Program).Assembly)
    .UseClaimsActorProvider()
    .UseResourceAuthorization(typeof(Program).Assembly)
    .UseEntityFrameworkUnitOfWork<AppDbContext>());

UseEntityFrameworkUnitOfWork<TContext>() is always applied last so the transactional command behavior runs innermost. AddDbContext<TContext>(...) and AddMediator(...) remain application-owned registrations.

UseFluentValidation() and UseResourceAuthorization() both support no-assembly calls for explicit, no-scanning composition; pass assemblies only when you want Trellis to discover validators/resource loaders automatically.

UseScalarValueValidation() is independent of UseAsp() — it registers the scalar-value model binders, JSON converters, and SuppressModelStateInvalidFilter toggle that mutate global MvcOptions / JsonOptions for both MVC and Minimal API JSON pipelines. Hosts that only need error-to-status mapping (e.g. an MVC site that does not bind value-object DTOs) can call UseAsp() alone and skip the binder / converter wiring. Minimal API hosts must still call app.UseScalarValueValidation() middleware and chain .WithScalarValueValidation() per endpoint.

UseProblemDetails() is independent of UseAsp() — it registers Trellis ProblemDetails customization (traceId on every error, 405 Allow header projected as extensions.allow, 500 detail rewrite) without pulling in Trellis MVC/result-mapping infrastructure. Composing it with a direct services.AddTrellisProblemDetails() call is idempotent — exactly one Trellis post-configure layer ends up registered.

UseIdempotency(opt => ...) wires the opt-in IETF Idempotency-Key middleware (options + scope resolver + marker). Composition is explicit — the slot does not register a store, so callers add services.AddInMemoryIdempotencyStore() (dev / tests) or an EF-backed store (production) and mount the middleware with app.UseTrellisIdempotency(). Endpoints opt in with [Idempotent].

UseWorkerActor(systemActor) composes the previously selected actor provider with a worker/system fallback for background scopes that have no HttpContext. It applies after the actor-provider selection and caching wrap, so HTTP requests still resolve through the inner provider (and its cache) and BackgroundService ticks short-circuit to the supplied system actor.

AOT compatibility

Trellis.ServiceDefaults is AOT- and trim-compatible. The package enables the AOT and trim analyzers (IsAotCompatible, IsTrimmable, EnableAotAnalyzer, EnableTrimAnalyzer) and keeps the default composition slots safe when you choose explicit overloads.

AOT-safe builder shapes are UseFluentValidation() plus UseFluentValidation<TValidator, TMessage>() per validator, UseResourceAuthorization() plus UseResourceAuthorization<TMessage, TResource, TResponse>() per command, and UseDomainEvents() or UseTrackedAggregateDomainEvents() plus their <TEvent, THandler>() per-handler overloads.

The assembly-scanning overloads (UseFluentValidation(asm), UseResourceAuthorization(asm), UseDomainEvents(asm), UseTrackedAggregateDomainEvents(asm)) remain convenience APIs for non-AOT consumers. They are annotated with [RequiresUnreferencedCode] and [RequiresDynamicCode], so trimmed/AOT applications must either switch to explicit registrations or make that choice visible at the consumer call site, for example by annotating the composition method or suppressing the analyzer warning.

UseEntityFrameworkUnitOfWork<TContext>() is also annotated [RequiresUnreferencedCode] / [RequiresDynamicCode] because the EF Core integration depends on runtime reflection and is excluded from the Trellis AOT publish gate. AOT consumers can still use the ASP, Mediator, FluentValidation, and authorization slots through this builder, but should compose data access separately.

Part of Trellis

This package is part of the Trellis framework.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-alpha.385 0 6/15/2026
3.0.0-alpha.382 37 6/12/2026
3.0.0-alpha.372 48 6/10/2026
3.0.0-alpha.360 77 6/7/2026
3.0.0-alpha.342 67 6/5/2026
3.0.0-alpha.337 48 6/3/2026
3.0.0-alpha.336 48 6/3/2026
3.0.0-alpha.304 57 5/29/2026