Routya.ConfigKit 1.0.0

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

⚙️ Routya.ConfigKit.Generator

🔧 A lightweight, source-generated configuration binder for .NET — just tag your class with [ConfigSection] and go.

CI CI NuGet NuGet


✨ Features

  • ✅ Compile-time generation of config binding and registration code
  • ✅ Supports both IOptions<T> and AddSingleton<T> modes
  • ✅ Full support for System.ComponentModel.Annotations
  • ✅ No reflection at runtime
  • ✅ Drop-in integration with appsettings.json
  • ✅ Currently only supports {get; set;} and {get; init;}.

🚀 Getting Started

🛠 Binding Modes | Mode | Behavior | |-------------|----------------------------------------| | Singleton | Registers the instance via AddSingleton<T> | | IOptions | Uses services.Configure<T>() | | Both | Adds both for flexibility |

1. Install package

dotnet add package Routya.ConfigKit.Generator

2. Create your config class

ConfigSection("MyService", ConfigBindingMode.IOptions)

The 'MyService' in ConfigSection is the section name within your configuration (eg. appsettings.json, Azure App Configuration)

{
  "MyService": {
    "RetryCount": 3,
    "UseCaching": false
  }
}

ConfigBindingMode.IOptions

using System.ComponentModel.DataAnnotations;
using Routya.ConfigKit;

[ConfigSection("MyService", mode: ConfigBindingMode.IOptions)]
public partial class MyServiceOptions
{
    [Required]
    public int RetryCount { get; init; }

    public bool UseCaching { get; init; } = true;
}

Generates

public static IServiceCollection AddMyServiceOptions(this IServiceCollection services, IConfiguration configuration)
{
	services.AddOptions<MyServiceOptions>()
			.Bind(configuration.GetSection("MyService"))
			.ValidateDataAnnotations()
			.ValidateOnStart();

	return services;
}

ConfigBindingMode.Singleton

using System.ComponentModel.DataAnnotations;
using Routya.ConfigKit;

[ConfigSection("MyService", ConfigBindingMode.Singleton)]
public partial class MyServiceOptions
{
    [Required]
    public int RetryCount { get; init; }

    public bool UseCaching { get; init; } = true;
}

Generates

 public static IServiceCollection AddMyServiceOptions(this IServiceCollection services, IConfiguration configuration)
 {
     var options = new MyServiceOptions()
     {
         RetryCount = configuration.GetValue<int>("MyService:RetryCount"),
         UseCaching = configuration.GetValue<bool>("MyService:UseCaching"),
     };

     var validationContext = new ValidationContext(options);
     Validator.ValidateObject(options, validationContext, validateAllProperties: true);

     services.AddSingleton(options);

     return services;
 }

3. Register the generated method in your startup

builder.Services.AddMyServiceOptions(builder.Configuration);

📅 Roadmap

  • Add support for complex/nested config objects
  • {get; private set;}

🔍 More from this author

🧰 Routya

A high-performance, minimal-overhead CQRS + MediatR alternative for .NET applications. Supports request/notification dispatching, behavior pipelines, scoped resolution, and performance-optimized dispatchers.

📦 Routya.ResultKit

A companion library for consistent API response modeling. Wraps results with success/failure metadata, integrates with ProblemDetails, and streamlines controller return types.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 Routya.ConfigKit:

Package Downloads
Routya.ConfigKit.Generator

Routya.ConfigKit.Generator is a Roslyn source generator that produces strongly-typed configuration binding methods at compile time. When used with [ConfigSection] from Routya.ConfigKit, it automatically emits service registration and validation code for options classes, including support for IOptions<T>, AddSingleton, and DataAnnotations validation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 144 5/1/2025
1.0.0 190 5/1/2025