-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Proposal]: .NET DI council #35999
Comments
I'm curious if this may extend beyond containers that implement the conforming container interface. For example, if there is a hook for a non-conforming container to inject things into an ASP.NET Core controller; and the abstraction now declares |
This doesn't affect non-conforming containers at all. Non-conforming containers work alongside the default implementation of the DI container. |
@tillig The main difference between an adapter and a non-conforming container is that when using an adapter, everything is resolved through the adapter. That includes all the AspNet.Core infrastructure in addition to "user defined" services. With a non-confirming container, the AspNet Core infrastructure is resolved using the default container (MS.DI) while "your code" is resolved through the non-confirming container. So for instance, if the AspNet Core team starts to rely on new functionality in the abstraction for use in the AspNet Core infrastructure, every adapter needs to handle that. |
OK, so if...
...then that's not the stuff we'd we're talking about here. Fair enough. I just remember being somewhat bitten by "we assume registration of services will yield an |
yeah, my guess is that AspNet Core infrastructure relies on this behaviour and that is probably why it is part of the specification. Correct me if I'm wrong (@davidfowl), but I don't think Microsoft is trying to support all possible features, but rather add a few more basic ones that every container supports anyway. Think of it as the |
Sure. I don't mean to ride ASP.NET Core, it's just the most convenient example I can think of at the moment. It seems like from a "required supported features" standpoint it goes both ways:
If we're defining a set of common features that all "sources of injection" (be they conforming or non conforming containers) need to support - that Again, latching onto ASP.NET Core, if a framework-provided base class in a controller class hierarchy requires public class MyController : HttpClientControllerBase
{
public MyController(Func<HttpClient> clientFactory) : base(clientFactory){}
}
public abstract class HttpClientControllerBase
{
public HttpClientControllerBase(Func<HttpClient> clientFactory)
{
// Some value-added controller base class from the framework, but which lives
// in the class hierarchy of application code. This will come from the non-conforming
// container via IControllerActivator, not the IServiceProvider.
}
} From a blinders-on standpoint, saying "containers and lifetime scopes should support
|
That being said, I welcome this council initiative so that we can discuss the abstraction going forward. At the same time I'd like to point out that it is important that we don't raise the bar too high. |
I concur with @seesharper The council should help foster new functionality while still keeping compatibility with existing adapters. @davidfowl is there any president to follow or is this type of thing new ground? |
I suggest SimpleInjector's: @dotnetjunkie |
@Tornhoof that's fine but I guess I should be more clear what this is. I wanted to make the current process a bit more formal but I didn't intend for this to be a design by committee thing. I want to get the opinions of the DI authors to see if we should allow new features into the abstraction since we currently reject every new feature. I haven't thought through how that would work other than tagging people on issues or PRs. |
@davidfowl You asked
I suggested Steven, that's it. No hidden agenda here. |
I welcome the initiative. The abstraction should evolve and new features should not be stopped. Unity already implements both of the features in question, so it would be desirable to keep it compatible with existing implementation, otherwise you have my vote. |
I want to clear up one thing, Microsoft is still going to ultimately decide on what features to include/exclude into the container abstraction. The goal of this is to formalize how we go about evaluating new features and we need to not only consider new container authors that want to implement the abstraction. That's why we should be extremely conservative when looking at new features. For example, |
So an extremely low overhead way to start this. I'm going to make a team on github (if the powers that be allow it) with the people in this group. When new issues or pull requests come up, I'll tag the group to have a discussion about it and we can take it from there. |
@davidfowl Not entirely true, it just doesn't pass the assertion that you get a |
@davidfowl Changed the skipped tests, they don't have to be skipped any more and StashBox fully supports |
If we take |
We might be getting in the weeds a bit if we dive too deep into specific features in this particular issue since it seems like this was more about the formation of the council using those noted items as examples. If there's a GitHub team, maybe we can have some chats there? |
Ok great let’s feel this out with the discussion being on Func<T>. |
Just wanted to emphasise that there might be more than meets the eye even when it comes to adding the simplest feature 😊. |
@davidfowl @danielcweber Yeah, I also noticed those broken tests and thanks for pointing out that not the entire functionality is broken, but Stashbox behaves a bit different. However, that was a glitch in the implementation which I already fixed. I'll release the fix with the next version soon, but first I want to finish some other ongoing developments on it. Thanks for adjusting the tests to make Stashbox pass, this fix won't break the current state of them, just fixed the previous. I also fixed that part recently which caused the open generic related tests to fail, so with the next version, all the skipped tests should pass. |
I haven't forgotten about this 😄 |
Does...does this mean constrained generics might actually make it in? 😍 |
Moving this issue to |
With so many changes to layout of the repositories, could you point me to a suggested way of building and testing latest DI? |
@maryamariyan can you assist? |
Here's the steps you would need to work on runtime repo:
HTH. |
Thank you |
You were so helpful last time, perhaps you could help again? |
@ENikS - check out this document: https://github.com/dotnet/runtime/blob/master/docs/workflow/testing/visualstudio.md If that doesn't work or is unclear - can you open an issue so we can update the docs? |
The idea here is to add some process to how we govern features that go into the DI abstraction by having the authors of dependency injection containers be the gate for new features. The original goal of the abstraction was to support a minimal set of features that most container authors could implement directly or via a small bridge (the initial feature set was designed looking at existing container implementations). Over the last couple of releases, we've had a couple of stalled feature requests because of this:
Currently our stance is that we will not add any more features unless containers that already support the current abstraction continue to work. I'd like to formalize that process a bit more and have container authors that support the MEDIA (Microsoft.Extensons.DependenyInjection.Abstraciton) chime in on what their thoughts are.
Here's my proposal for the initial set of people:
Unity - @ENikS
Autofac - @tillig, @alexmg
LightInject - @seesharper
Lamar, StructureMap - @jeremydmiller
DryIoc - @dadhi
StashBox - @z4kn4fein
Grace - @ipjohnson
Please let me know if I've left somebody out the list here is based on my history of working on this project and having these contributors involved (this it the OG list 😄). This is an open discussion so I don't want to dictate what the process should be (though I have some ideas). Lets try to come up with something concrete based on the following example:
There's a discussion about
Func<T>
. There's a pull request open that seems to pass all the tests. Lets come up with how we would evaluate and accept/reject features like this.The text was updated successfully, but these errors were encountered: