Skip to content
CAI
Software that uses CAICheck a score

mayuanyang/Mediator.Net

54.5

Adequate · 21 September 2026

3.5k

lines of production code

C#

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Mediator.Net is a .NET library implementing the Mediator pattern to decouple components by routing commands, events, and requests to their respective handlers. It provides a modular pipeline architecture that supports dependency injection, middleware execution, and streaming responses. The system includes integrations for major IoC containers and offers utilities for testing and logging.

How it got here

2016 — Initial project setup and architecture

17 changes.

This period marks the initialization of the Mediator.Net repository, establishing the core solution structure and integrating with multiple dependency injection containers such as Autofac, Microsoft DI, and Ninject. The work focused on defining the foundational message pipeline architecture, including distinct handling for commands, events, and requests, while simultaneously building out comprehensive test coverage for these new features.

2017–2018 — Web API integration and test coverage

17 changes.

This period focused on expanding the library's ecosystem by introducing a Serilog middleware and a Web API sample application to demonstrate ASP.NET Core integration. Concurrently, extensive test coverage was added for dependency injection containers, cancellation propagation, and performance, while updating handlers to support the new IReceiveContext interface.

2019–2022 — test coverage expansion

5 changes.

This period focused on expanding test coverage for the Mediator.Net library, specifically targeting stream handling, inheritance-based routing, and exception validation. New unit tests were added to verify the correct behavior of custom receive contexts, stream request and command handlers, and error conditions.

Features

Add Microsoft Dependency Injection integration for Mediator.Net

Users can now register the Mediator.Net mediator with the standard Microsoft.Extensions.DependencyInjection container. A new \Mediator.Net.MicrosoftDependencyInjection\ package provides \ContainerBuilderExtensions\ to wire up the mediator and its associated pipes, while the core library introduces an \IDependencyScope\ abstraction and specific exceptions to support this integration.

src/Mediator.Net · high confidence

Add Ninject integration for Mediator.Net

Users can now resolve Mediator.Net dependencies using the Ninject IoC container. This change introduces a new \NinjectDependencyScope\ class and \NinjectExtensions\ to bind the \MediatorBuilder\ and \IDependencyScope\ to the Ninject \StandardKernel\, enabling Ninject-based dependency resolution within the Mediator pipeline.

(repo-wide) · medium confidence

Add Serilog middleware for message logging

A new Serilog middleware has been added to the Mediator.Net pipeline, allowing users to log incoming messages at a specified log level (e.g., Information, Debug, Error) via the \UseSerilog\ extension method. The middleware supports conditional execution through a \shouldExecute\ filter and integrates with IoC containers by resolving the \ILogger\ from the dependency scope if not explicitly provided.

src/Mediator.Net.Middlewares.Serilog · high confidence

Add ValuesController for Mediator integration

A new ValuesController has been added to the WebApiSample project, exposing HTTP endpoints for sending commands and events through the Mediator pattern. This controller demonstrates how to inject the IMediator service and use RequestAsync and PublishAsync to interact with handlers, providing a concrete example of the library's usage in an ASP.NET Core application.

src/Mediator.Net.WebApiSample/Controllers · high confidence

Add Web API sample application with Mediator.Net integration

A new Web API sample project has been added to demonstrate Mediator.Net integration. The sample includes a standard ASP.NET Core startup configuration that registers the Mediator, including automatic handler registration from the test utilities and the sample's own handlers. It also configures MVC with Newtonsoft.Json and sets up logging for development and general environments.

src/Mediator.Net.WebApiSample · high confidence

Added calculation message and event handler for the WebApiSample

Introduced new message types and an event handler to support a calculation workflow. A new \CalculateCommand\ and \ResultCalculatedEvent\ were added to the messages folder, alongside a \ResultCalculatedEventHandler\ that processes the event by invoking a \BoardcastService\ to record the result.

src/Mediator.Net.WebApiSample/Handlers/EventHandler, src/Mediator.Net.WebApiSample/Messages · medium confidence

Introduces a structured message and handler contract hierarchy

