{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/DependencyInjection/issues/334","repository_url":"https://api.github.com/repos/aspnet/DependencyInjection","labels_url":"https://api.github.com/repos/aspnet/DependencyInjection/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/DependencyInjection/issues/334/comments","events_url":"https://api.github.com/repos/aspnet/DependencyInjection/issues/334/events","html_url":"https://github.com/aspnet/DependencyInjection/issues/334","id":120372278,"number":334,"title":"Ambient scopes not supported by all DI's","user":{"login":"pauldotknopf","id":523150,"avatar_url":"https://avatars2.githubusercontent.com/u/523150?v=3","gravatar_id":"","url":"https://api.github.com/users/pauldotknopf","html_url":"https://github.com/pauldotknopf","followers_url":"https://api.github.com/users/pauldotknopf/followers","following_url":"https://api.github.com/users/pauldotknopf/following{/other_user}","gists_url":"https://api.github.com/users/pauldotknopf/gists{/gist_id}","starred_url":"https://api.github.com/users/pauldotknopf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pauldotknopf/subscriptions","organizations_url":"https://api.github.com/users/pauldotknopf/orgs","repos_url":"https://api.github.com/users/pauldotknopf/repos","events_url":"https://api.github.com/users/pauldotknopf/events{/privacy}","received_events_url":"https://api.github.com/users/pauldotknopf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/aspnet/DependencyInjection/milestones/11","html_url":"https://github.com/aspnet/DependencyInjection/milestone/11","labels_url":"https://api.github.com/repos/aspnet/DependencyInjection/milestones/11/labels","id":870454,"number":11,"title":"Backlog","description":null,"creator":{"login":"glennc","id":234688,"avatar_url":"https://avatars0.githubusercontent.com/u/234688?v=3","gravatar_id":"","url":"https://api.github.com/users/glennc","html_url":"https://github.com/glennc","followers_url":"https://api.github.com/users/glennc/followers","following_url":"https://api.github.com/users/glennc/following{/other_user}","gists_url":"https://api.github.com/users/glennc/gists{/gist_id}","starred_url":"https://api.github.com/users/glennc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennc/subscriptions","organizations_url":"https://api.github.com/users/glennc/orgs","repos_url":"https://api.github.com/users/glennc/repos","events_url":"https://api.github.com/users/glennc/events{/privacy}","received_events_url":"https://api.github.com/users/glennc/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":11,"state":"open","created_at":"2014-11-18T00:37:53Z","updated_at":"2017-02-19T23:57:17Z","due_on":null,"closed_at":null},"comments":20,"created_at":"2015-12-04T10:18:35Z","updated_at":"2017-02-28T17:51:44Z","closed_at":"2017-02-19T17:57:00Z","body":"So, I'm having a discussion with @dotnetjunkie about implementing a dnx adapter for SimpleInjector (https://github.com/simpleinjector/SimpleInjector/issues/156).\n\nHe is not a fan of implementing an abstraction, it is a conforming container anti-pattern. I've argued that if he doesn't create a dnx adapater, SimpleInjector will simply not be a choice with users when doing ASP.NET 5 projects. I believe (and he can correct me if I am wrong) that the ultimate issue comes down to [Microsoft's use of ambient scopes](https://github.com/aspnet/DependencyInjection/blob/8a43c6eb6c57abad34d8185ab4412b738a51096f/src/Microsoft.Extensions.DependencyInjection.Specification.Tests/DependencyInjectionSpecificationTests.cs#L313).\n\nSo, my question is this. When thinking of the common denominator of features between containers, is this actually needed?\n\nWithin the ASP.NET stack, are scopes only used within the context of web requests?\n\nWhat about adding two kinds of scopes:\n- Local/ambiant - Requires a reference to the actual `IServiceScope` to resolve a service. This is how the ASP.NET DI currently does it.\n- Global/non-ambiant - The scope is determined in the container itself. It internally checks HttpContext.Current, or something similar. Maybe it could simply be called a \"WebRequestScope\", hard coding it, if abstracting it across DI's becomes an issue.\n\nIf the ASP.NET request pipeline is currently the _only_ thing using scopes, maybe it can be changed to use global scopes, leaving the local approach in-tact, but just not used. If we do this, SimpleInjector can support web requests, while explicitly declaring that they do not support local scopes. The maintainer of SimpleInjector doesn't have any intention of ever supporting local scopes, and it could simply be a known limitation of using a SimpleInjector dnx adapter. Of course, provided that the core libraries for ASP.NET don't depend on any local scopes. We don't want the SimpleInjector dnx adapter to be broke out-of-the-box.\n\nAny thoughts? I don't think @dotnetjunkie is budging ;) SimpleInjector is one of the fastest DI's, and it will break my heart to see it not supported.\n"},"comment":{"url":"https://api.github.com/repos/aspnet/DependencyInjection/issues/comments/283113848","html_url":"https://github.com/aspnet/DependencyInjection/issues/334#issuecomment-283113848","issue_url":"https://api.github.com/repos/aspnet/DependencyInjection/issues/334","id":283113848,"user":{"login":"davidfowl","id":95136,"avatar_url":"https://avatars0.githubusercontent.com/u/95136?v=3","gravatar_id":"","url":"https://api.github.com/users/davidfowl","html_url":"https://github.com/davidfowl","followers_url":"https://api.github.com/users/davidfowl/followers","following_url":"https://api.github.com/users/davidfowl/following{/other_user}","gists_url":"https://api.github.com/users/davidfowl/gists{/gist_id}","starred_url":"https://api.github.com/users/davidfowl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidfowl/subscriptions","organizations_url":"https://api.github.com/users/davidfowl/orgs","repos_url":"https://api.github.com/users/davidfowl/repos","events_url":"https://api.github.com/users/davidfowl/events{/privacy}","received_events_url":"https://api.github.com/users/davidfowl/received_events","type":"User","site_admin":false},"created_at":"2017-02-28T17:51:44Z","updated_at":"2017-02-28T17:51:44Z","body":"> I’m having a hard time imagining concrete cases where access to a different scope is needed. Can you give some concrete example where access to a different scope is a necessity?\r\n\r\nAnywhere that needs to call `GetService` aka in the composition root. Good framework usually do this for you, somewhere so you don't have to do it yourself. \r\n\r\nhttps://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting/Internal/RequestServicesFeature.cs#L30\r\n\r\nhttps://github.com/aspnet/SignalR/blob/dev/src/Microsoft.AspNetCore.SignalR/HubEndPoint.cs#L91\r\n\r\nhttps://github.com/OrchardCMS/Orchard2/blob/85c9f7ecf1ca11dd58a1c58f92345d370e725889/src/Orchard.Environment.Shell.Abstractions/Builders/ShellContext.cs#L30\r\n\r\nhttps://github.com/OrchardCMS/Orchard2/blob/982e149ff5e6e10e6e3af5725619754654adfb03/src/Orchard.Environment.Shell/Builders/ShellContainerFactory.cs#L137\r\n"}}
{"actor":{"display_login":"davidfowl"}}