Table of Contents

Class StartupValidationServiceProviderExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Excalibur.Dispatch.Abstractions.dll

Provides a host-less trigger for the framework's fail-fast startup gates — both the options gates registered with ValidateOnStart<TOptions>(OptionsBuilder<TOptions>) and the prerequisite wiring checks registered as IStartupPrerequisiteValidator.

public static class StartupValidationServiceProviderExtensions
Inheritance
StartupValidationServiceProviderExtensions
Inherited Members

Methods

ValidateStartupGates(IServiceProvider)

Runs the container's startup gates immediately, for consumers who build an IServiceProvider and resolve services directly without ever starting a host.

public static IServiceProvider ValidateStartupGates(this IServiceProvider provider)

Parameters

provider IServiceProvider

The built service provider whose startup gates should run now.

Returns

IServiceProvider

The same provider, so the call can be chained after BuildServiceProvider().

Remarks

Both families of gate fire from host startup, which only happens when the application calls IHost.StartAsync: the ValidateOnStart() options gates (for example the audit-store, key, grant, schedule, and separation-of-duties durability checks) and the prerequisite wiring checks (for example "event sourcing was added but no IEventStore provider was selected"). A consumer who composes the container manually — a custom serverless runtime, a manual IServiceProvider, a unit of work that never builds a host — never triggers them, so the fail-fast guarantees are silently inert. Such a consumer MUST call this method once, immediately after building the provider.

It runs the framework's own IStartupValidator (what ValidateOnStart() registers), so every registered options gate is covered automatically with no list to keep in sync, and then every IStartupPrerequisiteValidator in the container. It starts no hosted services: outbox processors, leader election, and other background work stay unstarted, because a container the consumer never intended to run as a host must not acquire one by asking whether it is wired correctly. It no-ops when neither family is registered, and is safe to call once after build.

One class of check is deliberately not covered: a gate that must perform I/O to decide — probing a remote secret mount, reading a physical table schema — cannot run from a synchronous method without blocking. Those remain hosted-only and each carries its own fail-closed check on the path it protects, so a host-less consumer fails on first use of that path rather than silently proceeding.

Hosts that build an IServiceProvider through the generic host and call StartAsync — including Azure Functions and AWS Lambda on the isolated-worker model — already run these gates at start and do not need this call. It is for the genuinely host-less path only.

Exceptions

ArgumentNullException

provider is null.

OptionsValidationException

A registered options gate fails validation.

InvalidOperationException

A registered prerequisite is missing or misconfigured.