The library now defines a clear separation between commands, events, requests, and their corresponding handlers, each with specific return types. Commands and events are treated as fire-and-forget messages, while requests are designed to return a response. Additionally, streaming variants (IStreamCommandHandler and IStreamRequestHandler) are introduced to support asynchronous enumerable responses, allowing handlers to yield multiple results over time.

src/Mediator.Net/Contracts · high confidence

Project initialization and repository setup

The repository was initialized with the core Mediator.Net solution structure, including the main project and integration packages for Autofac, Microsoft Dependency Injection, Serilog, and test utilities. The setup includes a comprehensive README with usage examples, a Chinese translation of the documentation, and standard repository files such as the Apache 2.0 license, code of conduct, and contributing guidelines.

(repo-wide) · high confidence

Behavioural changes

Added request and stream handler implementations for testing

The test utility library now includes a suite of request and stream handlers to support various test scenarios. This includes handlers for simple requests, multiple requests, and stream-based requests, as well as specific handlers for exception scenarios (e.g., \SimpleRequestWillThrowHandler\, \GetMultipleGuidStreamRequestWithExceptionHandler\). The changes also introduce support for inheritance-based handlers and multi-request handling within the \Mediator.Net.TestUtil\ project.

src/Mediator.Net.TestUtil/Handlers/RequestHandlers · medium confidence

Command handlers now accept IReceiveContext

The CalculateCommandHandler has been updated to accept an IReceiveContext parameter in its Handle method. This change allows the handler to access the incoming message and publish a response event, aligning with the new context-based API for command processing.

src/Mediator.Net.WebApiSample/Handlers/CommandHandler · medium confidence

Command handlers updated to use IReceiveContext

All command handlers in the test utility have been updated to accept IReceiveContext as a dependency, enabling access to message metadata and services. The change also introduces support for command responses, allowing handlers to return results, and adds new handlers for inheritance, multi-command handling, and performance testing.

src/Mediator.Net.TestUtil/Handlers/CommandHandlers · high confidence

Context objects now support service registration and async publishing

The context objects (IContext, IReceiveContext, IPublishContext) have been refactored to include a service registration mechanism (RegisterService/TryGetService) and a MetaData dictionary for storing arbitrary key-value pairs. Additionally, IReceiveContext now exposes a PublishAsync method that allows a handler to publish an event asynchronously using the configured publish pipe, enabling handlers to trigger downstream events or commands within the same execution flow.

src/Mediator.Net/Context · high confidence

Introduce message binding and handler registry structures

The library now exposes a new MessageBinding class that pairs a message type with its corresponding handler type, alongside a MessageHandlerRegistry that stores these bindings in a HashSet. This change introduces the core data structures for managing message-to-handler mappings, replacing previous implementations that relied on thread-static state or shared registries.

src/Mediator.Net/Binding · medium confidence

Refactored message pipeline architecture with dedicated pipes for commands, events, and requests

The message handling logic has been restructured into distinct pipeline components: CommandReceivePipe, EventReceivePipe, and RequestPipe, each with their own configurator and interface. A new GlobalReceivePipe acts as a central dispatcher that routes incoming messages to the appropriate handler based on message type. This change introduces a more modular and strongly-typed pipeline architecture, allowing for better separation of concerns and easier extension of message handling behavior.

src/Mediator.Net/Pipeline · high confidence

Test coverage

Add test middleware implementations for exception handling; Added AssemblyInfo metadata for the test project; Added AssemblyInfo.cs for the Mediator.Net.Autofac.Test project; Added cancellation token propagation tests; Added end-to-end tests for API endpoints; Added end-to-end tests for Mediator.Net Microsoft Dependency Injection integration; Added inheritance handler tests; Added initial test suite for Mediator.Net; Added integration tests for SimpleInjector DI scenarios; Added performance tests for the Mediator; Added test event handlers for inheritance, multiple events, and error scenarios; Added test for middleware metadata availability; Added test for multi-handler registration of the same event; Added test infrastructure for Autofac integration; Added test utilities for message types, middleware, and service mocks; Added tests for Mediator.Net.Autofac integration; Added tests for custom receive context usage; Added tests for event publishing and handler registration; Added tests for exception type validation; Added tests for message pipeline execution and exception handling; Added tests for request handling and unified result processing; Added tests for stream command handling; Added tests for stream request handlers; Expanded test coverage for command and event handling.

Dependencies

Updated .NET target frameworks and test dependencies

The project files have been updated to target .NET 8.0 and .NET 9.0 across the core library, integration packages (Autofac, Microsoft Dependency Injection, SimpleInjector, StructureMap, Ninject), and test projects. Test projects have been updated to use xUnit 2.9.3, Microsoft.NET.Test.Sdk 17.7.2, and other test utilities, while the main library references System.Interactive.Async 6.0.1.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 52 → 54 (+2.6)
  • Rubric changed (rubric-2026.08.18 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 89 → 80 (-9.0)
  • Architecture 69 → 69 (+0.0)
  • Maturity 60 → 62 (+2.3)
  • Readiness 43 → 43 (-0.4)
  • Security 52 → 64 (+11.1)
  • Performance 68 → 68 (+0.0)

Resolved (15)

  • Bounded contexts not declared
  • Duplicated block (15 lines × 2) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • Duplicated block (15 lines × 2) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • No exposed public API
  • Off-boarding risk: anonymized user #1
  • The README is a single file with no architecture or design documentation (no markdown files), so any architectural decisions, container integration details, or middleware ordering guidance are not present in the visible text and cannot be confirmed from this document alone. (README.md)
  • redundant comment (src/Mediator.Net.Autofac.Test/Properties/AssemblyInfo.cs)
  • redundant comment (src/Mediator.Net.Autofac.Test/Properties/AssemblyInfo.cs)

New (61)

  • Documentation: no architecture or design documentation (README.md)
  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • Duplicated block (10 lines × 5) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • Duplicated block (11–13 lines × 2) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • Duplicated block (13 lines × 2) (src/Mediator.Net/Context/PublishContext.cs)
  • Duplicated block (13–15 lines × 2) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • Duplicated block (16 lines × 4) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • Duplicated block (21 lines × 2) (src/Mediator.Net/Pipeline/GlobalReceivePipe.cs)
  • Duplicated block (34–35 lines × 3) (src/Mediator.Net/Pipeline/CommandReceivePipe.cs)
  • Duplicated block (6 lines × 2) (src/Mediator.Net.TestUtil/Middlewares/MiddlewareThrowExBeforeConnect.cs)
  • Duplicated block (6 lines × 4) (src/Mediator.Net.TestUtil/Middlewares/ConsoleLog2.cs)
  • Duplicated block (9 lines × 2) (src/Mediator.Net.TestUtil/Middlewares/SimpleMiddleware.cs)
  • End-of-life runtime: .NET net6.0
  • End-of-life runtime: .NET net9.0
  • Flaky test: Mediator.Net.Test::Mediator.Net.Test.TestEventHandlers.TestParentAndChildCombinedHandler.Mediator.Net.Test.TestEventHandlers.TestParentAndChildCombinedHandler.TestCombinedEventForChild
  • Flaky test: Mediator.Net.Test::Mediator.Net.Test.TestEventHandlers.TestParentAndChildCombinedHandler.Mediator.Net.Test.TestEventHandlers.TestParentAndChildCombinedHandler.TestCombinedEventForParent
  • Grammar inconsistency in test method name. 'ThenTheResultShouldBeReturn' uses the base form 'Return' instead of the past participle 'Returned' (as in 'should be returned').
  • Grammar inconsistency in test method names. 'WhenAEventIsPublished' uses 'A' before a vowel sound ('Event'), whereas 'WhenAMoreDerivedEventIsPublished' correctly uses 'A' before a consonant sound. The former should use 'An'.
  • High: security finding (details withheld)
  • …and 41 more

API surface

  • Unchanged — 2 HTTP endpoints

Architecture

  • Containers 0 added · 0 removed · contexts 1 added · 0 removed · edges 0 added · 0 removed

Added bounded contexts (1)

  • Mediator.Net.TestUtil

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

mayuanyang/Mediator.Net was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 0ea4f0f3fb40c736aa126c48edb100db69d81dd7 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.