Skip to content

Document async options validation in ASP.NET Core 11 - #37679

Draft
meaghanlewis with Copilot wants to merge 2 commits into
mainfrom
copilot/document-support-for-async-validation
Draft

meaghanlewis with Copilot wants to merge 2 commits into
mainfrom
copilot/document-support-for-async-validation

Conversation

Copilot AI commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

ASP.NET Core 11 adds async options validation during host startup. The options article only covered synchronous validation and ValidateOnStart.

  • Async startup validation

    • Added .NET 11+ guidance for async OptionsBuilder<TOptions>.Validate(...) overloads.
    • Clarified that async validators run through ValidateOnStart during IHost.StartAsync.
  • Validator patterns

    • Documented IAsyncValidateOptions<TOptions> for dedicated validator classes.
    • Noted registration via IValidateOptions<TOptions> and the synchronous fail-fast path.
  • Data annotations and source generation

    • Documented async DataAnnotations participation through DataAnnotationValidateOptions<TOptions>.
    • Added source-generator behavior for [OptionsValidator] emitting ValidateAsync when the validator implements IAsyncValidateOptions<TOptions>.
builder.Services.AddOptions<RemoteServiceOptions>()
    .Bind(builder.Configuration.GetSection(RemoteServiceOptions.SectionName))
    .Validate<IEndpointHealthCheck>(
        async (options, healthCheck, cancellationToken) =>
            await healthCheck.IsAvailableAsync(options.Endpoint, cancellationToken),
        "The configured endpoint isn't available.")
    .ValidateOnStart();
  • Scope and limitations
    • Clarified that IOptions<TOptions>.Value, IOptionsSnapshot<TOptions>, and IOptionsMonitor<TOptions> reloads remain synchronous and don't invoke async validators.

Internal previews

File Preview link
aspnetcore/fundamentals/configuration/options.md Learn preview

Build report

Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Copilot AI changed the title [WIP] Document support for async validation for options Document async options validation in ASP.NET Core 11 Sep 17, 2026
Copilot AI requested a review from meaghanlewis September 17, 2026 22:37
@meaghanlewis meaghanlewis reopened this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document support for async validation for Options

2 participants