Skip to content

V12 IRequestPostProcessor, how to write with void return type IRequest? #847

Answered by jbogard
jafin asked this question in Q&A
Discussion options

You must be logged in to vote

I added some notes to the upgrade guide around void requests and behaviors:

https:/jbogard/MediatR/wiki/Migration-Guide-11.x-to-12.0

Short answer - leave your request alone, but you'll need to make your pipelines/processors return Unit. This was to avoid dual pipelines/processors etc:

public class VoidRequest: IRequest {}
public class VoidRequestPostProcessor : IRequestPostProcessor<VoidRequest, Unit> {

    public Task Process(VoidRequest request, Unit response, CancellationToken cancellationToken)
    {
        // do some work, whatever
        return Task.CompletedTask;
    }
}

This works because I also removed the generic constraints on behaviors of where TRequest : IReque…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jafin
Comment options

Answer selected by jafin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants