Eigenverft.NetLib.Configuration.Binding 1.0.0.8-gdfdd996480

This is a prerelease version of Eigenverft.NetLib.Configuration.Binding.
dotnet add package Eigenverft.NetLib.Configuration.Binding --version 1.0.0.8-gdfdd996480
                    
NuGet\Install-Package Eigenverft.NetLib.Configuration.Binding -Version 1.0.0.8-gdfdd996480
                    
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="Eigenverft.NetLib.Configuration.Binding" Version="1.0.0.8-gdfdd996480" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eigenverft.NetLib.Configuration.Binding" Version="1.0.0.8-gdfdd996480" />
                    
Directory.Packages.props
<PackageReference Include="Eigenverft.NetLib.Configuration.Binding" />
                    
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 Eigenverft.NetLib.Configuration.Binding --version 1.0.0.8-gdfdd996480
                    
#r "nuget: Eigenverft.NetLib.Configuration.Binding, 1.0.0.8-gdfdd996480"
                    
#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 Eigenverft.NetLib.Configuration.Binding@1.0.0.8-gdfdd996480
                    
#: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=Eigenverft.NetLib.Configuration.Binding&version=1.0.0.8-gdfdd996480&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Eigenverft.NetLib.Configuration.Binding&version=1.0.0.8-gdfdd996480&prerelease
                    
Install as a Cake Tool

Eigenverft.NetLib.Configuration.Binding

NuGet Version NuGet Downloads Repository CI Targets License

Make configured lists and dictionaries replace initialized code defaults during standard .NET configuration binding. Choose explicitly what an empty configured collection means.

✨ At a glance

Package Eigenverft.NetLib.Configuration.Binding
Main API BindReplacingCollectionDefaults(...)
Collections Mutable lists and dictionaries
Empty values Keep defaults or replace with empty
Target frameworks .NET 8 and .NET 10
License MIT

📦 Installation

dotnet add package Eigenverft.NetLib.Configuration.Binding

🚀 Quick start

The built-in binder appends list items and merges dictionary entries when the target already has values. This extension clears a configured mutable collection first, then lets the framework bind and convert its values:

using System.Collections.Generic;
using Eigenverft.NetLib.Configuration.Binding;
using Microsoft.Extensions.Hosting;

HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
FilterOptions options = new();
builder.Configuration.GetSection("FilterOptions")
    .BindReplacingCollectionDefaults(
        options,
        EmptyCollectionBehavior.UseCodeDefaults);

public sealed class FilterOptions
{
    public List<string> Allowed { get; set; } = new() { "default" };
    public Dictionary<string, int> Weights { get; set; } = new() { ["default"] = 1 };
}

For options registration, apply the same policy whenever the options infrastructure creates or reloads an instance:

using Microsoft.Extensions.DependencyInjection;

builder.Services
    .AddOptions<FilterOptions>()
    .BindReplacingCollectionDefaults(
        "FilterOptions",
        EmptyCollectionBehavior.UseEmptyCollection);

🧭 Behavior and limits

Configuration state Result
Collection key is missing Keep code defaults
Configured list or dictionary has entries Replace the initialized collection
Configured collection is empty with UseCodeDefaults Keep code defaults
Configured collection is empty with UseEmptyCollection Replace with an empty collection

The empty-collection policy is required on every call. The helpers cover initialized mutable IList and IDictionary properties; other property types keep native binder behavior. ConfigurationKeyNameAttribute aliases are honored. Binding, value conversion, BinderOptions, named options, and change-token behavior remain framework-owned.

These APIs use reflection and are annotated for dynamic-code and trimming requirements. Preserve the options members used for binding when publishing a trimmed application.

🎯 Target frameworks

The package targets net8.0 and net10.0.

📄 License

MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.8-gdfdd996480 0 9/29/2026
1.0.0.8-g17613f8942 0 9/29/2026
1.0.0.6-g28e841270d 0 9/28/2026
1.0.0.5-gbac57d8b97 0 9/11/2026
1.0.0.5-g9537b96514 0 9/11/2026

Initial capability package extracted from Eigenverft.NetLib.Infrastructure.