-
Notifications
You must be signed in to change notification settings - Fork 313
Interface to formalize how tooling obtains the application's service provider #524
Comments
I don't see what this has to do with DI. Are we just looking for a place to put an interface? |
Sure, where should we put it? |
Honestly, I don't understand what this solves... Are we going to have shared code that calls into this interface or something? |
Not necessarily, but yes we could. As the title says and hopefully the description explains this interface formalizes the convention that tools need to implement in order to obtain the application's service provider at design time. E.g. instead of having to fake a host and instantiate The main affinity with DI is that it is about obtaining the |
It is an interesting idea for Universal apps as well. There is always the problem of being unable to instantiate ViewModels at design time which have constructor arguments that are meant to come from DI at runtime. Everybody goes about crafting a solution, and they aren't always pretty. Sometimes they're awful. This isn't about 'tooling' per se, not in the .NET Core sense, but how cool would it be if XDesProc could use this? Well, phase one would be me using this with if (DesignModeEnabled)... |
@divega @davidfowl @ajcvickers @DamianEdwards @muratg @bricelam - what is the status of this? We met last week, and I thought maybe we arrived at a conclusion, but I don't recall the concrete next steps. Whatever we decide, we should try to get it in this week. |
@Eilon Diego, Brice, and I talked about it a little while ago. Brice is going to send some pull requests and we will take it from there. |
Can you comment a bit on bringing some UI folks onboard? Xamarin, UWP? Is this something you see benefit in? Or should I raise this issue in a few other places? |
@ericwj It's worth raising in the respective places. I think it's a little less interesting with MVVM because most people probably aren't using |
No, not today, but behold, .NET Standard is coming. I don't think there is mention of a date for UWP to arrive at 2.0, but once it's there, it'll make quite an impact I'm sure. Sharing basics like this just removes friction and making switching project types less of a culture shock. And it'd be opt in anyway I'm sure... I've tried to find a suitable repo for XAML, but I couldn't really find one. Can you direct me somewhere, or should I use |
VS Feedback would be a good place to start. Maybe dotnet/project-system would also get the right people looking at it. |
And Xamarin? They don't have issues. Only pull requests 🥇 |
Sorry, no idea on that one |
TY anyway, I'll get there |
Provides access to the application's IServiceProvider to design-time services. Resolves #524
Clearing up milestone so that this can be re-triaged. We are not planning to do it for 2.0.0. Also some relevant comments in the conversation on the PR: #527 (comment). |
@divega What milestone should this go in? 2.2 or backlog? |
@muratg I think it is fine for this to be in the backlog. It still seems nice and from time to time we hear from people that want something that works with DI without ASP.NET Core and without going all the way down to Cc @bricelam and @ajcvickers in case they think we should plan to have it sooner. |
This issue was moved to dotnet/aspnetcore#2342 |
This a more general purpose alternative to the feature described in dotnet/efcore#8331.
Currently tools that require access to the application's runtime services and configuration (e.g. EF Core tools, ASP.NET Core Scaffolding, possibly Razor tooling and others) need to hardcode heuristics which
Startup.ConfigureServices()
in ASP.NET Core 1.0,Program.BuildWebHost()
in ASP.NET Core 2.0, etc.)IDbContextFactory
in EF) if the convention is not matchedThis issue is about defining a common accessor interface that tooling can scan for at design time which provides access to the application's service provider. We believe this approach:
Program.BuildWebHost(args).Services
. If the mechanism changes in the future, the template can be updatedDbContext
registered withAddDbContext
regardless of their location, makingIDbContextFactory
unnecessary for most common casesExample:
Open issues:
cc @bricelam @ajcvickers @DamianEdwards @davidfowl
The text was updated successfully, but these errors were encountered: