ConfigKit

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

v1.0.2
875 installs
.NET 8, 9, 10
No reflection
Two packages

Source generator + core attributes

Install the generator to get both — the generator pulls in the core package transitively.

Routya.ConfigKit.Generator

v1.0.2
875 installs

Source generator that emits your config binding and DI registration code at compile time. No reflection at runtime.

Source generatorIOptionsConfig
Compile-time config binding
IOptions<T>, Singleton, or Both
DataAnnotations validation
No reflection at runtime
Drop-in appsettings.json integration
dotnet add package Routya.ConfigKit.Generator

Routya.ConfigKit

v1.0.2
783 installs

Core attributes and types — ConfigSection, ConfigBindingMode, and the primitives the generator emits against.

AttributesPrimitives
[ConfigSection] attribute
Binding-mode enum
.NET 8, 9, 10 targets
Zero runtime dependencies
MIT licensed
dotnet add package Routya.ConfigKit
Example

Tag, bind, go

Three steps from appsettings.json to validated, strongly-typed options registered in DI — no reflection, all emitted at compile time.

1. Define the config shape

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

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

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

2. Match the section in appsettings.json

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

3. Register via the generated extension

builder.Services.AddMyServiceOptions(builder.Configuration);

The AddMyServiceOptions extension is generated at compile time. Binding modes: IOptions, Singleton, or Both — DataAnnotations validated on start.