Invex.Rez.Configuration 0.4.0-rc.6

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

Rez

Rez is a small .NET library for resolving terse, nestable template text such as {name} and {function(args)}. It is designed for application strings, configuration values, and other text where a full template engine would be unnecessary.

Rez takes inspiration from Mustache, but uses curly-brace tokens that can be nested and resolved recursively.

var resolver = new Resolver();
resolver.AddSource(new ResolverSource(new Dictionary<string, string> { { "name", "World" } }));

var greeting = resolver.Resolve("Hello, {name}!");

// greeting: "Hello, World!"

Features and behavior

  • Variables — {name} is replaced with its value
  • Functions — {repeat(abc,3)} invokes a function with the raw argument text
  • Nesting — {variable{number}} resolves inside-out, left-to-right
  • Recursion — resolved values may themselves contain placeholders, with a 4096-pass limit
  • Escaping — \{literal\} excludes braces from resolution (the backslashes are preserved in the output)
  • Pluggable sources — layer any number of variable/function sources; the first non-null result wins
  • Graceful fallback — unresolvable placeholders are left in the output unchanged
  • High performance — pooled buffers and span-based parsing minimize allocations
  • Configuration integration — resolve templates inside Microsoft.Extensions.Configuration values

Resolve(null) returns null. Missing variables and functions do not throw. Function delegates must return a non-null string; a source returns null only when it cannot resolve a name and wants the next source to be queried.

Installation

Install the core package:

dotnet add package Invex.Rez

For Microsoft.Extensions.Configuration integration, install the additional package:

dotnet add package Invex.Rez.Configuration

Both packages target net10.0, net9.0, net8.0, and netstandard2.0. The test project also runs on net48.

Variables and functions

Sources provide variables, functions, or both. ResolverSource is immutable and initialized with known values; ResolverStore is mutable and replaces an existing entry when the same name is added.

var resolver = new Resolver();
resolver.AddSource(new ResolverSource(new Dictionary<string, string>
{
    ["name"] = "World"
}));

var greeting = resolver.Resolve("Hello, {name}!");

// greeting: "Hello, World!"

Functions receive a FunctionCall whose Args property contains all text between the parentheses. Rez does not split or trim arguments; parsing is owned by the function:

var resolver = new Resolver()
    .AddSource(new ResolverSource(new Dictionary<string, Func<FunctionCall, string>>
    {
        ["shout"] = call => (call.Args ?? string.Empty).ToUpperInvariant() + "!"
    }));

var output = resolver.Resolve("{shout(hello)}");

// output: "HELLO!"

Source ordering and mutable values

Sources are queried in registration order for every placeholder. The first non-null result wins, so register overrides before defaults:

var overrides = new ResolverStore();
var defaults = new ResolverSource(new Dictionary<string, string> { ["env"] = "production" });

var resolver = new Resolver()
    .AddSource(overrides)
    .AddSource(defaults);

resolver.Resolve("{env}"); // "production"
overrides.AddVariable("env", "development");
resolver.Resolve("{env}"); // "development"

Use RemoveVariable and RemoveFunction to remove entries from a ResolverStore. Resolver and source types are not synchronized; configure them before concurrent use, or provide synchronization when mutating them.

Configuration integration

Invex.Rez.Configuration provides two related features:

  1. ConfigResolverSource exposes IConfigurationRoot values as Rez variables, including nested keys such as {Logging:Level}.
  2. IResolvableConfig wraps configuration and resolves templates when values are read. The AddResolvableConfiguration() extension registers it in dependency injection.
var config = (IConfigurationRoot)new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

var resolver = new Resolver()
    .AddSource(new ConfigResolverSource(config));

var output = resolver.Resolve("The {ServiceName} service is ready.");

Values written through IResolvableConfig are stored unmodified; resolution occurs on read. See the Configuration Integration guide for dependency-injection setup.

Development

The repository requires the .NET 10 SDK selected by global.json:

dotnet build Invex.Rez.slnx
dotnet test Invex.Rez.slnx

See AGENTS.md for repository structure, code conventions, generated workflow rules, snapshot testing, and the complete contributor checklist.

Documentation

Where did the name come from?

The name Rez is a play on the word "res" (short for "resolution"), which is the process of resolving a template. The name was chosen as it is short and memorable and is not too similar to other names in the .NET ecosystem.

License

See LICENSE.txt.

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 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. 
.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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0-rc.4 56 11/20/2026
1.3.0-rc.2 64 11/13/2026
1.2.0 94 11/11/2026
1.2.0-rc.11 57 11/11/2026
1.2.0-rc.2 67 10/30/2026
1.1.0 102 10/22/2026
1.1.0-rc.6 64 10/22/2026
1.1.0-rc.4 69 10/22/2026
1.1.0-rc.2 63 10/16/2026
1.0.0 99 10/15/2026
0.4.0-rc.34 67 10/15/2026
0.4.0-rc.32 66 10/14/2026
0.4.0-rc.26 57 10/14/2026
0.4.0-rc.24 60 10/14/2026
0.4.0-rc.22 54 10/14/2026
0.4.0-rc.20 83 10/14/2026
0.4.0-rc.16 65 10/13/2026
0.4.0-rc.10 77 9/11/2026
0.4.0-rc.8 81 8/28/2026
0.4.0-rc.6 87 8/21/2026
Loading failed