Skip to content

DovetailConfigurationAttribute

Classsealednet10.0
📦 Joinery.Dovetail v0.4.3-beta.13
Declares the configuration section of an options class. Dovetail's source generator describes the class as JSON Schema, which is merged into the application's appsettings.schema.json for editor completion and validation, and registers it with the options pipeline.
namespace Joinery.Dovetail.Attributes;
public sealed class DovetailConfigurationAttribute
: System.Attribute
{
// ...
}
Attribute

Without a section path the section is the type name with an Options, Settings, Configuration or Config suffix removed, so GreetingsOptions becomes Greetings. Nested sections use :, as in "Http:Retry".

A type has one section, so it can be declared once. For a type you don't own, use the assembly form, Attributes.DovetailConfigurationAttribute`1.

DovetailConfigurationAttribute.KeyStyle picks how the keys of the type and of the types nested in it are spelled (as declared, Pascal, camel, dash or underscore case). A type that several sections reach has to spell its keys the same way in all of them; DT0016 reports a mismatch.

The generated registration reads its own section from the application's complete IConfiguration and creates or binds the options.

Only works with source generators enabled.

View all constructors
View all properties