Pragmatic.Configuration
Zero-boilerplate configuration binding, validation, and DI registration via source generator — plus runtime stores with cascade resolution, multi-tenancy, hot-reload, and pluggable backends.
The Problem
Section titled “The Problem”Every IOptions<T> class needs the same binding/validation/registration boilerplate. Across 20 options
classes that’s hundreds of lines of ceremony, and validation is opt-in: forget one
.ValidateDataAnnotations() and [Required] is silently ignored until it fails at runtime.
// 4 lines of ceremony per options class, repeated for every config typeservices.AddOptions<BookingOptions>() .Bind(configuration.GetSection("Booking")) .ValidateDataAnnotations() .ValidateOnStart();Beyond that: secrets vary by environment, dynamic reconfiguration needs a deploy, and per-tenant overrides become hardcoded switch statements.
The Solution — two pillars
Section titled “The Solution — two pillars”Compile-time binding: annotate a class with [Configuration]; the generator produces the binding,
DataAnnotation validation, and DI registration. One line registers everything.
[Configuration]public partial class BookingOptions{ [Required] public string CurrencyCode { get; init; } = ""; [Range(1, 365)] public int MaxStayDays { get; init; }}Runtime stores: a unified API over configuration with cascade resolution (global → tenant → user), hot-reload, and pluggable backends (Database, Azure) — without redeploying.
Installation
Section titled “Installation”dotnet add package Pragmatic.Configurationdotnet add package Pragmatic.SourceGenerator # generates the [Configuration] bindingStatus
Section titled “Status”[Configuration] binding/validation and the runtime stores (cascade, hot-reload, Database/Azure
backends) are functional within the 0.8 preview. See the roadmap.
| Concepts | The two pillars, cascade resolution, hot-reload, choosing a backend |
| Getting Started | Your first [Configuration] class and a runtime store |
| Stores | Backends (Database, Azure), cascade, tenant overrides, hot-reload |
| Common Mistakes | The most frequent configuration pitfalls |
| Troubleshooting | Problem/solution guide with diagnostics |
Requirements
Section titled “Requirements”- .NET 10.0+
Pragmatic.SourceGeneratoranalyzer
License
Section titled “License”Part of the Pragmatic.Design ecosystem — see Licensing. Pragmatic.Configuration is MIT-licensed.