Optionary 0.1.1

dotnet add package Optionary --version 0.1.1
                    
NuGet\Install-Package Optionary -Version 0.1.1
                    
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="Optionary" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Optionary" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Optionary" />
                    
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 Optionary --version 0.1.1
                    
#r "nuget: Optionary, 0.1.1"
                    
#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 Optionary@0.1.1
                    
#: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=Optionary&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Optionary&version=0.1.1
                    
Install as a Cake Tool

Optionary

Strongly-typed, AOT-safe configuration options for .NET: a reflection-free options binder and per-application JSON Schema for editor completion, generated from your options types.

It ships as one package, Optionary: the [Optionary] attribute, the source generator, the binder and the schema build. Optionary reads whatever IConfiguration holds and adds no configuration providers of its own; use Microsoft's JSON provider or any other IConfigurationSource for the files.

github-release-badge github-license-badge github-build-badge nuget-Optionary-badge

Documentation: https://rocketsurgeonsguild.github.io/Optionary/

Getting started

Add the package:

dotnet add package Optionary

Put [Optionary] on the class that holds a section's values. The section name is the type name without its Options suffix:

using System.ComponentModel.DataAnnotations;
using Optionary;

namespace MyApp;

/// <summary>Options for the greetings this application prints.</summary>
[Optionary] // section "Greetings"
public sealed class GreetingsOptions
{
    /// <summary>The text that comes before the name.</summary>
    public string Message { get; set; } = "Hello";

    /// <summary>How many times the greeting is said.</summary>
    [Range(1, 5)]
    public int Repeat { get; set; } = 1;
}

The generator writes an internal AddOptionaryConfigurationOptions() extension method into the project's RootNamespace. Call it once, then read the options through IOptions<GreetingsOptions> as usual:

using MyApp;

var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddOptionaryConfigurationOptions();

Building an application writes obj/appsettings.schema.json, merged from its own options types and those of every library it references, which editors use for completion and validation of appsettings.json. See Getting started for the editor setup, and the samples for a library, a console app and a web app.

Packages

Package NuGet What it does
Optionary nuget-Optionary-badge The [Optionary] attributes, the source-generated binder and the MSBuild targets for the schema

Building

The toolchain comes from mise: mise install, then mise run build (or dotnet build Optionary.slnx). mise run docs serves the documentation site from docs/.

Origins

Optionary started as the configuration schema and binding feature of Dovetail, and was moved into its own library so it can be used without Dovetail. The code was imported from Dovetail at commit 3f512a33b0 as a snapshot, without its history, and then renamed; Dovetail's history up to that commit is where to look for how it came to be. The migration plan tracks what has moved so far.

Product Compatible and additional computed target framework versions.
.NET 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.  net11.0 is compatible. 
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 Optionary:

Package Downloads
Rocket.Surgery.ModularPipelines.Extensions

ModularPipelines modules that restore, version with GitVersion, build, test with coverage, pack, ship public API files and build the docs of a .NET solution, added to a build host by Dovetail joints, with run history kept in the repository.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 165 11/16/2026
0.1.1-beta.0 108 11/16/2026
0.1.0-beta.1 94 11/16/2026