diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs index 7590a785..46dfca86 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs @@ -47,7 +47,12 @@ using NUnit.Framework; namespace Newtonsoft.Json.Tests.Serialization { - public interface ITaskRepository + public interface IBase + { + DateTime CreatedOn { get; set; } + } + + public interface ITaskRepository : IBase { string ConnectionString { get; set; } } @@ -58,7 +63,12 @@ namespace Newtonsoft.Json.Tests.Serialization string Level { get; set; } } - public class TaskRepository : ITaskRepository + public class Base : IBase + { + public DateTime CreatedOn { get; set; } + } + + public class TaskRepository : Base, ITaskRepository { public string ConnectionString { get; set; } } @@ -202,7 +212,8 @@ namespace Newtonsoft.Json.Tests.Serialization 'Level': 'Debug' }, 'Repository': { - 'ConnectionString': 'server=.' + 'ConnectionString': 'server=.', + 'CreatedOn': '2015-04-01 20:00' }, 'People': [ { @@ -223,6 +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(2, count); diff --git a/Src/Newtonsoft.Json.sln.DotSettings b/Src/Newtonsoft.Json.sln.DotSettings index c97ec47f..2c4af6be 100644 --- a/Src/Newtonsoft.Json.sln.DotSettings +++ b/Src/Newtonsoft.Json.sln.DotSettings @@ -2,5 +2,7 @@ False True False + True True + True \ No newline at end of file diff --git a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs index 6fd669fa..c378a8a4 100644 --- a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs @@ -883,8 +883,20 @@ namespace Newtonsoft.Json.Utilities { ValidationUtils.ArgumentNotNull(targetType, "targetType"); - List propertyInfos = new List(targetType.GetProperties(bindingAttr)); - GetChildPrivateProperties(propertyInfos, targetType, bindingAttr); + List propertyInfos; + + if (!targetType.IsInterface()) + { + propertyInfos = new List(targetType.GetProperties(bindingAttr)); + } + else + { + propertyInfos = (new Type[] { targetType }) + .Concat(targetType.GetInterfaces()) + .SelectMany(i => i.GetProperties(bindingAttr)).ToList(); + } + + GetChildPrivateProperties(propertyInfos, targetType, bindingAttr); // a base class private getter/setter will be inaccessable unless the property was gotten from the base class for (int i = 0; i < propertyInfos.Count; i++)