Skip to content

Fix Mediator v3 interface breaking changes: ValueTask return types and source generator leak - #1446

Draft
ardalis with Copilot wants to merge 2 commits into
copilot/replace-mediatr-with-mediatorfrom
copilot/fix-copilot-issue
Draft

Fix Mediator v3 interface breaking changes: ValueTask return types and source generator leak#1446
ardalis with Copilot wants to merge 2 commits into
copilot/replace-mediatr-with-mediatorfrom
copilot/fix-copilot-issue

Conversation

Copilot AI commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

CI failing due to two distinct breakages from Mediator v3.0.2 adoption.

NoOpMediator interface mismatch (CS0535, CS0738)

Mediator v3 changed IMediator/ISender/IPublisher to use ValueTask instead of Task, added ICommand<T>/IQuery<T> overloads to ISender, and removed Send<TRequest>(TRequest) where TRequest : IRequest. Updated NoOpMediator to match:

// Before
public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, ...) => Task.FromResult<TResponse>(default);
public Task Publish(object notification, ...) => Task.CompletedTask;

// After
public ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, ...) => ValueTask.FromResult<TResponse>(default!);
public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> request, ...) => ValueTask.FromResult<TResponse>(default!);
public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> request, ...) => ValueTask.FromResult<TResponse>(default!);
public ValueTask Publish(object notification, ...) => ValueTask.CompletedTask;

Mediator.SourceGenerator transitive leak (CS0436)

Mediator.SourceGenerator in DevBetterWeb.Web.csproj lacked PrivateAssets>all, causing the source generator to run in every test project referencing Web. This re-generated AssemblyReference, MediatorOptions, and Mediator types that conflicted with those already compiled into the Web assembly.

<!-- Before -->
<PackageReference Include="Mediator.SourceGenerator" />

<!-- After -->
<PackageReference Include="Mediator.SourceGenerator">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

Copilot AI changed the title [WIP] Fix issue with Copilot functionality Fix Mediator v3 interface breaking changes: ValueTask return types and source generator leak Aug 2, 2026
Copilot AI requested a review from ardalis August 2, 2026 22:24
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.

2 participants