-Fixed documentation typo
-Fixed error when serializing some interfaces with hidden properties -Fixed some large integers being incorrectly read from JSON
This commit is contained in:
@@ -50,7 +50,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
/// <returns>The property name camel cased.</returns>
|
||||
protected override string ResolvePropertyName(string propertyName)
|
||||
{
|
||||
// lower case the first letter of the passed in name
|
||||
// lower case the first letter (or more) of the passed in name
|
||||
return StringUtils.ToCamelCase(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +85,15 @@ namespace Newtonsoft.Json.Serialization
|
||||
{
|
||||
if (property.DeclaringType != null && existingProperty.DeclaringType != null)
|
||||
{
|
||||
if (property.DeclaringType.IsSubclassOf(existingProperty.DeclaringType))
|
||||
if (property.DeclaringType.IsSubclassOf(existingProperty.DeclaringType)
|
||||
|| (existingProperty.DeclaringType.IsInterface && property.DeclaringType.ImplementInterface(existingProperty.DeclaringType)))
|
||||
{
|
||||
// current property is on a derived class and hides the existing
|
||||
Remove(existingProperty);
|
||||
duplicateProperty = false;
|
||||
}
|
||||
if (existingProperty.DeclaringType.IsSubclassOf(property.DeclaringType))
|
||||
if (existingProperty.DeclaringType.IsSubclassOf(property.DeclaringType)
|
||||
|| (property.DeclaringType.IsInterface && existingProperty.DeclaringType.ImplementInterface(property.DeclaringType)))
|
||||
{
|
||||
// current property is hidden by the existing so don't add it
|
||||
return;
|
||||
|
||||
@@ -665,6 +665,21 @@ namespace Newtonsoft.Json.Utilities
|
||||
|
||||
int end = start + length;
|
||||
|
||||
// Int32.MaxValue and MinValue are 10 chars
|
||||
if (length > 10)
|
||||
{
|
||||
// invalid result takes precedence over overflow
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
int c = chars[i] - '0';
|
||||
|
||||
if (c < 0 || c > 9)
|
||||
return ParseResult.Invalid;
|
||||
}
|
||||
|
||||
return ParseResult.Overflow;
|
||||
}
|
||||
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
int c = chars[i] - '0';
|
||||
@@ -730,6 +745,21 @@ namespace Newtonsoft.Json.Utilities
|
||||
|
||||
int end = start + length;
|
||||
|
||||
// Int64.MaxValue and MinValue are 19 chars
|
||||
if (length > 19)
|
||||
{
|
||||
// invalid result takes precedence over overflow
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
int c = chars[i] - '0';
|
||||
|
||||
if (c < 0 || c > 9)
|
||||
return ParseResult.Invalid;
|
||||
}
|
||||
|
||||
return ParseResult.Overflow;
|
||||
}
|
||||
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
int c = chars[i] - '0';
|
||||
|
||||
@@ -550,5 +550,23 @@ namespace Newtonsoft.Json.Utilities
|
||||
Type match;
|
||||
return type.AssignableToTypeName(fullTypeName, out match);
|
||||
}
|
||||
|
||||
public static bool ImplementInterface(this Type type, Type interfaceType)
|
||||
{
|
||||
for (Type currentType = type; currentType != null; currentType = currentType.BaseType)
|
||||
{
|
||||
Type[] interfaces = currentType.GetInterfaces();
|
||||
|
||||
for (int i = 0; i < interfaces.Length; i++)
|
||||
{
|
||||
if (interfaces[i] == interfaceType || (interfaces[i] != null && interfaces[i].ImplementInterface(interfaceType)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user