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
base: main
Are you sure you want to change the base?
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 |
I've changed the |
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.
Sorry that I didnt join earlier. I'm still trying to understand this, but great discussion and work! It was quite a ride to go through all of this :).
Would you be able to join the Thursday triage meeting (https://docs.orchardcore.net/en/latest/resources/meeting/) and present this? We need a group consultation.
I think this approach is good, but I need to put more time into it.
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.
SecureMediaPermissions
need to be adjusted too if this will be merged.
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.
Not necessarily, applying the feature attribute should still be possible and the behavior should not be changed by this PR.
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.
While it will work, it'll have an unnecessary attribute.
@@ -9,7 +10,8 @@ namespace OrchardCore.Environment.Extensions | |||
/// </summary> | |||
public interface ITypeFeatureProvider | |||
{ | |||
IFeatureInfo GetFeatureForDependency(Type dependency); | |||
IEnumerable<IFeatureInfo> GetFeaturesForDependency(Type dependency); |
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.
Perhaps having a GetExtensionForDependency()
would make the intent clearer for the consumers that only need that but now do First()
.
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.
Yes, that is a valid idea. But maybe we should review the responsibilities of ITypeFeatureProvider
and IExtensionManager
completely, there is some overlapping.
This pull request has merge conflicts. Please resolve those before requesting a review. |
I think I am able to join next week. |
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
That would be great, thank you! |
I couldn't take part today, but did you in the end? |
No, sorry. I was talking about this week, so next Thursday 👍 |
OK, I'll try to take part too. |
Just an idea how to fix #15782. Removing
FeatureEntry
may be overkill, but it is not really required.