diff options
author | JamesNK <james@newtonking.com> | 2010-10-16 14:45:36 +0400 |
---|---|---|
committer | JamesNK <james@newtonking.com> | 2010-10-16 14:45:36 +0400 |
commit | 1703992773b08532d2adad1bf073c849b35a8f88 (patch) | |
tree | 71e967060e7172f85431b001cd090b4b71d47bc4 /Src/Newtonsoft.Json | |
parent | 336f14b3d2cd59a854a3b8565d99bdc3ff0d8c1c (diff) |
-Added covariance to IJEnumerable type parameter
-Fixed inaccessible private getter/setters on base classes
Diffstat (limited to 'Src/Newtonsoft.Json')
-rw-r--r-- | Src/Newtonsoft.Json/Linq/IJEnumerable.cs | 6 | ||||
-rw-r--r-- | Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/Src/Newtonsoft.Json/Linq/IJEnumerable.cs b/Src/Newtonsoft.Json/Linq/IJEnumerable.cs index a758fcb..6291e99 100644 --- a/Src/Newtonsoft.Json/Linq/IJEnumerable.cs +++ b/Src/Newtonsoft.Json/Linq/IJEnumerable.cs @@ -9,7 +9,11 @@ namespace Newtonsoft.Json.Linq /// Represents a collection of <see cref="JToken"/> objects.
/// </summary>
/// <typeparam name="T">The type of token</typeparam>
- public interface IJEnumerable<T> : IEnumerable<T> where T : JToken
+ public interface IJEnumerable<
+#if !(NET20 || NET35 || SILVERLIGHT)
+ out
+#endif
+ T> : IEnumerable<T> where T : JToken
{
/// <summary>
/// Gets the <see cref="IJEnumerable{JToken}"/> with the specified key.
diff --git a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs index 7419ba8..e2bb83b 100644 --- a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs @@ -880,10 +880,21 @@ namespace Newtonsoft.Json.Utilities {
ValidationUtils.ArgumentNotNull(targetType, "targetType");
- List<MemberInfo> propertyInfos = new List<MemberInfo>(targetType.GetProperties(bindingAttr));
+ List<PropertyInfo> propertyInfos = new List<PropertyInfo>(targetType.GetProperties(bindingAttr));
GetChildPrivateProperties(propertyInfos, targetType, bindingAttr);
- return propertyInfos.Cast<PropertyInfo>();
+ // 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++)
+ {
+ PropertyInfo member = propertyInfos[i];
+ if (member.DeclaringType != targetType)
+ {
+ PropertyInfo declaredMember = member.DeclaringType.GetProperty(member.Name, bindingAttr);
+ propertyInfos[i] = declaredMember;
+ }
+ }
+
+ return propertyInfos;
}
public static BindingFlags RemoveFlag(this BindingFlags bindingAttr, BindingFlags flag)
@@ -893,7 +904,7 @@ namespace Newtonsoft.Json.Utilities : bindingAttr;
}
- private static void GetChildPrivateProperties(IList<MemberInfo> initialProperties, Type targetType, BindingFlags bindingAttr)
+ private static void GetChildPrivateProperties(IList<PropertyInfo> initialProperties, Type targetType, BindingFlags bindingAttr)
{
// fix weirdness with private PropertyInfos only being returned for the current Type
// find base type properties and add them to result
|