Comments (5)
Hello @sorbonad There is an active pull request that fixes the issue.. It might take some time to get merged. Until then, you can implement this workaround:
builder.Services.AddMediatR(config => {
//add this line to filter out handlers that contain generic parameters.
//This will effectively turn off the newly added feature.
config.TypeEvaluator = x => !x.ContainsGenericParameters;
config.RegisterServicesFromAssemblies(assemblies);
});
Or roll back MediatR to the previous version.
from mediatr.
Yes, this is a bug with the new version. I am working on a fix and have just about got it.. However need some input from others in regards to some limits to put on these features.
The issues arise from the new updated support of generic handlers to not support generic requests with more than one type parameter.
The issue is fixed in my local version however this also let's users define too many types which could cause mediatR to hang in service registration as you could understand if there were too many type parameters each with it's own number of types that can close that type parameter.
I'm trying to come up with a solution that will register handlers like your's above and will not let the user essentially soft lock their app when being too vague with parameters. For example, SomeRequestType<T1, T2, T3, etc.. TN>
with no constraints makes it very complex to compute every single possible concrete combination of SomeRequestTypeHandler<SomeRequestType<T1, T2, T3, etc.. TN>>
.
In the meantime a workaround is to:
- revert back to previous version
or - update your add mediator call configuration to provide a type evaluator that will tell mediator to skip trying to register your generic request handlers. (this will not affect your manual registrations)
builder.Services.AddMediatR(config => {
config.TypeEvaluator = x => !x.ContainsGenericParameters;
config.RegisterServicesFromAssemblies(assemblies);
});
by setting up mediatR this way you tell it to only try to register handler types that do not contain generic type parameters. (The default behavior of previous versions)
from mediatr.
Thanks for the reply, for me, the workaround is enough for my needs, so I am closing this issue.
from mediatr.
Hello, the improvement / fix mentioned is something that is going to be released soon or it will take time? thanks
from mediatr.
Alright, thank you @zachpainter77
from mediatr.
Related Issues (20)
- Seperate Interfaces to Contract project to provide abstraction layer HOT 8
- Improve base package readme
- Implement IRequest, how to enter Behavior HOT 1
- IRequestExceptionHandler from other project not loaded
- Question:
- Question: How I can setup MediatR 12.1.0 in Ninject module? HOT 2
- How do I register INotification with generics? HOT 2
- long running INotificationHandler HOT 1
- Question: Can multiple MediatR handlers be packaged into a single class HOT 2
- .NET8 upgrade from .NET Core 2.1 : Command cannot be used as type parameter 'TRequest' for 'IRequestHandler<TRequest>' HOT 3
- Irequest in library and handler in web api project HOT 2
- what use net8 aot publish
- v12.3.0 Breaking Change HOT 13
- Question: Why IRequestExceptionHandler is not catching? HOT 1
- Question: How to register generic requests HOT 6
- Question: Why MediatR does not support ValueTasks ?
- Question: Why MediatR does not support ValueTasks ?
- Generic Handler implementation only handles single generic argument and breaks existing implementations HOT 5
- Validation is not invoked when IRequest has no Result
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mediatr.