{"action":"closed","issue":{"url":"https://api.github.com/repos/ninject/Ninject/issues/189","labels_url":"https://api.github.com/repos/ninject/Ninject/issues/189/labels{/name}","comments_url":"https://api.github.com/repos/ninject/Ninject/issues/189/comments","events_url":"https://api.github.com/repos/ninject/Ninject/issues/189/events","html_url":"https://github.com/ninject/Ninject/issues/189","id":106589907,"number":189,"title":"WhenMemberHas broken","user":{"login":"sglienke","id":6238697,"avatar_url":"https://avatars.githubusercontent.com/u/6238697?v=3","gravatar_id":"","url":"https://api.github.com/users/sglienke","html_url":"https://github.com/sglienke","followers_url":"https://api.github.com/users/sglienke/followers","following_url":"https://api.github.com/users/sglienke/following{/other_user}","gists_url":"https://api.github.com/users/sglienke/gists{/gist_id}","starred_url":"https://api.github.com/users/sglienke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sglienke/subscriptions","organizations_url":"https://api.github.com/users/sglienke/orgs","repos_url":"https://api.github.com/users/sglienke/repos","events_url":"https://api.github.com/users/sglienke/events{/privacy}","received_events_url":"https://api.github.com/users/sglienke/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ninject/Ninject/labels/Core","name":"Core","color":"e10c02"}],"state":"closed","locked":false,"assignee":{"login":"scott-xu","id":1913505,"avatar_url":"https://avatars.githubusercontent.com/u/1913505?v=3","gravatar_id":"","url":"https://api.github.com/users/scott-xu","html_url":"https://github.com/scott-xu","followers_url":"https://api.github.com/users/scott-xu/followers","following_url":"https://api.github.com/users/scott-xu/following{/other_user}","gists_url":"https://api.github.com/users/scott-xu/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-xu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-xu/subscriptions","organizations_url":"https://api.github.com/users/scott-xu/orgs","repos_url":"https://api.github.com/users/scott-xu/repos","events_url":"https://api.github.com/users/scott-xu/events{/privacy}","received_events_url":"https://api.github.com/users/scott-xu/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2015-09-15T16:07:24Z","updated_at":"2015-09-16T23:50:44Z","closed_at":"2015-09-16T23:50:44Z","body":"While looking through the code it occured to me that WhenMemberHas and WhenTargetHas have the exact same implementation. But imo WhenMemberHas should not check if Target.IsDefined but if Target.Member.IsDefined. While for properties this would be the same for methods and ctors that is not the case.\r\n\r\nThe first test fails because it mistakenly considers the Weak attribute.\r\n\r\n```csharp\r\n    public class Knight \r\n    {\r\n        public IWeapon Weapon { get; private set; }\r\n\r\n        public Knight([Weak] IWeapon weapon)\r\n        {\r\n            this.Weapon = weapon;\r\n        }\r\n    }\r\n    \r\n    public class ConditionalBindingTests : StandardKernelContext\r\n    {\r\n        [Fact]\r\n        public void WhenMemberHasShouldNotConsiderAttributeOnTarget()\r\n        {\r\n            kernel.Bind<Knight>().ToSelf();\r\n            kernel.Bind<IWeapon>().To<Sword>();\r\n            kernel.Bind<IWeapon>().To<ShortSword>().WhenMemberHas<WeakAttribute>();\r\n\r\n            var knight = kernel.Get<Knight>();\r\n            knight.Weapon.Should().BeOfType<Sword>();\r\n        }\r\n\r\n        [Fact]\r\n        public void WhenTargetHasShouldConsiderAttributeOnTarget()\r\n        {\r\n            kernel.Bind<Knight>().ToSelf();\r\n            kernel.Bind<IWeapon>().To<Sword>();\r\n            kernel.Bind<IWeapon>().To<ShortSword>().WhenTargetHas<WeakAttribute>();\r\n\r\n            var knight = kernel.Get<Knight>();\r\n            knight.Weapon.Should().BeOfType<ShortSword>();\r\n        }\r\n    }\r\n```"}}