-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ability to use existing startup registrations. #83
Comments
Unfortunately supporting the dynamic addition syntax is really hard as the resulting set of services depends on the result of runtime calls. Take the following example: public static void AddXYZ(this IServiceCollection services)
{
if (environment.IsDevelopment())
{
services.AddScoped<IChatProvider, ChatProvider>();
)
else
{
services.AddScoped<IChatProvider, ChatProvider>();
}
} Which service should be code generated? And this is one of the simpler patterns used in |
Hhm. Didn't really think about such scenario. |
Having more than one container / service providers has issues with scoping because for example Jab would control instances of scoped and singleton services which IServiceProvider wouldn't be able to resolve. So as soon as you resolved a service from IServiceProvider, everything in the tree from that point would be controlled by the runtime controller. And if any of those resolved services tried to inject a scoped service that Jab had resolved, IServiceProvider would create a new one. |
In a number of existing application, people already have this.
Rather than forcing one to put attribute on tons of classes. I would love the generator to be able to read this existing registration from code and infer registrations from it. This would save a lot of code edits. Of course one may have to decorate the static registration class itself with an attribute so the generator can find it.
If you are open to this idea, I'd love to contribute.
Great software BTW.
The text was updated successfully, but these errors were encountered: