ConfigTransformer 1.1.2
dotnet add package ConfigTransformer --version 1.1.2
NuGet\Install-Package ConfigTransformer -Version 1.1.2
<PackageReference Include="ConfigTransformer" Version="1.1.2" />
<PackageVersion Include="ConfigTransformer" Version="1.1.2" />
<PackageReference Include="ConfigTransformer" />
paket add ConfigTransformer --version 1.1.2
#r "nuget: ConfigTransformer, 1.1.2"
#:package ConfigTransformer@1.1.2
#addin nuget:?package=ConfigTransformer&version=1.1.2
#tool nuget:?package=ConfigTransformer&version=1.1.2
ConfigTransformer
ConfigTransformer is a .NET extension that enhances your configuration pipeline by transforming placeholders in your configuration values using the IConfigurationBuilder
. It replaces tokens like {Settings:Api:BaseUrl}
with their actual values from the configuration at runtime.
Ideal for simplifying complex, cross-referenced config structures in .NET
apps (e.g., appsettings.json
, environment variables, etc.).
✨ Features
- 🔁 Recursively replaces tokens like
{Section:Sub:Key}
- 🔍 Deep traversal of the configuration structure
- ✅ Safe fallback for missing keys
- 🔄 Prevents infinite substitution loops
- 🛠️ Works directly on
IConfigurationBuilder
📦 Usage
🔧 appsettings.json:
{
"Settings": {
"Api": {
"BaseUrl": "https://api.example.com"
}
},
"MyService": {
"Endpoint": "{Settings:Api:BaseUrl}/v1/data"
}
}
🌐 .NET App Initialization:
builder.Configuration
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables()
.Transform(); // Replace all placeholders after config is loaded
✅ Output after Transform
"MyService": {
"Endpoint": "https://api.example.com/v1/data"
}
🔄 How Placeholder Replacement Works
- Transform() scans all key-value pairs in the config.
- If a value contains {Some:Key}, it attempts to resolve Some:Key from the current configuration.
- It supports nested or chained placeholders.
- Up to 10 recursive passes are performed to ensure all placeholders are resolved.
- If a placeholder cannot be resolved, it is left untouched.
📌 Best Practices
- Call Transform() after your IConfigurationBuilder has loaded all sources.
- Do not use circular placeholders – transformation is capped at 10 recursive passes.
- Escape { and } with {{ or }} if you want them to remain literal.
📦 Installation
Install via NuGet
dotnet add package ConfigTransformer
Or via the NuGet Package Manager Console
Install-Package ConfigTransformer
📄 License
This project is licensed under the MIT License
Product | Versions 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 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 9.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.