fl-configuration-extensions 0.3.1

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

Fl.Configuration.Extensions

A .NET library that provides functional programming extensions for Microsoft's Configuration system, offering type-safe configuration binding with functional programming patterns.

Features

  • Type-Safe Configuration Binding: Automatically maps configuration sections to strongly-typed objects
  • Functional Programming Support: Integration with LanguageExt Option monad for null-safe operations
  • Convention-Based: Uses type name as configuration section key
  • Dual APIs: Both strict (throws on missing) and safe (returns Option) configuration retrieval
  • Multi-Framework Support: Targets .NET 8.0, 9.0, and 10.0

Installation

dotnet add package Fl.Configuration.Extensions

Usage

Configuration Class Setup

public record DatabaseConfig 
{
    public string ConnectionString { get; init; }
    public int Timeout { get; init; }
}

Configuration File (appsettings.json)

{
    "DatabaseConfig": {
        "ConnectionString": "Server=localhost;Database=MyDb;",
        "Timeout": 30
    }
}

Required Configuration (Strict)

Use GetRequiredConfiguration<T>() when the configuration section must be present:

var dbConfig = configuration.GetRequiredConfiguration<DatabaseConfig>();
// Throws KeyNotFoundException if "DatabaseConfig" section is missing
Console.WriteLine($"Connection: {dbConfig.ConnectionString}");

Optional Configuration (Safe)

Use GetConfiguration<T>() for optional configuration sections:

var optionalConfig = configuration.GetConfiguration<DatabaseConfig>();

// Functional pattern matching:
optionalConfig.Match(
    /* Some: */ config => {
        Console.WriteLine($"Connection: {config.ConnectionString}");
        // Use the configuration
    },
    /* None: */ () => {
        Console.WriteLine("Configuration not found, using defaults");
        // Handle missing configuration gracefully
    }
);

// Or check if present:
if (optionalConfig.IsSome)
{
    var config = optionalConfig.ValueUnsafe();
    // Use config...
}

API Reference

Extension Methods

GetRequiredConfiguration<T>()
public static T GetRequiredConfiguration<T>(this IConfiguration configuration) where T : class, new()
  • Returns: Instance of type T populated from configuration
  • Throws: KeyNotFoundException if the configuration section is missing
  • Section Key: Uses typeof(T).Name as the configuration section key
GetConfiguration<T>()
public static Option<T> GetConfiguration<T>(this IConfiguration configuration) where T : class, new()
  • Returns: Option<T> - Some<T> if found, None if missing
  • Section Key: Uses typeof(T).Name as the configuration section key
  • Safe: Never throws exceptions, use functional pattern matching

Dependencies

  • Microsoft.Extensions.Configuration (≥10.0.3)
  • Microsoft.Extensions.Configuration.Abstractions (≥10.0.3)
  • Microsoft.Extensions.Configuration.Binder (≥10.0.3)
  • Fl.Functional.Utils (≥0.1.0)
  • LanguageExt: Functional programming library for Option monad

Target Frameworks

  • .NET 8.0
  • .NET 9.0
  • .NET 10.0

Ideal Use Cases

  1. Microservices Architecture: Clean, type-safe configuration binding
  2. Functional Programming: Integration with functional codebases using LanguageExt
  3. Configuration Validation: Early detection of missing required configuration
  4. Optional Feature Configuration: Safe handling of optional configuration sections
  5. Strongly-Typed Configuration: Automatic mapping without manual binding code

Benefits

  • Type Safety: Compile-time guarantees for configuration structure
  • Functional Programming: Option monad prevents null reference exceptions
  • Convention-Based: No magic strings, uses type names as section keys
  • Clean API: Simple, expressive methods for common configuration patterns
  • Multi-Framework: Supports latest .NET versions
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 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 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on fl-configuration-extensions:

Package Downloads
fl-shared-utils-components

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.1 280 4/27/2026
0.3.0 464 3/1/2026
0.2.0 140 2/28/2026
0.1.0 112 2/27/2026