OpenMediatR 0.0.4-alpha

This is a prerelease version of OpenMediatR.
dotnet add package OpenMediatR --version 0.0.4-alpha
                    
NuGet\Install-Package OpenMediatR -Version 0.0.4-alpha
                    
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="OpenMediatR" Version="0.0.4-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenMediatR" Version="0.0.4-alpha" />
                    
Directory.Packages.props
<PackageReference Include="OpenMediatR" />
                    
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 OpenMediatR --version 0.0.4-alpha
                    
#r "nuget: OpenMediatR, 0.0.4-alpha"
                    
#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 OpenMediatR@0.0.4-alpha
                    
#: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=OpenMediatR&version=0.0.4-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OpenMediatR&version=0.0.4-alpha&prerelease
                    
Install as a Cake Tool

OpenMediatR

OpenMediatR is a lightweight, open-source alternative to the popular MediatR library. It provides simple in-process messaging with support for IRequest/IRequestHandler and INotification/INotificationHandler patterns, aiming for clarity, minimalism, and zero external dependencies.

⚠️ Preview Version: This is version 0.0.2, an early preview release intended for testing and feedback. APIs and structure may change.

OpenMediatR


🧩 Why "OpenMediatR"?

Because messaging should be simple, open, and yours to control — without magic, and without cost.


✨ Features

  • ✅ Clean, minimal abstraction layer
  • ✅ Zero external dependencies
  • ✅ Simple integration with .NET DI
  • ✅ Clear separation of contracts and implementation
  • ✅ Unit-test friendly architecture
  • ✅ Familiar IRequest, IRequestHandler, and ISender patterns

🧠 How It Works

Requests

// Define a request
public class Ping : IRequest<string> { }

// Implement a handler
public class PingHandler : IRequestHandler<Ping, string>
{
    public Task<string> Handle(Ping request, CancellationToken cancellationToken)
        => Task.FromResult("Pong");
}

Notifications

// Define a notification
public class Alert : INotification
{
    public string Message { get; set; }
}

// Implement a handler
public class AlertHandler : INotificationHandler<Alert>
{
    public Task Handle(Alert notification, CancellationToken cancellationToken)
    {
        Console.WriteLine(notification.Message);
        return Task.CompletedTask;
    }
}

Dispatching

public class SomeService
{
    private readonly ISender _sender;
    private readonly IPublisher _publisher;

    public SomeService(ISender sender, IPublisher publisher)
    {
        _sender = sender;
        _publisher = publisher;
    }

    public async Task Run()
    {
        var response = await _sender.Send(new Ping());
        Console.WriteLine(response); // "Pong"

        await _publisher.Publish(new Alert { Message = "Something happened!" });
    }
}

📌 Roadmap

  • Notification support (INotification)
  • Pipeline behaviors (IPipelineBehaviuor<,>)
  • Request validators (IRequestValidator<>)
  • Custom behaviors and decorators
  • NuGet packaging and CI/CD
  • Performance benchmarks

🤝 Contributing

OpenMediatR is in its infancy — contributions, ideas, and issues are all welcome! Feel free to fork, raise issues, or suggest enhancements.


📄 License

This project is licensed under the Apache License 2.0.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
0.0.4-alpha 211 7/19/2025
0.0.3-alpha 390 7/19/2025 0.0.3-alpha is deprecated because it has critical bugs.
0.0.2-alpha 46 7/18/2025
0.0.1-alpha 47 7/18/2025