-Incremented version to 6.0.1

-Changed .NET 4 Portable NuGet target to portable-net40+sl5+wp80+win8+monotouch+monoandroid
-Fixed Uri serialization roundtrip by using Uri.OriginalString
-Added Decimal and DateTimeOffset constructors to JValue
-Changed DefaultMemberSearchFlags on DefaultContractResolver to obsolete
This commit is contained in:
James Newton-King
2014-01-09 22:01:10 +13:00
parent 62f6a2c256
commit f878541047
9 changed files with 49 additions and 9 deletions
@@ -102,7 +102,6 @@
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -75,4 +75,4 @@ using System.Security;
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("5.0.8.16826")]
[assembly: AssemblyFileVersion("6.0.1.16909")]
@@ -9937,6 +9937,20 @@ Parameter name: value",
}", s);
}
#endif
[Test]
public void RoundtripUriOriginalString()
{
string originalUri = "https://test.com?m=a%2bb";
Uri uriWithPlus = new Uri(originalUri);
string jsonWithPlus = JsonConvert.SerializeObject(uriWithPlus);
Uri uriWithPlus2 = JsonConvert.DeserializeObject<Uri>(jsonWithPlus);
Assert.AreEqual(originalUri, uriWithPlus2.OriginalString);
}
}
public class PersonReference
+1 -1
View File
@@ -397,7 +397,7 @@ namespace Newtonsoft.Json
internal static string ToString(Uri value, char quoteChar)
{
return ToString(value.ToString(), quoteChar);
return ToString(value.OriginalString, quoteChar);
}
/// <summary>
+20
View File
@@ -73,6 +73,15 @@ namespace Newtonsoft.Json.Linq
{
}
/// <summary>
/// Initializes a new instance of the <see cref="JValue"/> class with the given value.
/// </summary>
/// <param name="value">The value.</param>
public JValue(decimal value)
: this(value, JTokenType.Float)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="JValue"/> class with the given value.
/// </summary>
@@ -119,6 +128,17 @@ namespace Newtonsoft.Json.Linq
{
}
#if !NET20
/// <summary>
/// Initializes a new instance of the <see cref="JValue"/> class with the given value.
/// </summary>
/// <param name="value">The value.</param>
public JValue(DateTimeOffset value)
: this(value, JTokenType.Date)
{
}
#endif
/// <summary>
/// Initializes a new instance of the <see cref="JValue"/> class with the given value.
/// </summary>
@@ -91,5 +91,5 @@ using System.Security;
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("5.0.8.16826")]
[assembly: AssemblyFileVersion("6.0.1.16909")]
[assembly: CLSCompliant(true)]
@@ -143,9 +143,10 @@ namespace Newtonsoft.Json.Serialization
/// Gets or sets the default members search flags.
/// </summary>
/// <value>The default members search flags.</value>
[ObsoleteAttribute("DefaultMembersSearchFlags is obsolete. Inherit from DefaultContractResolver and override the GetSerializableMembers method instead.")]
public BindingFlags DefaultMembersSearchFlags { get; set; }
#else
private BindingFlags DefaultMembersSearchFlags = BindingFlags.Instance | BindingFlags.Public;
private BindingFlags DefaultMembersSearchFlags = BindingFlags.Instance | BindingFlags.Public;
#endif
/// <summary>
@@ -194,7 +195,9 @@ namespace Newtonsoft.Json.Serialization
public DefaultContractResolver(bool shareCache)
{
#if !NETFX_CORE
#pragma warning disable 618
DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance;
#pragma warning restore 618
#endif
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
IgnoreSerializableAttribute = true;
@@ -280,8 +283,10 @@ namespace Newtonsoft.Json.Serialization
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(objectType);
#endif
#pragma warning disable 618
List<MemberInfo> defaultMembers = ReflectionUtils.GetFieldsAndProperties(objectType, DefaultMembersSearchFlags)
.Where(m => !ReflectionUtils.IsIndexedProperty(m)).ToList();
#pragma warning restore 618
foreach (MemberInfo member in allMembers)
{
@@ -1248,8 +1253,10 @@ namespace Newtonsoft.Json.Serialization
property.ItemTypeNameHandling = (propertyAttribute != null) ? propertyAttribute._itemTypeNameHandling : null;
allowNonPublicAccess = false;
#pragma warning disable 618
if ((DefaultMembersSearchFlags & BindingFlags.NonPublic) == BindingFlags.NonPublic)
allowNonPublicAccess = true;
#pragma warning restore 618
if (propertyAttribute != null)
allowNonPublicAccess = true;
if (memberSerialization == MemberSerialization.Fields)