Cocoar.Configuration 0.9.0

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

Cocoar.Configuration

Cocoar.Configuration

Lightweight, strongly-typed, deterministic multi-source configuration layering for .NET (Current target framework: net9.0).

Build (develop) PR Validation License: MIT NuGet Downloads


Why Cocoar.Configuration?

Deterministic, strongly-typed, rule-driven configuration layering that complements Microsoft.Extensions.Configuration.

Design Goals at a Glance

  • Explicit ordered layering: Deterministic last-write-wins per key.
  • Typed direct injection: Inject config classes or mapped interfaces (no IOptions<T> ceremony).
  • Atomic snapshot recompute: Full ordered rebuild on change → consistent view for all consumers.
  • Dynamic rule factories: Later rules can read earlier in-progress snapshots to shape options/queries.
  • Pluggable provider model: File, environment, HTTP polling, Microsoft adapter, static & custom.
  • DI lifetimes & keys: Configure singleton (default), scoped, transient, keyed variants per type.
  • Per-type diagnostics: Inspect merged snapshots when troubleshooting.
  • Interoperability: Bring any existing IConfigurationSource via the Microsoft Adapter package.

Installation

Supported TFM: net9.0 (multi-targeting planned).

<ItemGroup>
        <PackageReference Include="Cocoar.Configuration" />
        
        <PackageReference Include="Cocoar.Configuration.AspNetCore" />
        <PackageReference Include="Cocoar.Configuration.HttpPolling" />
        <PackageReference Include="Cocoar.Configuration.MicrosoftAdapter" />
</ItemGroup>

CLI:

dotnet add package Cocoar.Configuration
dotnet add package Cocoar.Configuration.AspNetCore
dotnet add package Cocoar.Configuration.HttpPolling
dotnet add package Cocoar.Configuration.MicrosoftAdapter

Quick Start

Minimal example (file + environment layering, strongly-typed access):

// ...
builder
    .AddCocoarConfiguration(
        Rule.From.File(_ => FileSourceRuleOptions.FromFilePath("appsettings.json", "App")).For<AppSettings>().Optional(),
        Rule.From.Environment(_ => new EnvironmentVariableRuleOptions("APP_")).For<AppSettings>()
    );

Then inject your config type directly:

var settings = app.Services.GetRequiredService<AppSettings>();
Console.WriteLine($"FeatureX: {settings.EnableFeatureX}");

Concepts

  • Rule: Source + optional query + target configuration type
  • Provider: Pluggable source (file, env, HTTP, static, custom, adapter)
  • Merge: Ordered last-write-wins per flattened key
  • Recompute: Any change → full recompute → atomic snapshot swap
  • Dynamic dependencies: Rule factories (options/query) can read in-progress snapshots.
  • Required vs Optional: Pptional failure skips the layer.
  • DI Lifetimes & Keys: Register as singleton (default), scoped, transient, keyed

👉 Read more in the Concepts Deep Dive


Providers

Built-in and extension providers:

Provider Package Change Signal Notes
Static Core Seed defaults, compose values
File (JSON) Core ✅ Filesystem watcher Deterministic layering
Environment Core Prefix filter; __ & : nesting
HTTP Polling Extension Interval polling, payload diffing
Microsoft Adapter Extension Depends Any IConfigurationSource

👉 See Providers Overview for full details.


Advanced Features

  • Service Lifetimes & Keys: control DI lifetimes, keyed configs
  • Generic Provider API: Rule.From.Provider<>() for full control
  • Microsoft Adapter: wrap any IConfigurationSource
  • HTTP Polling Provider: auto-change detection

👉 Details in Advanced Features


Security

  • Never commit secrets to JSON files in your repository
  • Use environment variable overlays or dedicated secret management systems
  • For remote providers: Always use TLS, set reasonable timeouts, and include auth headers when needed
  • Consider using Azure Key Vault, AWS Secrets Manager, or similar via the Microsoft Adapter

Examples

Multi-project solution under src/Examples/ with runnable demos:


Deep Dive Documentation

For more in-depth documentation, see:


Thread Safety & Performance

  • Reading config is thread-safe
  • Recompute is O(n) per rules + JSON size
  • Providers reused across recomputes when options stable

Versioning & Stability

  • Stable releases follow SemVer; see GitHub Releases or NuGet version history for changes.
  • Breaking changes only in MAJOR versions; MINOR for additive features; PATCH for fixes.
  • Provider abstractions evolve conservatively.

Packages are published under the NuGet organization cocoar.

Contributing

Issues and PRs are welcome 🎉 Keep provider abstractions stable & deterministic. Examples and docs are validated in CI.


(This README reflects the current state – future optimizations & multi-targeting will be documented in docs/.)

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (4)

Showing the top 4 NuGet packages that depend on Cocoar.Configuration:

Package Downloads
Cocoar.Configuration.AspNetCore

Powerful layered configuration for .NET—simple, strongly typed, reactive. Compose ordered rules (file, environment, HTTP polling, static, Microsoft IConfiguration) with deterministic last-write-wins merging, partial atomic recompute, and hash-gated reactive streams.

Cocoar.Configuration.HttpPolling

Powerful layered configuration for .NET—simple, strongly typed, reactive. Compose ordered rules (file, environment, HTTP polling, static, Microsoft IConfiguration) with deterministic last-write-wins merging, partial atomic recompute, and hash-gated reactive streams.

Cocoar.Configuration.MicrosoftAdapter

Powerful layered configuration for .NET—simple, strongly typed, reactive. Compose ordered rules (file, environment, HTTP polling, static, Microsoft IConfiguration) with deterministic last-write-wins merging, partial atomic recompute, and hash-gated reactive streams.

Cocoar.Configuration.DI

Powerful layered configuration for .NET—simple, strongly typed, reactive. Compose ordered rules (file, environment, HTTP polling, static, Microsoft IConfiguration) with deterministic last-write-wins merging, partial atomic recompute, and hash-gated reactive streams.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.15.0 12 9/18/2025
0.14.0 31 9/17/2025
0.13.0 41 9/17/2025
0.12.0 46 9/17/2025
0.11.1 47 9/16/2025
0.11.0 45 9/16/2025
0.10.0 50 9/16/2025
0.9.2 57 9/15/2025
0.9.1 55 9/14/2025
0.9.0 54 9/14/2025
0.4.0 58 9/13/2025

Initial release: lightweight, strongly-typed, deterministic multi-source configuration layering with ordered last-write-wins merge and atomic recompute.