Cocoar.Configuration.AspNetCore 0.10.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cocoar.Configuration.AspNetCore --version 0.10.0
                    
NuGet\Install-Package Cocoar.Configuration.AspNetCore -Version 0.10.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.AspNetCore" Version="0.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cocoar.Configuration.AspNetCore" Version="0.10.0" />
                    
Directory.Packages.props
<PackageReference Include="Cocoar.Configuration.AspNetCore" />
                    
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.AspNetCore --version 0.10.0
                    
#r "nuget: Cocoar.Configuration.AspNetCore, 0.10.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.AspNetCore@0.10.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.AspNetCore&version=0.10.0
                    
Install as a Cake Addin
#tool nuget:?package=Cocoar.Configuration.AspNetCore&version=0.10.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(
        // File + env layering (rule-level selection via .Select)
        Rule.From.File("appsettings.json").Select("App").For<AppSettings>().Optional(),
        Rule.From.Environment("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: Incremental – only recompute from earliest changed rule; atomic snapshot publish.
  • Dynamic dependencies: Rule factories (options/query) can read earlier in-progress rule outputs during a pass.
  • Required vs Optional: Optional 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 (atomic snapshot swap)
  • Incremental recompute: only from earliest changed rule onward (prefix reused)
  • Selection-hash gating: unchanged selected subtree events skipped
  • Providers reused across recomputes when instance options stable
  • Static rule set: rules immutable after initialization (use UseWhen to toggle)

Quality & Reliability

This project invests heavily in correctness-first incremental recompute. Optimisations (prefix reuse, cancellation, selection‑hash gating, debounce) are all guarded by strong differential and stress tests so performance never compromises determinism.

Core test suites (see src/tests/):

Suite Focus Guarantee
DifferentialCorrectnessFuzzTests Random multi-provider mutation waves Final published snapshot bit-for-bit equals a naive full merge
PartialRecomputeTests Prefix reuse / earliest-index accuracy Unchanged prefix providers are never refetched
OverlappingRecomputeCorrectnessTests Cancellation under descending storms No lost updates; latest versions survive heavy overlap
CancellationTests Mid-pass abort & restart Earlier changes preempt wasted later work
SnapshotChangeDeletionTests Deletion propagation Removed keys do not resurrect spuriously
RecomputeStressTests Burst & jitter durability Bounded passes; stable end-state
Provider suites (Providers/*Tests) Integration of file/env/http/adapter Source-specific semantics remain correct

Why call this out? Incremental configuration layering is deceptively complex once you introduce cancellation and reuse. Many libraries silently drop updates or leak stale keys; these suites explicitly prevent that class of regression.


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

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
1.0.0 55 9/21/2025
0.15.0 257 9/18/2025
0.14.0 264 9/17/2025
0.13.0 264 9/17/2025
0.12.0 269 9/17/2025
0.11.1 269 9/16/2025
0.11.0 271 9/16/2025
0.10.0 274 9/16/2025
0.9.2 217 9/15/2025
0.9.1 191 9/14/2025
0.9.0 111 9/14/2025
0.4.0 115 9/13/2025

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