diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs index 7c31f9c7..44da8965 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs @@ -234,7 +234,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.IsNotNull(o); Assert.IsNotNull(o.Logger); Assert.IsNotNull(o.Repository); - Assert.IsNotNull(o.Repository.CreatedOn); + Assert.AreEqual(o.Repository.CreatedOn, DateTime.Parse("2015-04-01 20:00")); Assert.AreEqual(2, count); diff --git a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs index ba73f174..e3a3933d 100644 --- a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs @@ -883,17 +883,15 @@ namespace Newtonsoft.Json.Utilities { ValidationUtils.ArgumentNotNull(targetType, "targetType"); - List propertyInfos; + List propertyInfos = new List(targetType.GetProperties(bindingAttr)); - if (!targetType.IsInterface()) + // GetProperties on an interface doesn't return properties from its interfaces + if (targetType.IsInterface()) { - propertyInfos = new List(targetType.GetProperties(bindingAttr)); - } - else - { - propertyInfos = (new Type[] { targetType }) - .Concat(targetType.GetInterfaces()) - .SelectMany(i => i.GetProperties(bindingAttr)).ToList(); + foreach (Type i in targetType.GetInterfaces()) + { + propertyInfos.AddRange(i.GetProperties(bindingAttr)); + } } GetChildPrivateProperties(propertyInfos, targetType, bindingAttr);