{"action":"created","issue":{"url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19","repository_url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection","labels_url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19/comments","events_url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19/events","html_url":"https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19","id":196960874,"node_id":"MDU6SXNzdWUxOTY5NjA4NzQ=","number":19,"title":"Can't resolve some controller parameters if scanning in the registry","user":{"login":"mcliment","id":63848,"node_id":"MDQ6VXNlcjYzODQ4","avatar_url":"https://avatars3.githubusercontent.com/u/63848?v=4","gravatar_id":"","url":"https://api.github.com/users/mcliment","html_url":"https://github.com/mcliment","followers_url":"https://api.github.com/users/mcliment/followers","following_url":"https://api.github.com/users/mcliment/following{/other_user}","gists_url":"https://api.github.com/users/mcliment/gists{/gist_id}","starred_url":"https://api.github.com/users/mcliment/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcliment/subscriptions","organizations_url":"https://api.github.com/users/mcliment/orgs","repos_url":"https://api.github.com/users/mcliment/repos","events_url":"https://api.github.com/users/mcliment/events{/privacy}","received_events_url":"https://api.github.com/users/mcliment/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2016-12-21T15:30:59Z","updated_at":"2018-07-05T16:33:45Z","closed_at":null,"author_association":"NONE","body":"When scanning for things in the registry, some types can't be resolved in the controller constructor (in the case of the example IOptions<T> but I don't think it's exclusive to this type).\r\n\r\nI have pushed some code to reproduce the issue:\r\nhttps://github.com/mcliment/StructureMap.Microsoft.DependencyInjection/tree/issue-demo\r\n\r\nTo reproduce, run the sample site and go to `/Bad`. This should throw an exception because the type `IOptions<MySettings>` can't be resolved. Then go to `/Good` and should work, loading the same type through a wrapper. Then \"/Bad\" works perfectly.\r\n\r\nThe thing it that `TryGetInstance` can't resolve the type the first time (`GetInstance` works properly).\r\n\r\nIf the `registry.Scan` is removed from `ConfigureContainer` and the type `MySettingsWrapper` is added as `services.AddTransient<IMySettingsWrapper, MySettingsWrapper>();` then `/Bad` works the first time.\r\n\r\nAs well, if the Scan has the clause `a.Exclude(t -> true);` instead of the `Include(...)` also works the first time."},"comment":{"url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection/issues/comments/402781069","html_url":"https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19#issuecomment-402781069","issue_url":"https://api.github.com/repos/structuremap/StructureMap.Microsoft.DependencyInjection/issues/19","id":402781069,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjc4MTA2OQ==","user":{"login":"jeremyZX","id":634106,"node_id":"MDQ6VXNlcjYzNDEwNg==","avatar_url":"https://avatars3.githubusercontent.com/u/634106?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremyZX","html_url":"https://github.com/jeremyZX","followers_url":"https://api.github.com/users/jeremyZX/followers","following_url":"https://api.github.com/users/jeremyZX/following{/other_user}","gists_url":"https://api.github.com/users/jeremyZX/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyZX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyZX/subscriptions","organizations_url":"https://api.github.com/users/jeremyZX/orgs","repos_url":"https://api.github.com/users/jeremyZX/repos","events_url":"https://api.github.com/users/jeremyZX/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyZX/received_events","type":"User","site_admin":false},"created_at":"2018-07-05T16:33:45Z","updated_at":"2018-07-05T16:33:45Z","author_association":"NONE","body":"@khellang @jeremydmiller  \r\nWhy is the SM Service provider choosing to call Container.TryGetInstance vs  Container.GetInstance at all?  Or why isn't the behavior configurable?  I don't think an analogy of GetService/TryGetInstance vs GetRequiredService/GetInstance holds up.  As @jeremydmiller mentions, the behavior changes substantially beyond returning null (TryGetInstance's behavior) vs. throwing an exception (GetInstance's behavior.)\r\n\r\nWe've historically had to work around this issue with a custom fork of StructureMap.Microsoft.DependencyInjection.  Ideally, we'd like to shelve that fork; but short of playing wack-a-mole with missing family policies to cover the gap between TryGetInstance vs GetInstance when upstream code is insistent on calling the former, I don't see a resolution."}}
{"actor":{"display_login":"jeremyZX"}}