-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Corrects the mapping of types to features in ITypeFeatureProvider #15793
Corrects the mapping of types to features in ITypeFeatureProvider #15793
Conversation
/cc @MikeAlhayek @Piedone |
This may substitute #15787. |
@gvkries what actually fixes the issue here? |
It's in the |
@gvkries I think there is two things that should be considered in the solutions.
The only way to really know if a type was added by a startup file, is by calling that start up and then get all the types that were added in the process. I am not sure if this is the best process I think something like this may actually solve the problem of needed
With this approach, only a startup class will need a I am not sure I have time to test out the above approach, but if you are able it, it may worth trying. |
@MikeAlhayek I take a look if I find some more time. But do you think we should work on this at all, or is it too much hassle? |
@gvkries I think we should. But we have to replace existing approach with a better approach. The current solution is to use |
@MikeAlhayek Your solution is almost the same as mine, I only kept the type registration in the |
This is the problem I think we should solve. And with the approach I provides, I am don't think we would need to add additional types to the |
I tried this quickly, but I need to go now, I'll come back to this later. |
Thank for looking into it. maybe we need to investigate why do we need to populate the |
My reasoning was wrong, I only missed some types in the feature provider. Especially all non-DIed-types are of cause not added now, which causes the problem. |
What we build a fake Service Collection in the Extension Manager so we can get the correct mapping and therefore we won't need it in the ShellContainerFactory. |
…lContainerFactory`. Before, that responsibility was split between the `ExtensionManager` and shell container factory.
…kries/OrchardCore into gvkries/di-dependencies-15782
As @MikeAlhayek said, I completely moved populating the Additionally this simplifies the extension manager and moves all usages that needs the feature types to rely on the type feature provider as well. No more duplicated responsibilities between extension manager and type feature provider. Type sharing between multiple features is not considered yet. |
Make sure you do a round of testing to ensure that the types are tied to the correct feature. Before complicating things by associating one type to possibly multiple features |
Yes, I think we should skip that addition for now. |
I am not sure you can. The extension manager uses every feature available (not the features that are associated to the current tenant). This means that if you have a type T that could be registered to feature A and feature B which both features are independent of each other, then the extension manager may assign type T to feature A and never to feature B. Now if you only enable feature B and not A, then the |
Yeah, that is correct. But the current solution is already an improvement. |
Not really. Using the Feature attribute currently gives you the correct mapping no matter what. If we make this change, then Feature attribute will not be honored as we would honer registration. In order for this to be an acceptable solution, I think it has to provide a better replacement to the existing solution. |
No, the current solution does not remove or change the feature attribute at all. Only types not marked with it are now correctly assigned to its feature if it is in the DI container. I was not really thinking of fully replacing the |
…r multiple features.
I have now removed all Especially, the removal of the attribute from some classes that were assigned to the application default feature, i.e. they had a I think this should not break anything, but maybe it is more safe to keep the attribute on those classes that have no specific feature assigned via a startup. |
Yeah, those that had a Feature attribute with a feature different than what they'll get now should rather remain. I have no idea what may depend on them but it's probably safe to assume that something can. |
…e default application feature.
You are right, I added the attribute back to the classes in question. Shouldn't have removed them in the first place. 😇 |
Are you ready for another round of reviews? |
Yes, I try to attend to the meeting tomorrow, if there is one. |
src/OrchardCore/OrchardCore.Abstractions/Extensions/Features/ITypeFeatureProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs
Show resolved
Hide resolved
…TypeFeatureProvider.cs Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
@gvkries during the call, you mentioned there are minor things that you want to do to this PR. Once you are done, I'll do one last final review. |
No sorry, I'm done with this for now. I was just trying to explain that I'm not happy that some types are now assigned to two features by default. But I want to keep it this way, because I'm not sure if I break something if I change that. Basically all types are assigned to a feature that has the same ID as the parent extension. This will be the first feature entry and an additional more specific feature is added afterwards, if there is one. This way calling So please go ahead and check it out 🙈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a documentation in the release notes for awareness
@MikeAlhayek Many thanks! |
Just an idea how to fix #15782. Removing
FeatureEntry
may be overkill, but it is not really required.