Cocoar.Configuration.AspNetCore 1.0.0

dotnet add package Cocoar.Configuration.AspNetCore --version 1.0.0
                    
NuGet\Install-Package Cocoar.Configuration.AspNetCore -Version 1.0.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="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cocoar.Configuration.AspNetCore" Version="1.0.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 1.0.0
                    
#r "nuget: Cocoar.Configuration.AspNetCore, 1.0.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@1.0.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=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cocoar.Configuration.AspNetCore&version=1.0.0
                    
Install as a Cake Tool

Cocoar.Configuration

Powerful layered configuration for .NET
Simple • Strongly typed • Reactive
Elevates configuration from hidden infrastructure to an observable, safety‑enforced subsystem you can trust under change and failure.

Cocoar.Configuration

Build (develop) PR Validation License: Apache-2.0 NuGet Downloads


🌟 Features

🚀 Key Innovations

  • Auto-Registered Reactive Config – Every config type gets IReactiveConfig<T> in DI automatically
  • Health Monitoring Service – Real-time health snapshots, metrics export, and resilience tracking
  • Streaming MD5 Change Detection – High-performance hashing pipeline for file/HTTP providers

Core Principles

  • Deterministic Layering – Explicit ordered rules, last-write-wins, no hidden merge logic.
  • Strongly Typed – Direct POCO injection, no IOptions<T> or attributes.
  • Atomic Snapshots – Always consistent view; no half-applied updates.
  • Reactive & Dynamic Reload – Config updates automatically propagate.

Rule System

  • Unified Fluent API – Same syntax across all providers.
  • Composable RulesFetch → Select → Mount → Merge pipeline.
  • Dynamic Rule Factories – Generate rules based on earlier snapshots.
  • Advanced Binding – Classes, interfaces, or factory functions.
  • Partial Recomputation – Only the earliest changed rule restarts, minimizing churn.
  • Required / Optional rules – control startup failure vs runtime degradation (.Required(true/false)).
  • Conditional execution – enable rules only when needed (.When(() => condition)).

Providers

  • Static / Observable – Core built-ins.
  • File – resilient: falls back to polling when watching fails, then auto-recovers.
  • Environment – flexible mapping: __ and : delimiters build JSON hierarchy.
  • HTTP – custom headers, caching, and change-only emissions.
  • Microsoft Adapter Provider (extension) – Bridge existing IConfiguration.

Health Monitoring & Reliability

  • Integrated Health ServiceIConfigurationHealthService for all providers.
  • Health Snapshots – Capture and stream provider health in real time.
  • Metrics Export Hooks (experimental) – Integrate with Prometheus / OpenTelemetry.
  • Cancellation-Aware Reporting – Accurate health checks under shutdown/load.
  • Error-Resilient Observables – Streams stay alive even if subscribers throw exceptions.
  • Two-Phase Error Handling – Fail-fast on init, graceful degradation at runtime.
  • Fail-Safe Defaults – Config remains valid even on failures.
  • Change Propagation System – Coalesced updates, consistent application.

Developer Experience

  • Minimal Boilerplate – Define a class, add a rule, done.
  • Auto-Registered Reactive ConfigIReactiveConfig<T> registered automatically in DI.
  • Interface binding – map POCOs to read-only interfaces (Bind.Type<T>().To<IMyConfig>()) for clean contracts.
  • Service Lifetime Control – Scoped, Singleton, Transient, and Keyed registrations supported.
  • Test-Friendly – Static/observable providers make testing easy.
  • ASP.NET Core Integration – Drop-in extensions for DI.
  • Migration Path – Adapter for Microsoft.Extensions.Configuration.

Install

dotnet add package Cocoar.Configuration
# For ASP.NET Core integration:
dotnet add package Cocoar.Configuration.AspNetCore

Quickstart

var builder = WebApplication.CreateBuilder(args);

// Register layered configuration (file + environment overlay)
builder.Services.AddCocoarConfiguration([
    Rule.From.File("appsettings.json").Select("App").For<AppSettings>(),
    Rule.From.Environment("APP_").For<AppSettings>()
]);

var app = builder.Build();

// Simple endpoint: inject concrete snapshot (Scoped)
app.MapGet("/feature", (AppSettings cfg) => new {
    snapshotFlag = cfg.FeatureFlag,  // Value at scope start (request)
    message = cfg.Message
});

Examples

Each example is a standalone runnable project under src/Examples/:

Project Description
BasicUsage Common ASP.NET Core pattern (file + env overlay)
FileLayering Multiple JSON layering (base + env + local)
DynamicDependencies Later rules derive values from earlier configs
AspNetCoreExample Minimal API exposing config via endpoints
GenericProviderAPI Generic provider registration API usage
HttpPollingExample Remote HTTP polling configuration pattern
MicrosoftAdapterExample Integrating existing IConfigurationSource assets
ServiceLifetimes DI lifetime & keyed registration control
StaticProviderExample Static seeding with JSON strings and factory functions
DIExample Comprehensive DI patterns & overrides
SimplifiedCoreExample Pure core (no DI) with ConfigManager
BindingExample Interface binding without DI

More details: Examples README.


Quality & Reliability

Cocoar.Configuration is backed by an extensive test suite:

  • 204 automated tests across core, providers, and edge cases (v1.0.0).
  • Continuous integration (GitHub Actions) validates every PR and commit.
  • High coverage of provider behavior, failure handling, and the recompute pipeline.

<details> <summary><strong>What’s covered beyond unit tests</strong></summary>

  • Integration: multi‑provider composition, rule ordering, recompute pipeline, snapshot stability.
  • Concurrency & Cancellation: debounce/coalescing under rapid change storms; overlapping recomputes; cancellation correctness.
  • Stress & Performance: large/megabyte JSONs; high‑frequency writes; multi‑provider concurrency; emission minimality (fewer emissions than changes).
  • File Provider Resilience: FileSystemWatcher ⇄ polling fallback; directory deletion/recreation recovery.
  • HTTP Provider “battle tests”: headers, caching, non‑200 handling, base address vs absolute URIs.
  • Environment & Microsoft Adapter: delimiter/underscore edge cases; in‑memory config integration.
  • Fuzz/Differential tests: random change sequences maintain correctness and stable merges.
  • Health pipeline: status derivation, recovery, version preservation on failure, observable health updates.

</details>

See the Testing Guide for patterns and trait filters.


Security Notes

  • Do not commit secrets to repo JSON
  • Overlay secrets via env/provider layers
  • Use TLS + auth for remote polling
  • Consider vault integration via Microsoft adapter

Contributing & Versioning

  • SemVer (additive MINOR, breaking MAJOR)
  • PRs & issues welcome
  • Licensed under Apache License 2.0 (explicit patent grant & attribution via NOTICE)

License & Trademark

This project is licensed under the Apache License, Version 2.0. See NOTICE for attribution.

"Cocoar" and related marks are trademarks of COCOAR e.U. Use of the name in forks or derivatives should preserve attribution and avoid implying official endorsement. See TRADEMARKS for permitted and restricted uses.


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 24 9/21/2025
0.15.0 235 9/18/2025
0.14.0 250 9/17/2025
0.13.0 248 9/17/2025
0.12.0 255 9/17/2025
0.11.1 255 9/16/2025
0.11.0 257 9/16/2025
0.10.0 260 9/16/2025
0.9.2 208 9/15/2025
0.9.1 182 9/14/2025
0.9.0 102 9/14/2025
0.4.0 106 9/13/2025