Repository navigation
Introduce IStartup interface - #714
Conversation
|
|
||
| namespace Microsoft.AspNetCore.Hosting | ||
| { | ||
| public abstract class Startup : IStartup |
There was a problem hiding this comment.
Having Startup as the base name is going to be an obnoxious conflict with app's Startup.
|
The code is simpler in a few places, but you've added multiple concepts that we now have to explain to people. E.g. The interface, base class, wrapper classes, incompatible Configuration variations, etc. All told I think this is worse for consumers because it will be much more confusing. We need to choose one pattern or the other. |
That's inaccurate, the main change is simplifying the hosting interface between the hosting and the application layer. The new contract is The new classes are:
I'm going to commit this because it cleans up the hosting code very nicely and doesn't break the existing mechanisms around the Startup pattern. We can figure out how to change the |
|
TBH, we could get rid of the base class and force user code to implement the interface since we already have the convention based startup. |
…d in the hosting container to override any startup logic. `UseStartup` overloads have been changed to detect `IStartup` and directly put it in the container, or to wrapping it with a `ConventionBasedStartup` implementation to preserve the existing behavior. - Remove IStartupLoader and add `IStartup` instead that matches the signature hosting cares about - Moved `UseStartup` to extension methods - Move existing logic into `ConventionBasedStartup` class
09eec65 to
8f5f8d2
Compare
|
@davidfowl do we get real public (i.e. Internal namespace doesn't count) surface to resolve the |
|
@divega If you use the hosting logic then you have everything in the container, otherwise it's no different than what you have today. Today we still support all of the injection etc via ConventionBasedStartup. It's another discussion if we want to stick to the interface only. Also, injection is still supported in the ctor of the |
This change introduces a new service
IStartupthat can be registered in the hosting container to override any startup logic.UseStartupoverloads have been changed to detectIStartupand directly put it in the container, or to wrapping it with aConventionBasedStartupimplementation to preserve the existing behavior.IStartupinstead that matches the signature hosting cares aboutUseStartupto extension methodsConventionBasedStartupclass/cc @Tratcher @JunTaoLuo