{"action":"created","issue":{"url":"https://api.github.com/repos/Smudge202/Compose/issues/49","labels_url":"https://api.github.com/repos/Smudge202/Compose/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/Smudge202/Compose/issues/49/comments","events_url":"https://api.github.com/repos/Smudge202/Compose/issues/49/events","html_url":"https://github.com/Smudge202/Compose/issues/49","id":69115524,"number":49,"title":"Extensions specify dependency contracts","user":{"login":"Smudge202","id":2247869,"avatar_url":"https://avatars.githubusercontent.com/u/2247869?v=3","gravatar_id":"","url":"https://api.github.com/users/Smudge202","html_url":"https://github.com/Smudge202","followers_url":"https://api.github.com/users/Smudge202/followers","following_url":"https://api.github.com/users/Smudge202/following{/other_user}","gists_url":"https://api.github.com/users/Smudge202/gists{/gist_id}","starred_url":"https://api.github.com/users/Smudge202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Smudge202/subscriptions","organizations_url":"https://api.github.com/users/Smudge202/orgs","repos_url":"https://api.github.com/users/Smudge202/repos","events_url":"https://api.github.com/users/Smudge202/events{/privacy}","received_events_url":"https://api.github.com/users/Smudge202/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Smudge202/Compose/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-17T10:50:07Z","updated_at":"2015-04-17T10:56:57Z","closed_at":null,"body":"This possibly relates/resolves #44.\r\n\r\nWhen adding a service extension, more complex services will likely depend on other services.  Similarly, if an application extension author can decide not to add default implementations of services on which it depends.\r\n\r\nIn both cases, it would be useful for the extension author(s) to be able to provide user friendly messages explaining to the host author which services need to be added.  In order to do this, I propose that we provide a _contract API_ which would work in the following way (potentially / as an example):\r\n\r\n\r\n###Application Extension\r\n```c#\r\npublic static void UseMyApplication(this Executable app)\r\n{\r\n  app.Requires<IDependency1>();\r\n  app.Requires<IDependency2>(\"friendly name\");\r\n  // ... OnExecute code\r\n}\r\n```\r\n\r\n###Service Extension\r\n```c#\r\npublic static void AddMyService(this IServiceCollection services, IConfiguration config = null)\r\n{\r\n  services.AddTransient<IMyService, ServiceImplementation>()\r\n    .Requires<IDependency>();\r\n  // min this example, Compose would realise IDependency is required by ServiceImplementation\r\n  // not by IMyService (which could have the implementation overriden by the Host/App)\r\n}\r\n```\r\n\r\nIf the Host does not provide a service in which the application has specified a requirement, even though an exception would have been thrown by the underlying IServiceProvider when attempting to build up the application, instead Compose will validate the composition beforehand and throw a more user friendly exception stating that the given service is required by _x_.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/Smudge202/Compose/issues/comments/93964446","html_url":"https://github.com/Smudge202/Compose/issues/49#issuecomment-93964446","issue_url":"https://api.github.com/repos/Smudge202/Compose/issues/49","id":93964446,"user":{"login":"sblackler","id":775191,"avatar_url":"https://avatars.githubusercontent.com/u/775191?v=3","gravatar_id":"","url":"https://api.github.com/users/sblackler","html_url":"https://github.com/sblackler","followers_url":"https://api.github.com/users/sblackler/followers","following_url":"https://api.github.com/users/sblackler/following{/other_user}","gists_url":"https://api.github.com/users/sblackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sblackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sblackler/subscriptions","organizations_url":"https://api.github.com/users/sblackler/orgs","repos_url":"https://api.github.com/users/sblackler/repos","events_url":"https://api.github.com/users/sblackler/events{/privacy}","received_events_url":"https://api.github.com/users/sblackler/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T10:56:57Z","updated_at":"2015-04-17T10:56:57Z","body":"I think it's far more preferable to have a composition exception up front rather than leaving it to the provider. How would this work during a transition, eg: switching out IMyService at runtime"}}