You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 15, 2023. It is now read-only.
we might add an attribute to our startup class and call a generated method:
[assembly:AddMediatRRegistrations(typeof(Startup))]publicclassStartup{publicvoidConfigureServices(IServiceCollectionservices){services.AddGenMediatR();// <- method generated by source generators}}
The former has significant and growing runtime costs associated as the complexity of the project increases, whereas the latter would generate a function
and thus not be subject to the for loop over assembliesToScan.SelectMany(a => a.DefinedTypes) multiple times (project I am working on was apparently looping over the defined types of all assemblies in the bin dir nearly 100 times for various libraries it was using).
The text was updated successfully, but these errors were encountered:
heh, yeah I'm looking... probably wouldn't get to it for a while so if anybody else wants to try they are welcome.
I'm not really sure what the best approach is. C#9 source generators are implemented as roslyn analyzers, so in theory this project can be changed to an analyzer dependency instead of a runtime dependency (obviously this is a breaking change). Perhaps it would be better to implement it as a separate nuget package?
Hey, I wondered about this myself, so a while back I created another mediator pattern implementation based on source generation myself: https://github.com/martinothamar/Mediator
There are some differences in API from MediatR but the source generation itself is maybe something to look at for a potential implementation here. It does assembly scanning to generate both DI extension method and the mediator implementation itself. Won't have time get into any PR here atm but posting this just in case someone else is considering it 😄
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It would be nice to change the reflection done here to a compile time dependency. Instead of
we might add an attribute to our startup class and call a generated method:
The former has significant and growing runtime costs associated as the complexity of the project increases, whereas the latter would generate a function
and thus not be subject to the for loop over
assembliesToScan.SelectMany(a => a.DefinedTypes)
multiple times (project I am working on was apparently looping over the defined types of all assemblies in the bin dir nearly 100 times for various libraries it was using).The text was updated successfully, but these errors were encountered: