Routya.ConfigKit
1.0.0
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
<PackageReference Include="Routya.ConfigKit" Version="1.0.0" />
<PackageVersion Include="Routya.ConfigKit" Version="1.0.0" />
<PackageReference Include="Routya.ConfigKit" />
paket add Routya.ConfigKit --version 1.0.0
#r "nuget: Routya.ConfigKit, 1.0.0"
#addin nuget:?package=Routya.ConfigKit&version=1.0.0
#tool nuget:?package=Routya.ConfigKit&version=1.0.0
⚙️ Routya.ConfigKit.Generator
🔧 A lightweight, source-generated configuration binder for .NET — just tag your class with
[ConfigSection]
and go.
✨ Features
- ✅ Compile-time generation of config binding and registration code
- ✅ Supports both
IOptions<T>
andAddSingleton<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 | Versions 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Options.DataAnnotations (>= 9.0.4)
- System.ComponentModel.Annotations (>= 5.0.0)
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.