Table of Contents

Class AotFluentValidatorResolver

Namespace
Excalibur.Dispatch.Validation.FluentValidation
Assembly
Excalibur.Dispatch.Validation.FluentValidation.dll

AOT-compatible FluentValidation validator resolver that uses compile-time code generation.

public sealed class AotFluentValidatorResolver : IValidatorResolver
Inheritance
AotFluentValidatorResolver
Implements
Inherited Members
Extension Methods

Remarks

This implementation avoids reflection by delegating to a source-generated IAotValidationDispatcher that maps each message type to its strongly-typed validators at compile time.

If no IAotValidationDispatcher is registered in the service provider, TryValidateAsync(IDispatchMessage, IServiceProvider?, CancellationToken) throws InvalidOperationException directing the consumer to add the Excalibur.Dispatch.SourceGenerators analyzer package.

Constructors

AotFluentValidatorResolver(IServiceProvider)

AOT-compatible FluentValidation validator resolver that uses compile-time code generation.

public AotFluentValidatorResolver(IServiceProvider provider)

Parameters

provider IServiceProvider

The service provider for dependency injection.

Remarks

This implementation avoids reflection by delegating to a source-generated IAotValidationDispatcher that maps each message type to its strongly-typed validators at compile time.

If no IAotValidationDispatcher is registered in the service provider, TryValidateAsync(IDispatchMessage, IServiceProvider?, CancellationToken) throws InvalidOperationException directing the consumer to add the Excalibur.Dispatch.SourceGenerators analyzer package.

Methods

TryValidateAsync(IDispatchMessage, IServiceProvider?, CancellationToken)

Validates a message using AOT-compatible, source-generated dispatch logic.

public ValueTask<IValidationResult?> TryValidateAsync(IDispatchMessage message, IServiceProvider? requestServices = null, CancellationToken cancellationToken = default)

Parameters

message IDispatchMessage

The message to validate.

requestServices IServiceProvider

The caller-owned request-scoped provider.

cancellationToken CancellationToken

Cancellation of validation.

Returns

ValueTask<IValidationResult>

Validation result if validators exist, null otherwise.

Exceptions

InvalidOperationException

Thrown when no IAotValidationDispatcher is registered. This means the Excalibur.Dispatch.SourceGenerators package is not referenced as an analyzer, or no FluentValidation validators for IDispatchMessage types were discovered at compile time.