Pragmatic.Composition.Host
1.0.0-alpha.6
dotnet add package Pragmatic.Composition.Host --version 1.0.0-alpha.6
NuGet\Install-Package Pragmatic.Composition.Host -Version 1.0.0-alpha.6
<PackageReference Include="Pragmatic.Composition.Host" Version="1.0.0-alpha.6" />
<PackageVersion Include="Pragmatic.Composition.Host" Version="1.0.0-alpha.6" />
<PackageReference Include="Pragmatic.Composition.Host" />
paket add Pragmatic.Composition.Host --version 1.0.0-alpha.6
#r "nuget: Pragmatic.Composition.Host, 1.0.0-alpha.6"
#:package Pragmatic.Composition.Host@1.0.0-alpha.6
#addin nuget:?package=Pragmatic.Composition.Host&version=1.0.0-alpha.6&prerelease
#tool nuget:?package=Pragmatic.Composition.Host&version=1.0.0-alpha.6&prerelease
Pragmatic.Composition
Source-generated application composition and dependency injection for .NET 10. Declare modules, services, and startup steps; the generator writes all the wiring, so the composed application starts without reflection and without scanning assemblies.
Convention-based scanning lives in a separate package, Pragmatic.Composition.Scanning, for the cases
the generator cannot see. It loads assemblies and enumerates types at run time and is neither trim- nor
AOT-safe; referencing it is the opt-in, and nothing in the generated path calls it.
The Problem
Every .NET app accumulates the same startup ceremony: register services one by one, order middleware,
wire DbContexts, keep it consistent across modules. With 50+ services, Program.cs becomes a wall of
services.AddScoped<>() that no one wants to maintain, and forgetting one line silently breaks the app.
// Without Pragmatic: 80+ lines of mechanical wiring
builder.Services.AddScoped<IOrderService, OrderService>();
builder.Services.AddScoped<IProductService, ProductService>();
// ... 50 more, growing with every new class
builder.Services.AddDbContext<AppDbContext>(o => o.UseSqlServer(cs));
app.UseAuthentication(); app.UseAuthorization(); // forget one and it breaks
The Solution
Declare what your application is; the generator handles how it starts up.
// Program.cs: one call wires everything
await PragmaticApp.RunAsync(args, app =>
{
app.UsePragmaticMigrations();
if (app.Environment.IsDevelopment()) app.UseDevelopmentIdentity(); // X-User-* headers are the caller
});
// Module topology: one class per bounded context
[Module]
[Include<OrdersModule, AppDatabase>]
[Include<BillingModule, FinancialDatabase>]
public sealed class MyAppModule;
// Services register themselves
[Service]
public class OrderService(IOrderRepository repository) : IOrderService { }
The generator emits the complete host startup (infrastructure auto-registration, ordered startup
steps, database init, endpoint mapping, telemetry, maintenance mode) at compile time. Cross-assembly
discovery works through [PragmaticMetadata] assembly attributes: libraries declare what they
register, the host aggregates automatically.
Packages
| Package | Role |
|---|---|
Pragmatic.Composition |
Meta-package (references Abstractions + Host) |
Pragmatic.Composition.Host |
ASP.NET Core runtime: PragmaticApp, IStartupStep, telemetry, remote boundaries, maintenance mode |
Pragmatic.Composition.Scanning |
Opt-in convention scanning at run time, not trim- or AOT-safe (see above) |
Attributes ([Service], [Module], [StartupStep], …) live in Pragmatic.Abstractions, so domain
modules use them without referencing ASP.NET Core.
The 3-tier configuration model
| Tier | Where | What it decides |
|---|---|---|
| Topology (compile-time) | [Module], [Boundary], [BelongsTo<T>], [UsePackage<T>] |
Structure & module dependencies; the generator detects it |
| Module strategy | Program.cs via IPragmaticBuilder.Use*() |
Infrastructure choices: auth handler, storage, transport |
| Business wiring | IStartupStep |
Services, filters, OpenAPI, feature-specific DI + HTTP pipeline |
What a module declares is wired without a line in Program.cs, with in-memory or passthrough defaults
where a backend is optional; you override only what you need. Two things are never defaulted, because
guessing them would be unsafe: who calls the API (every endpoint requires an authenticated caller,
the build stops on PRAG1695 without an identity package or [AnonymousHost], and outside Development a
host with no authentication method refuses to start) and a culture, from UseI18N or the modules'
translations. See Startup Pipeline.
Installation
dotnet add package Pragmatic.Composition.Host
dotnet add package Pragmatic.SourceGenerator # the unified analyzer
(Building inside this monorepo? See Monorepo Structure.)
What the generator gives you
[Service]/[Decorator]: self-registering services and ordered decorators, noAddScopedlists.[Module]/[Include<…>]: module topology and per-module databases.[StartupStep]/IStartupStep: ordered business wiring + HTTP pipeline configuration.IPragmaticBuilder.Use*(): module strategy (auth, storage, messaging, …).- Remote boundaries:
[RemoteBoundary<T>]generates typed HTTP invokers for cross-service calls. - Maintenance mode, telemetry, and database initialization, wired automatically.
Status
Functional within 1.0.0-alpha: the composition model, service/decorator registration, startup steps, the builder, remote boundaries, and maintenance mode. See the roadmap.
Documentation
| Guide | What you'll learn |
|---|---|
| Concepts | Composition model, metadata aggregation, the 3-tier configuration model |
| Getting Started | Your first module, service, and PragmaticApp.RunAsync |
| Service Registration | [Service], lifetimes, [Decorator], keyed services |
| Startup Pipeline | IStartupStep, IPragmaticBuilder, ordering, HTTP pipeline |
| Remote Boundaries | [RemoteBoundary<T>], typed HTTP invokers, the invoke endpoint |
| Common Mistakes | The most frequent composition pitfalls |
| Troubleshooting | Problem/solution guide with diagnostics |
Requirements
- .NET 10.0+
- ASP.NET Core 10.0+
Pragmatic.SourceGeneratoranalyzer
License
Part of the Pragmatic.Design ecosystem. See Licensing. Pragmatic.Composition is licensed under the PolyForm Small Business 1.0.0 license (free for small businesses; commercial license above the threshold).
| Product | Versions 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. net11.0 is compatible. |
-
net10.0
- OpenTelemetry.Exporter.Console (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- Pragmatic.Abstractions (>= 1.0.0-alpha.6)
- Pragmatic.Actions (>= 1.0.0-alpha.6)
- Pragmatic.Redaction (>= 1.0.0-alpha.6)
-
net11.0
- OpenTelemetry.Exporter.Console (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- Pragmatic.Abstractions (>= 1.0.0-alpha.6)
- Pragmatic.Actions (>= 1.0.0-alpha.6)
- Pragmatic.Redaction (>= 1.0.0-alpha.6)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Pragmatic.Composition.Host:
| Package | Downloads |
|---|---|
|
Pragmatic.Composition
Meta-package for backward compatibility. References Pragmatic.Abstractions (interfaces/attributes) and Pragmatic.Composition.Host (ASP.NET Core hosting runtime). |
|
|
Pragmatic.Endpoints.Mcp
MCP (Model Context Protocol) exposure for Pragmatic.Design endpoints: [McpTool] endpoints become MCP tools with input schemas derived from the compile-time manifest, with zero reflection. Self-HTTP execution reuses the full endpoint pipeline (authz, validation, tenancy). |
|
|
Pragmatic.Messaging.Dashboard
Operational dashboard for Pragmatic.Messaging: ops API (status, outbox, dead-letters with replay, sagas, audit) plus an embedded HTML panel. API-key or localhost-only protected, excluded from OpenAPI. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.6 | 194 | 11/21/2026 |
| 1.0.0-alpha.5 | 125 | 11/21/2026 |
| 1.0.0-alpha.4 | 181 | 11/16/2026 |
| 1.0.0-alpha.3 | 567 | 10/17/2026 |
| 1.0.0-alpha.2 | 179 | 10/12/2026 |
| 1.0.0-alpha.1 | 395 | 10/3/2026 |