Repository navigation
2.1.0
MediatR compatibility
AnyMediator 2.1 closes the remaining gaps with MediatR: behaviors, handlers and calls written for MediatR now work unchanged once the namespace and AddMediatR are replaced.
Changes from 2.0.0 that need attention
2.0.0 was published the day before this release and had no downloads, so these changes ship as a minor version.
Publishre-throws failures, as MediatR does. Every sink still runs; one failure is re-thrown as is, several as anAggregateException. In 2.0.0 failures were logged and swallowed. The dependency onMicrosoft.Extensions.Logging.Abstractionsis removed.- Two handlers for the same request make
AddAnyMediatorthrow, naming both classes. In 2.0.0 the first one found was used silently. ISender.Send(object)andIPublisher.Publish(object)are new interface members: classes that implementISenderorIPublisherby hand must add them. Mocks are unaffected.
New
- Handlers for a notification's base class or interface also receive it:
INotificationHandler<IDomainEvent>runs for everyIDomainEvent. A handler class runs once perPublish. - Open generic handlers are found by scanning and closed when a message is dispatched, e.g.
GetByIdHandler<T> : IRequestHandler<GetById<T>, T>orIndexEntity<T> : INotificationHandler<EntityCreated<T>>. IPipelineBehaviorandIStreamPipelineBehaviorconstrainTRequesttonotnull, so MediatR behaviors compile unchanged.Send(object),CreateStream(object)andPublish(object)for messages whose type is only known at runtime;Publish(object)passes the runtime type to sinks.cfg.TypeEvaluatorfilters the types registered by scanning.
Docs: Upgrading from AnyMediator 2.0
What's Changed
- 2.1.0: MediatR-compatible Publish errors, object overloads, generic and polymorphic handlers by @Adiakys in #16
Full Changelog: 2.0.0...2.1.0