Skip to content

Attribute Reference

All attributes live in the Deepstaging.Config namespace.

[ConfigRoot]

Marks a partial class as a configuration root. The generator produces an interface, partial class implementation, DI extension, and configuration source method. This is the host-level attribute that generates config files (schema, settings, secrets).

Property Type Default Description
Section string? Inferred Configuration section name

The section name is optional. If omitted, it is inferred by stripping the ConfigRoot suffix from the class name:

// Section = "Smtp" (explicit)
[ConfigRoot(Section = "Smtp")]
public sealed partial class SmtpConfigRoot;

// Section = "Database" (inferred from "DatabaseConfigRoot")
[ConfigRoot]
public sealed partial class DatabaseConfigRoot;

DSCFG03 — Section not inferrable

If the class name does not end in ConfigRoot and no explicit Section is set, the analyzer reports DSCFG03 as an error.

[Exposes<T>]

Declares a configuration type to expose from a [ConfigRoot] or [ConfigModule]. Repeatable — add one per configuration type.

[ConfigRoot]
[Exposes<DatabaseConfig>]
[Exposes<DatabaseSecrets>]
public sealed partial class DatabaseConfigRoot;

Each exposed type becomes:

  • A property on the generated interface and class
  • An IOptions<T> binding with BindConfiguration and ValidateOnStart
  • A section in the generated JSON Schema

[ConfigModule]

Marks a static partial class as a configuration module. This is the context-level attribute that provides typed config access via runtime effects. The generator produces a provider, capability interface, effect accessors, and a DI extension method.

[ConfigModule]
[Exposes<OrderingConfig>]
public static partial class OrderingConfigModule;

The class must be static (DSCFG12) and partial (DSCFG11).

Use [ConfigModule] alongside [Runtime] — it's auto-discovered in the same assembly:

[Runtime]
public partial class OrderingRuntime;
// OrderingConfigModule is auto-discovered

// In handlers:
from config in OrderingConfigModule.OrderingConfig<OrderingRuntime>()
let minutes = config.GracePeriodMinutes

See Generated Code for the full list of generated artifacts.

[ConfigSection]

Used by infrastructure packages to declare their configuration requirements at a specific section path.

// In Deepstaging.Data.Postgres
[ConfigSection("Deepstaging:Postgres")]
public sealed class DeepstagingPostgresOptions
{
    [Secret]
    public string ConnectionString { get; set; } = "";
    public string Schema { get; set; } = "ds";
}

Infrastructure sections are automatically included in the generated JSON Schema under their declared path.

[Secret]

Marks a property as containing sensitive data. See the Secrets page for full details.

public class SmtpSecrets
{
    [Secret]
    public string Password { get; init; } = "";

    [Secret]
    public string ApiKey { get; init; } = "";
}