diff --git a/src/Ninject.Test/Integration/PropertyInjectionTests.cs b/src/Ninject.Test/Integration/PropertyInjectionTests.cs index 44519023..b84f2b78 100644 --- a/src/Ninject.Test/Integration/PropertyInjectionTests.cs +++ b/src/Ninject.Test/Integration/PropertyInjectionTests.cs @@ -149,7 +149,21 @@ public void ParentPropertiesAreInjected() warrior.SecretWeaponAccessor.Should().NotBeNull(); warrior.VerySecretWeaponAccessor.Should().NotBeNull(); } - + + [Fact] + public void GrandParentPropertiesAreInjected() + { + this.kernel.Settings.InjectNonPublic = true; + this.kernel.Settings.InjectParentPrivateProperties = true; + var warrior = this.kernel.Get(); + + warrior.Should().NotBeNull(); + warrior.OffHandWeapon.Should().NotBeNull(); + warrior.SecondaryWeapon.Should().NotBeNull(); + warrior.SecretWeaponAccessor.Should().NotBeNull(); + warrior.VerySecretWeaponAccessor.Should().NotBeNull(); + } + private class OwnStyleNinja : Ninja { public OwnStyleNinja(IWeapon weapon) @@ -171,6 +185,14 @@ public FatherStyleNinja(IWeapon weapon) { } } + + private class GrandFatherStyleNinja : FatherStyleNinja + { + public GrandFatherStyleNinja(IWeapon weapon) + : base(weapon) + { + } + } #endif //!SILVERLIGHT } diff --git a/src/Ninject/Selection/Selector.cs b/src/Ninject/Selection/Selector.cs index ea3e516b..793a5d9d 100644 --- a/src/Ninject/Selection/Selector.cs +++ b/src/Ninject/Selection/Selector.cs @@ -108,7 +108,7 @@ public virtual IEnumerable SelectPropertiesForInjection(Type type) { for (Type parentType = type.GetTypeInfo().BaseType; parentType != null; parentType = parentType.GetTypeInfo().BaseType) { - properties.AddRange(this.GetPrivateProperties(type.GetTypeInfo().BaseType)); + properties.AddRange(this.GetPrivateProperties(parentType)); } }