MediateX 3.0.0

Requires NuGet 6.0 or higher.

dotnet add package MediateX --version 3.0.0
                    
NuGet\Install-Package MediateX -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MediateX" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MediateX" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MediateX" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MediateX --version 3.0.0
                    
#r "nuget: MediateX, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MediateX@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MediateX&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MediateX&version=3.0.0
                    
Install as a Cake Tool

MediateX Logo

MediateX

The Modern Mediator Pattern for .NET 10+

NuGetLicenseC#.NET

MediateX is a bold reimagining of the mediator pattern, crafted exclusively for the modern .NET ecosystem. Born from the solid foundation of MediatR, MediateX takes a deliberate step forward, shedding the weight of backward compatibility to fully embrace the power and performance of .NET 10 and beyond.

Version 3.x marks a pivotal moment: upgraded to .NET 10, enhanced DI container compatibility, improved assembly scanning robustness, and critical bug fixes for notification handlers and nested generic behaviors.

Our philosophy is simple: always leverage the best of what the .NET platform offers. MediateX is built with the latest C# 14 features and targets .NET 10. This is not just another library; it's a commitment to staying on the cutting edge.


๐Ÿ’– Support the Project

MediateX is a passion project, driven by the desire to provide a truly modern tool for the .NET community. Maintaining this library requires significant effort: staying current with each .NET release, addressing issues promptly, implementing new features, keeping documentation up to date, and ensuring compatibility across different DI containers.

If MediateX has helped you build better applications or saved you development time, I would be incredibly grateful for your support. Your contributionโ€”no matter the sizeโ€”helps me dedicate time to respond to issues quickly, implement improvements, and keep the library evolving alongside the .NET platform.

I'm also looking for sponsors who believe in this project's mission. Sponsorship helps ensure MediateX remains actively maintained and continues to serve the .NET community for years to come.

Of course, there's absolutely no obligation. If you prefer, simply starring the repository or sharing MediateX with fellow developers is equally appreciated!

  • โญ Star the repository on GitHub to raise its visibility

  • ๐Ÿ’ฌ Share MediateX with your team or community

  • โ˜• Support via Donations:

    • PayPal
    • Ko-fi

๐ŸŽ‰ What's New in 3.0.0

Major .NET 10 Upgrade! MediateX 3.0.0 brings significant improvements:

  • โฌ†๏ธ Target Framework: Upgraded from .NET 9 to .NET 10 with C# 14
  • ๐Ÿ”ง DI Container Compatibility: Simplified mediator constructor works with all DI containers
  • ๐Ÿ›ก๏ธ Assembly Scanning Robustness: Safe handling of assemblies with unloadable types (F# inref/outref, missing dependencies)
  • ๐Ÿ› Notification Handler Fix: Fixed contravariance-based incorrect handler registration that caused duplicate invocations
  • ๐Ÿ› Nested Generic Behaviors: Fixed AddOpenBehavior() for behaviors like IPipelineBehavior<TRequest, Result<T>>
  • ๐Ÿ“ Project Structure: Reorganized to src/MediateX/ following .NET ecosystem conventions

See the full changelog for details.


๐Ÿš€ Getting Started

Integrating MediateX into your .NET 10+ application is straightforward.

1. Install the NuGet Package:

dotnet add package MediateX

2. Register Services: In your Program.cs or service configuration, register MediateX and tell it which assembly to scan for handlers.

builder.Services.AddMediateX(cfg =>
{
    // Scans the assembly containing your handlers (e.g., Program)
    cfg.RegisterServicesFromAssemblyContaining<Program>();
});

3. Create and Send a Request: Define a request and its handler, then use the IMediator service to send it.

// Define a request and its expected response
public record GetProductQuery(int Id) : IRequest<Product>;

// Create a handler for the request
public class GetProductHandler : IRequestHandler<GetProductQuery, Product>
{
    public Task<Product> Handle(GetProductQuery request, CancellationToken cancellationToken)
    {
        // Your business logic here...
        var product = new Product { Id = request.Id, Name = "Awesome Gadget" };
        return Task.FromResult(product);
    }
}

// Inject IMediator and send the request from a controller or another service
var product = await mediator.Send(new GetProductQuery(42));

โœจ Features

Core Capabilities

  • Request/Response - Commands and queries with single handler (IRequest<TResponse>)
  • Notifications & Events - Publish to multiple handlers (INotification)
  • Streaming - Async stream responses with IAsyncEnumerable<T> (IStreamRequest<TResponse>)
  • Separated Interfaces - Use ISender, IPublisher, or IMediator based on your needs

Pipeline Features

  • Behaviors - Add cross-cutting concerns (logging, validation, caching, etc.)
  • Pre/Post Processors - Execute logic before and after handlers
  • Exception Handling - Sophisticated error handling with fallback responses
  • Stream Behaviors - Wrap and transform async streams

Advanced Features

  • Publishing Strategies - Sequential or parallel notification execution
  • Generic Variance - Leverage C# covariance/contravariance
  • Dynamic Dispatch - Runtime type resolution for flexibility
  • Handler Prioritization - Automatic ordering based on assembly/namespace
  • Open Generic Support - Register generic handlers with constraints

๐Ÿ“… Versioning & .NET Support Policy

MediateX follows a clear versioning strategy aligned with .NET's release cadence:

Version History

MediateX .NET C# Status
1.x - 2.x .NET 9 C# 13 Legacy
3.x .NET 10 C# 14 Current

Future Support Policy

MediateX will always support the current LTS version plus the next standard release. When a new LTS version is released, support for older versions will be discontinued:

MediateX .NET C# Notes
3.x .NET 10 C# 14 LTS only
4.x .NET 10 + .NET 11 C# 14 / C# 15 LTS + Standard
5.x .NET 12 C# 16 New LTS (drops .NET 10/11)
6.x .NET 12 + .NET 13 C# 16 / C# 17 LTS + Standard

Why this policy?

  • Focused development: By limiting supported versions, we can dedicate more effort to quality, performance, and new features
  • Modern features: Each .NET version brings improvements that MediateX can fully leverage
  • Clear upgrade path: Users know exactly when to plan their upgrades

Note: We recommend always using the latest LTS version of .NET for production applications.


๐Ÿ“š Documentation

Comprehensive guides to help you master MediateX:

Getting Started

Core Features

Advanced Topics

Examples

Check out the samples folder for complete working examples with different DI containers and scenarios.


๐Ÿ™ Acknowledgments

MediateX would not exist without the pioneering work of Jimmy Bogard and the many contributors to the original MediatR project. Their efforts created a robust and battle-tested foundation that has benefited countless .NET developers.

This library began as a fork of MediatR version 12.5.0. We are immensely grateful for their contribution to the .NET ecosystem, which provided the starting point for this new, forward-focused direction. While MediatR continues to serve a broad range of .NET versions, MediateX is our dedicated effort to serve developers who are ready to build exclusively on the future of the platform.

Original Project: MediatR on GitHub

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 903 12/14/2025
2.1.0 661 12/2/2025

v3.0.0 - .NET 10 upgrade, improved DI container compatibility, assembly scanning robustness. v2.1.1 - Enhanced NuGet metadata. v2.1.0 - C# 9-13 modernization.