Skip to content

Replace MediatR with source-generated Mediator across application and tests#1406

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/replace-mediatr-with-mediator
Open

Replace MediatR with source-generated Mediator across application and tests#1406
Copilot wants to merge 3 commits into
mainfrom
copilot/replace-mediatr-with-mediator

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

This issue replaces runtime MediatR wiring with source-generated Mediator. The change updates dependencies and mediator integration points so command/query/notification flow uses Mediator abstractions and generated registrations.

  • Dependency migration

    • Replaced MediatR package usage with:
      • Mediator.Abstractions
      • Mediator.SourceGenerator (host project)
    • Updated central package management in Directory.Packages.props accordingly.
  • Mediator API and namespace transition

    • Swapped using MediatR; to using Mediator; in core, infrastructure, web, and functional test code paths.
    • Kept existing mediator interaction patterns (Send, Publish) while moving to Mediator interfaces.
  • DI registration update (source-generated setup)

    • Replaced AddMediatR(...) with AddMediator(...).
    • Configured explicit assemblies for handler/message discovery to align with source generation.
  • Infrastructure naming alignment

    • Renamed domain event dispatcher from MediatRDomainEventDispatcher to MediatorDomainEventDispatcher.
    • Updated DI registration to use renamed implementation.

Example of the new registration pattern:

builder.Services.AddMediator(options =>
{
	options.Assemblies =
	[
		typeof(IAggregateRoot),
		typeof(AppDbContext),
		typeof(Program)
	];
});

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.cdnjs.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test tests/DevBetterWeb.FunctionalTests/DevBetterWeb.FunctionalTests.csproj --filter FullyQualifiedName~NoOpMediator (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 12, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Replace MediatR with generated Mediator implementation Replace MediatR with source-generated Mediator across application and tests May 12, 2026
Copilot AI requested a review from ardalis May 12, 2026 00:54
@ardalis ardalis marked this pull request as ready for review May 12, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace MediatR with Mediator source generated

2 participants