Skip to content

v1.1.0

Latest

Choose a tag to compare

@ejsmith ejsmith released this 11 Apr 02:52
· 39 commits to main since this release

What's New

IMediatorBuilder Fluent API

AddMediator() now returns IMediatorBuilder instead of IServiceCollection, enabling fluent chaining for extension packages:

services.AddMediator().AddQueues();

CallContext & HTTP Binding

  • CallContext — A new pooled, lightweight mechanism for passing request-scoped objects (HttpContext, HttpRequest, HttpResponse) to handler and middleware methods, reducing allocations and improving testability
  • HTTP binding attributes — Message properties can now use [FromHeader], [FromQuery], and [FromRoute] to bind values from the HTTP request before the handler is invoked

Handler Metadata & Registry

  • HandlerRegistry now stores rich attribute metadata, source type/method names, parameter types, and stable DescriptorId identifiers
  • New indexed lookups by attribute type and descriptor ID for extension packages and middleware
  • HandlerExecutionInfo includes an optional DescriptorId for improved traceability

MessageContext<T> Subscriptions

mediator.SubscribeAsync<MessageContext<T>>() wraps subscription messages with publisher metadata (ActivityContext), enabling trace context propagation across publish/subscribe boundaries.

Result Type Improvements

  • Result.Accepted(message, location) — New overload that accepts a location string (e.g., a job status URL). Generated endpoints now emit a proper HTTP Location header on 202 responses.
  • Result.FromResult(IResult) — Safe cross-type conversion between Result and Result<T>, replacing hard casts in generated middleware pipelines

Endpoint Generation Enhancements

  • Improved route generation with better handling of non-CRUD verbs and kebab-case conversion
  • Refactored to use Group terminology (replacing Category) for clarity and consistency
  • New RouteConventions utility encapsulating shared routing logic
  • ClaimsPrincipal is now automatically available as a handler parameter in endpoints
  • Assembly name included in endpoint mapping log messages for modular apps

Authorization & OpenTelemetry

  • Generated handlers skip redundant authorization for event/notification dispatch (skipAuthorization parameter)
  • Notification handler activities now include the handler class name (e.g., Handle OrderHandler.OrderCreated)
  • IAuthorizationContextProvider falls back to Thread.CurrentPrincipal when HttpContext is unavailable (background workers)

Infrastructure

  • Startup logging moved from Console.WriteLine to ILoggerFactory-backed logging
  • Enabled TreatWarningsAsErrors and fixed all nullable reference type annotations
  • New endpoint benchmarks comparing hand-coded minimal APIs vs source-generated endpoints
  • Updated to .NET 10.0.5 dependencies

Bug Fixes

  • [HandlerEndpoint] override — An explicit [HandlerEndpoint] attribute now correctly overrides the event handler auto-exclude heuristic. Previously, handlers with class names ending in EventHandler were excluded from endpoint generation even when explicitly annotated. (#150)
  • Safe Result conversion — Generated middleware pipelines now safely convert between Result types instead of throwing InvalidCastException when the middleware returns a different IResult type than the handler declares

Contributors

Thanks to all contributors and the Dependabot for keeping dependencies up to date!

Full Changelog: v1.0.1...v1.1.0