-
Notifications
You must be signed in to change notification settings - Fork 111
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
Unable to inject Scoped/Transient services into FeatureFilter #15
Comments
Is this different from existing behavior? I wouldn't expect a scoped service to be able to be used in the feature filters which are singletons. This is why things like |
Closing since there has been no response. Please re-open if my response is inadequate. |
I ran into this issue yesterday. I managed to code around it, but it was less than ideal. I ran into two primary issues:
For the first issue, a web project could inject I could have passed the user object into the feature manager method as a context, but then the calling code would need to know that the configured feature filters would need to act on the current user, and I don't believe that's a good idea. For the second issue, I ended up injecting Both of these could have been avoided if the registered feature filters were not singletons (either scoped or transient would have sufficed). The code-base seems pretty straight forward, but I don't want to make any bad assumptions. If you can give me some general direction (or at least tell me what you are trying to avoid), I can work on a PR to allow feature filters to not necessarily be singleton. |
I am hitting this too. I wish it could depend on a scoped ISessionManager. |
This issue should be re-opened. @jimmyca15 @cbrianball @szalapski |
Update: Now, we provide AddScopedFeatureManagement() method which will register FeatureManager and feature filters as scoped services. In this way, you can inject scoped services into feature filters. Also, we expose FeatureManager to public, you can also register the feature management system as transient by yourself. |
Fixed in release 3.1.0 |
In.NET Core 3.0 DI scope validation is enabled by default.
Application throws an exception that it is not possible to resolve service that is Scoped/Transient .
Cannot consume scoped service 'Common.Services.IRequestDataProvider' from singleton 'Microsoft.FeatureManagement.IFeatureFilter'
The text was updated successfully, but these errors were encountered: