martinothamar/mediator

A high performance implementation of Mediator pattern in .NET using source generators.

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 1 hour ago
Added to GitGenius on September 18th, 2026
Created on March 31st, 2021
Open Issues & Pull Requests: 39 (+0)
GitHub issues: Enabled
Number of forks: 182
Total Stargazers: 3,719 (+0)
Total Subscribers: 47 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 22.6 hours
Mean response time: 37.4 days
90th percentile: 54.8 days
Tracked items: 66

Most active contributors

Sign in to see contributor activity.

How this project is maintained

79% of open issues come from outside the core team, so the backlog reflects real-world use rather than internal planning. Three people close 91% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 28
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 674 days
Stale 30+ days: 28
Stale 90+ days: 26

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 1
Events in 7 days: 3

Top labels

  • enhancement (14)
  • help wanted (3)
  • good first issue (2)
  • bug (1)
  • documentation (1)

Most active issues this week

Detailed Description

Mediator is a high performance implementation of the Mediator pattern in .NET using source generators.

The mediator pattern addresses the need to implement cross-cutting concerns like logging and metrics while avoiding constructor bloat from numerous injected dependencies. This implementation uses source generators to produce code at compile time rather than relying on reflection or runtime code generation. The generator creates DI registration code, implements the IMediator interface, monomorphizes Send methods for requests and commands, and generates diagnostics to catch configuration errors during development. For larger projects, it builds fast dictionary lookups for methods taking object or generic arguments.

Developers should choose this tool if they need Native AOT support, care about cold start performance in serverless or edge scenarios, or want build-time error detection instead of runtime failures. The tool suits projects targeting .NET Standard 2.0 or .NET 8 where performance is a priority. The README explicitly compares it to MediatR, noting that this implementation delivers better performance while maintaining a similar API. Unlike MediatR, it provides full Native AOT support without reflection and emphasizes non-pessimization by making slower configurations opt-in. Users can work with either the IMediator interface or the concrete Mediator class, with the latter offering better performance characteristics.

The project maintains a stable API that changes only for good reason and follows semantic versioning strictly, reducing the patching burden on adopters. The source generator includes diagnostics that warn when handlers are not defined for requests, catching mistakes during development. The library is distributed as two NuGet packages: Mediator.SourceGenerator for executable projects and Mediator.Abstractions for projects defining messages and handlers, with clear guidance that the generator should not be installed in every layer of a deployed artifact.