Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

ApplicationPart should be a feature collection #4760

Closed
davidfowl opened this issue May 27, 2016 · 9 comments
Closed

ApplicationPart should be a feature collection #4760

davidfowl opened this issue May 27, 2016 · 9 comments

Comments

@davidfowl
Copy link
Member

davidfowl commented May 27, 2016

Today ApplicationPart need to implement interfaces in order for the feature provider to interact with the part. This means that parts cannot be extended without making a new derived one. Instead, ApplicationPart should be a feature collection so that new interfaces can be added/removed from existing parts.

It will allow people to extend AssemblyPart for example without making a new derived type.

/cc @javiercn @rynowak @Eilon @pranavkm

@Eilon Eilon added this to the 1.0.1 milestone May 27, 2016
@rynowak
Copy link
Member

rynowak commented Jun 3, 2016

I like this, but is this something we'd do in 1.0.1? This seems breaking changey

@davidfowl
Copy link
Member Author

Yea, we can talk about it some more after 1.0.0

@rynowak
Copy link
Member

rynowak commented Jun 13, 2016

I can actually think of a way we can do this without breaking changes. Add the feature collection, and then have a default implementation on ApplicationPart (which is an ABC) that does a cast to the existing feature interfaces.

@pranavkm
Copy link
Contributor

How does the user apply a feature to all parts - ones already in the part manager and ones that are added later? e.g.

foreach (var part in partManager.Parts.OfType<AssemblyPart>())
{
   part.Features.Set<ITestFeature>(foo);
}

partManager.Parts.Add(new AssemblyPart(..)); <-- How do I ensure this part also has the feature?

@javiercn
Copy link
Member

@pranavkm the order in which you call things during startup is important. You add parts first then you create features.

@pranavkm
Copy link
Contributor

Sure, but it makes it much harder to compose it. For instance, we wouldn't be able to light up the the ICanHazViewsFeature on AssemblyPart as part of registering Razor the way we register FeatureProviders today. (https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs#L64 bit).

@javiercn
Copy link
Member

@pranavkm let's talk offline

@pranavkm
Copy link
Contributor

pranavkm commented Sep 9, 2016

Discussed this offline and here's what we have:

We decided the current model of creating parts doesn't lend itself to a feature collection model. The guidance would be

  1. Use broad interfaces like IApplicationPartTypeProvider, ICompilationReferencesProvider. We should add additional interfaces like IResourcesProvider etc to make feature light up such as embedded views.
  2. Use an IFeatureProvider that downcasts when these interfaces aren’t sufficient. For instance, precompiled view discovery would work this way. We’ll remove IViewsProvider and associated types from Mvc.Core.

@pranavkm
Copy link
Contributor

We don't have any immediate work scheduled for this. Closing this for now and we can track the embedded view work via #5144.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants