{"action":"created","issue":{"url":"https://api.github.com/repos/khellang/Scrutor/issues/65","repository_url":"https://api.github.com/repos/khellang/Scrutor","labels_url":"https://api.github.com/repos/khellang/Scrutor/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/khellang/Scrutor/issues/65/comments","events_url":"https://api.github.com/repos/khellang/Scrutor/issues/65/events","html_url":"https://github.com/khellang/Scrutor/issues/65","id":375773486,"node_id":"MDU6SXNzdWUzNzU3NzM0ODY=","number":65,"title":"AsImplementedInterfaces() registering too much","user":{"login":"danspam","id":239976,"node_id":"MDQ6VXNlcjIzOTk3Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/239976?v=4","gravatar_id":"","url":"https://api.github.com/users/danspam","html_url":"https://github.com/danspam","followers_url":"https://api.github.com/users/danspam/followers","following_url":"https://api.github.com/users/danspam/following{/other_user}","gists_url":"https://api.github.com/users/danspam/gists{/gist_id}","starred_url":"https://api.github.com/users/danspam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danspam/subscriptions","organizations_url":"https://api.github.com/users/danspam/orgs","repos_url":"https://api.github.com/users/danspam/repos","events_url":"https://api.github.com/users/danspam/events{/privacy}","received_events_url":"https://api.github.com/users/danspam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-31T02:37:18Z","updated_at":"2018-10-31T08:13:44Z","closed_at":null,"author_association":"NONE","body":"I understand that AsImplementedInterfaces() registers *all* implemented interfaces, however this is sometimes too much. Take for instance, the FluentValidation library, you may scan with the following:\r\n\r\n`.AddClasses(c => c.AssignableTo(typeof(IValidator<>))).AsImplementedInterfaces()`\r\n\r\nThis will pickup all the `AbstractValidator<T>` implementations you have, but this class implements the following interfaces:\r\n```\r\nIValidator<T>\r\nIEnumerable\r\nIEnumerable<IValidationRule>\r\nIValidator\r\n```\r\n\r\nWhich means you get entries for all of these, not just the desired `IValidator<T>` and I need to do the following to get rid of the superfluous entries:\r\n\r\n```\r\nservices.RemoveAll<IValidator>();\r\nservices.RemoveAll<IEnumerable>();\r\nservices.RemoveAll<IEnumerable<IValidationRule>>();\r\n```\r\n\r\nIs there any way to do this without having to remove the extra entries afterwards? "},"comment":{"url":"https://api.github.com/repos/khellang/Scrutor/issues/comments/434597716","html_url":"https://github.com/khellang/Scrutor/issues/65#issuecomment-434597716","issue_url":"https://api.github.com/repos/khellang/Scrutor/issues/65","id":434597716,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDU5NzcxNg==","user":{"login":"khellang","id":582487,"node_id":"MDQ6VXNlcjU4MjQ4Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/582487?v=4","gravatar_id":"","url":"https://api.github.com/users/khellang","html_url":"https://github.com/khellang","followers_url":"https://api.github.com/users/khellang/followers","following_url":"https://api.github.com/users/khellang/following{/other_user}","gists_url":"https://api.github.com/users/khellang/gists{/gist_id}","starred_url":"https://api.github.com/users/khellang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khellang/subscriptions","organizations_url":"https://api.github.com/users/khellang/orgs","repos_url":"https://api.github.com/users/khellang/repos","events_url":"https://api.github.com/users/khellang/events{/privacy}","received_events_url":"https://api.github.com/users/khellang/received_events","type":"User","site_admin":false},"created_at":"2018-10-31T08:13:44Z","updated_at":"2018-10-31T08:13:44Z","author_association":"OWNER","body":"> Is there any way to do this without having to remove the extra entries afterwards?\r\n\r\nNot really. You either have to filter them out using a custom implementation of `AsImplementedInterfaces` (it's pretty straight forward):\r\n\r\nhttps://github.com/khellang/Scrutor/blob/4bb8ff4d3f936e02f11d9ebcabc68bd424728411/src/Scrutor/ServiceTypeSelector.cs#L50-L55\r\n\r\nOr remove the extra entries like you're already doing. I guess we could look at automatically filtering out `IEnumerable` interfaces as those doesn't make much sense to register. The problem is that it would be a breaking change."}}
{"actor":{"display_login":"khellang"}}