Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamesNK <james@newtonking.com>2012-02-10 15:33:45 +0400
committerJamesNK <james@newtonking.com>2012-02-10 15:33:45 +0400
commit49328ddeb0e58a7419c25b69d4932b9886886073 (patch)
treedf69cca9be3d8e751963768402f360cf1e7d493d
parent3bebf5c7659c6d092ee06bbd2de9aa6aa5ba452e (diff)
-Incremented version to 4.0.8
-Added VersionConverter -Fixed converting XML to JSON with a default namespace -Changed Silverlight/Windows Phone assemblies to not be signed
-rw-r--r--Build/Newtonsoft.Json.nuspec2
-rw-r--r--Build/build.ps140
-rw-r--r--Doc/versions.txt6
-rw-r--r--Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs114
-rw-r--r--Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs490
-rw-r--r--Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs10
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs24
-rw-r--r--Src/Newtonsoft.Json/Converters/VersionConverter.cs109
-rw-r--r--Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs8
-rw-r--r--Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj1
-rw-r--r--Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj1
-rw-r--r--Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj1
-rw-r--r--Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj1
-rw-r--r--Src/Newtonsoft.Json/Newtonsoft.Json.csproj1
-rw-r--r--Src/Newtonsoft.Json/Properties/AssemblyInfo.cs22
20 files changed, 777 insertions, 58 deletions
diff --git a/Build/Newtonsoft.Json.nuspec b/Build/Newtonsoft.Json.nuspec
index d8b232e..3495d31 100644
--- a/Build/Newtonsoft.Json.nuspec
+++ b/Build/Newtonsoft.Json.nuspec
@@ -3,7 +3,7 @@
<metadata>
<id>Newtonsoft.Json</id>
<title>Json.NET</title>
- <version>4.0.7</version>
+ <version>4.0.8</version>
<authors>James Newton-King</authors>
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
<language>en-US</language>
diff --git a/Build/build.ps1 b/Build/build.ps1
index 3a9bee0..66a61c5 100644
--- a/Build/build.ps1
+++ b/Build/build.ps1
@@ -1,6 +1,6 @@
properties {
- $zipFileName = "Json40r7.zip"
- $majorVersion = "4.0.7"
+ $zipFileName = "Json40r8.zip"
+ $majorVersion = "4.0.8"
$version = GetVersion $majorVersion
$signAssemblies = $false
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
@@ -15,11 +15,11 @@
$releaseDir = "$baseDir\Release"
$workingDir = "$baseDir\Working"
$builds = @(
- @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "net40"; Framework="net-4.0"},
- @{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp,sl4-windowsphone71"; Framework="net-4.0"},
- @{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "sl4"; Framework="net-4.0"},
- @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"},
- @{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"}
+ @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
+ @{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp,sl4-windowsphone71"; Framework="net-4.0"; Sign=$false},
+ @{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "sl4"; Framework="net-4.0"; Sign=$false},
+ @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"; Sign=$true},
+ @{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"; Sign=$true}
)
}
@@ -51,10 +51,12 @@ task Build -depends Clean {
{
$name = $build.Name
$finalDir = $build.FinalDir
+ $sign = ($build.Sign -and $signAssemblies)
Write-Host -ForegroundColor Green "Building " $name
+ Write-Host -ForegroundColor Green "Signed " $sign
Write-Host
- exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$signAssemblies" (GetConstants $build.Constants $signAssemblies) ".\Src\$name.sln" } "Error building $name"
+ exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$sign" (GetConstants $build.Constants $sign) ".\Src\$name.sln" } "Error building $name"
}
}
@@ -137,28 +139,6 @@ task Test -depends Deploy {
}
}
-function MergeAssembly($dllPrimaryAssembly, $signKey, [string[]]$mergedAssemlies)
-{
- $mergeAssemblyPaths = [String]::Join(" ", $mergedAssemlies)
-
- $primary = Get-Item $dllPrimaryAssembly
- $mergedAssemblyName = $primary.Name
- $temporaryDir = $primary.DirectoryName + "\" + [Guid]::NewGuid().ToString()
- New-Item $temporaryDir -ItemType Directory
-
- $ilMergeKeyFile = switch($signAssemblies) { $true { "/keyfile:$signKeyPath" } default { "" } }
-
- try
- {
- exec { .\Tools\ILMerge\ilmerge.exe "/internalize" "/closed" "/log:$workingDir\$mergedAssemblyName.MergeLog.txt" $ilMergeKeyFile "/out:$temporaryDir\$mergedAssemblyName" $dllPrimaryAssembly $mergeAssemblyPaths } "Error executing ILMerge"
- Copy-Item -Path $temporaryDir\$mergedAssemblyName -Destination $dllPrimaryAssembly -Force
- }
- finally
- {
- Remove-Item $temporaryDir -Recurse -Force
- }
-}
-
function GetConstants($constants, $includeSigned)
{
$signed = switch($includeSigned) { $true { ";SIGNED" } default { "" } }
diff --git a/Doc/versions.txt b/Doc/versions.txt
index 8a726fb..ef8d1d8 100644
--- a/Doc/versions.txt
+++ b/Doc/versions.txt
@@ -2,13 +2,13 @@ Versions:
Json.NET comes in different versions for the various .NET frameworks.
--DotNet:
+-Net40:
.NET latest (4.0)
--DotNet35:
+-Net35:
.NET 3.5 SP1, Mono
--DotNet20:
+-Net20:
.NET 2.0
-Silverlight:
diff --git a/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs
new file mode 100644
index 0000000..eaaaf94
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs
@@ -0,0 +1,114 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json.Converters;
+using NUnit.Framework;
+using Newtonsoft.Json.Tests.TestObjects;
+
+namespace Newtonsoft.Json.Tests.Converters
+{
+ public class VersionClass
+ {
+ public VersionClass(string version1, string version2)
+ {
+ this.StringProperty1 = "StringProperty1";
+ this.Version1 = new Version(version1);
+ this.Version2 = new Version(version2);
+ this.StringProperty2 = "StringProperty2";
+ }
+
+ public VersionClass()
+ {
+ }
+
+ public string StringProperty1 { get; set; }
+ public Version Version1 { get; set; }
+ public Version Version2 { get; set; }
+ public string StringProperty2 { get; set; }
+ }
+
+ public class VersionConverterTests : TestFixtureBase
+ {
+ private void SerializeVersionClass(string version1, string version2)
+ {
+ VersionClass versionClass = new VersionClass(version1, version2);
+
+ string json = JsonConvert.SerializeObject(versionClass, Formatting.Indented, new VersionConverter());
+
+ string expectedJson = string.Format(@"{{
+ ""StringProperty1"": ""StringProperty1"",
+ ""Version1"": ""{0}"",
+ ""Version2"": ""{1}"",
+ ""StringProperty2"": ""StringProperty2""
+}}", version1, version2);
+
+ Assert.AreEqual(expectedJson, json);
+ }
+
+ [Test]
+ public void SerializeVersionClass()
+ {
+ SerializeVersionClass("1.0.0.0", "2.0.0.0");
+ SerializeVersionClass("1.2.0.0", "2.3.0.0");
+ SerializeVersionClass("1.2.3.0", "2.3.4.0");
+ SerializeVersionClass("1.2.3.4", "2.3.4.5");
+
+ SerializeVersionClass("1.2", "2.3");
+ SerializeVersionClass("1.2.3", "2.3.4");
+ SerializeVersionClass("1.2.3.4", "2.3.4.5");
+ }
+
+ private void DeserializeVersionClass(string version1, string version2)
+ {
+ string json = string.Format(@"{{""StringProperty1"": ""StringProperty1"", ""Version1"": ""{0}"", ""Version2"": ""{1}"", ""StringProperty2"": ""StringProperty2""}}", version1, version2);
+ Version expectedVersion1 = new Version(version1);
+ Version expectedVersion2 = new Version(version2);
+
+ VersionClass versionClass = JsonConvert.DeserializeObject<VersionClass>(json, new VersionConverter());
+
+ Assert.AreEqual("StringProperty1", versionClass.StringProperty1);
+ Assert.AreEqual(expectedVersion1, versionClass.Version1);
+ Assert.AreEqual(expectedVersion2, versionClass.Version2);
+ Assert.AreEqual("StringProperty2", versionClass.StringProperty2);
+ }
+
+ [Test]
+ public void DeserializeVersionClass()
+ {
+ DeserializeVersionClass("1.0.0.0", "2.0.0.0");
+ DeserializeVersionClass("1.2.0.0", "2.3.0.0");
+ DeserializeVersionClass("1.2.3.0", "2.3.4.0");
+ DeserializeVersionClass("1.2.3.4", "2.3.4.5");
+
+ DeserializeVersionClass("1.2", "2.3");
+ DeserializeVersionClass("1.2.3", "2.3.4");
+ DeserializeVersionClass("1.2.3.4", "2.3.4.5");
+ }
+ }
+} \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs
index 4dc32b2..c672ac5 100644
--- a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs
@@ -1285,7 +1285,7 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?><root booleanType=""true"" />", xmlString);
}
- static void JsonBodyToSoapXml(Stream json, Stream xml)
+ private static void JsonBodyToSoapXml(Stream json, Stream xml)
{
Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings();
settings.Converters.Add(new Newtonsoft.Json.Converters.XmlNodeConverter());
@@ -1301,6 +1301,494 @@ namespace Newtonsoft.Json.Tests.Converters
}
}
}
+
+#if !NET20
+ [Test]
+ public void DeserializeXNodeDefaultNamespace()
+ {
+ string xaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ string json = JsonConvert.SerializeXNode(XDocument.Parse(xaml), Formatting.Indented);
+
+ string expectedJson = @"{
+ ""Grid"": {
+ ""@xmlns"": ""http://schemas.microsoft.com/winfx/2006/xaml/presentation"",
+ ""@xmlns:x"": ""http://schemas.microsoft.com/winfx/2006/xaml"",
+ ""@xmlns:toolkit"": ""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"",
+ ""@Style"": ""{StaticResource trimFormGrid}"",
+ ""@x:Name"": ""TrimObjectForm"",
+ ""Grid.ColumnDefinitions"": {
+ ""ColumnDefinition"": [
+ {
+ ""@Width"": ""63*""
+ },
+ {
+ ""@Width"": ""320*""
+ }
+ ]
+ },
+ ""Grid.RowDefinitions"": {
+ ""@xmlns"": """",
+ ""RowDefinition"": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ ""TextBox"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordTypedTitle"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordExternalReference"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Author, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAuthor"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Container, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordContainer"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordIsEnclosed"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAssignee"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ],
+ ""toolkit:DatePicker"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateCreated"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""2""
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateDue"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""3""
+ }
+ ],
+ ""TextBlock"": [
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Title (Free Text Part)"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""External ID"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Created"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""2"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Due"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""3"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Author"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Container"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Enclosed?"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Assignee"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ]
+ }
+}";
+
+ Assert.AreEqual(expectedJson, json);
+
+ XNode node = JsonConvert.DeserializeXNode(json);
+
+ string xaml2 = node.ToString();
+
+ string expectedXaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ Assert.AreEqual(expectedXaml, xaml2);
+ }
+#endif
+
+ [Test]
+ public void DeserializeXmlNodeDefaultNamespace()
+ {
+ string xaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ XmlDocument document = new XmlDocument();
+ document.LoadXml(xaml);
+
+ string json = JsonConvert.SerializeXmlNode(document, Formatting.Indented);
+
+ string expectedJson = @"{
+ ""Grid"": {
+ ""@xmlns"": ""http://schemas.microsoft.com/winfx/2006/xaml/presentation"",
+ ""@xmlns:x"": ""http://schemas.microsoft.com/winfx/2006/xaml"",
+ ""@xmlns:toolkit"": ""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"",
+ ""@Style"": ""{StaticResource trimFormGrid}"",
+ ""@x:Name"": ""TrimObjectForm"",
+ ""Grid.ColumnDefinitions"": {
+ ""ColumnDefinition"": [
+ {
+ ""@Width"": ""63*""
+ },
+ {
+ ""@Width"": ""320*""
+ }
+ ]
+ },
+ ""Grid.RowDefinitions"": {
+ ""@xmlns"": """",
+ ""RowDefinition"": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ ""TextBox"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordTypedTitle"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordExternalReference"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Author, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAuthor"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Container, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordContainer"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordIsEnclosed"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAssignee"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ],
+ ""toolkit:DatePicker"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateCreated"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""2""
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateDue"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""3""
+ }
+ ],
+ ""TextBlock"": [
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Title (Free Text Part)"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""External ID"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Created"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""2"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Due"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""3"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Author"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Container"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Enclosed?"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Assignee"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ]
+ }
+}";
+
+ Assert.AreEqual(expectedJson, json);
+
+ XmlNode node = JsonConvert.DeserializeXmlNode(json);
+
+ StringWriter sw = new StringWriter();
+ XmlWriter writer = XmlWriter.Create(sw, new XmlWriterSettings
+ {
+ Indent = true,
+ OmitXmlDeclaration = true
+ });
+ node.WriteTo(writer);
+ writer.Flush();
+
+ string xaml2 = sw.ToString();
+
+ string expectedXaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ Assert.AreEqual(expectedXaml, xaml2);
+ }
}
}
#endif \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
index 446512c..a1cb857 100644
--- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
+++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
@@ -1923,5 +1923,15 @@ bye", reader.Value);
reader.Read();
Assert.AreEqual(JsonToken.EndArray, reader.TokenType);
}
+
+ [Test]
+ [ExpectedException(typeof(JsonReaderException), ExpectedMessage = "Additional text encountered after finished reading JSON content: }. Line 1, position 2.")]
+ public void UnexpectedEndTokenWhenParsingOddEndToken()
+ {
+ JsonReader reader = new JsonTextReader(new StringReader(@"{}}"));
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader.Read());
+ reader.Read();
+ }
}
} \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
index 135fa42..f9c40b4 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
@@ -84,6 +84,7 @@
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonValidatingReaderTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj
index b1729d7..af23192 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj
@@ -114,6 +114,7 @@
<Compile Include="Converters\CustomCreationConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonValidatingReaderTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
index 25d36f2..6a9ae0f 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
@@ -110,6 +110,7 @@
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj
index 78fe5a6..e019d0d 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj
@@ -74,6 +74,7 @@
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
index 2a87afd..925083a 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
@@ -115,6 +115,7 @@
<Compile Include="Converters\CustomCreationConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="FileSystemEntityModel.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
index 032490a..d1e339e 100644
--- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
+++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
@@ -24,26 +24,32 @@
#endregion
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-#if SILVERLIGHT
-[assembly: AssemblyTitle("Newtonsoft Json.NET Tests Silverlight")]
+#if WINDOWS_PHONE
+[assembly: AssemblyTitle("Json.NET Tests Windows Phone")]
+#elif SILVERLIGHT
+[assembly: AssemblyTitle("Json.NET Tests Silverlight")]
#elif PocketPC
-[assembly: AssemblyTitle("Newtonsoft Json.NET Tests Compact")]
+[assembly: AssemblyTitle("Json.NET Tests Compact")]
+#elif NET20
+[assembly: AssemblyTitle("Json.NET Tests .NET 2.0")]
+#elif NET35
+[assembly: AssemblyTitle("Json.NET Tests .NET 3.5")]
#else
-[assembly: AssemblyTitle("Newtonsoft Json.NET Tests")]
+[assembly: AssemblyTitle("Json.NET")]
#endif
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Newtonsoft")]
-[assembly: AssemblyProduct("Newtonsoft Json.NET Tests")]
-[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
+[assembly: AssemblyProduct("Json.NET Tests")]
+[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -64,7 +70,7 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("4.0.7.0")]
+[assembly: AssemblyVersion("4.0.8.0")]
#if !PocketPC
-[assembly: AssemblyFileVersion("4.0.7.14610")]
+[assembly: AssemblyFileVersion("4.0.8.14611")]
#endif
diff --git a/Src/Newtonsoft.Json/Converters/VersionConverter.cs b/Src/Newtonsoft.Json/Converters/VersionConverter.cs
new file mode 100644
index 0000000..67a9b66
--- /dev/null
+++ b/Src/Newtonsoft.Json/Converters/VersionConverter.cs
@@ -0,0 +1,109 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Globalization;
+using Newtonsoft.Json.Utilities;
+
+namespace Newtonsoft.Json.Converters
+{
+ /// <summary>
+ /// Converts a <see cref="Version"/> to and from a string (e.g. "1.2.3.4").
+ /// </summary>
+ public class VersionConverter : JsonConverter
+ {
+ /// <summary>
+ /// Writes the JSON representation of the object.
+ /// </summary>
+ /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
+ /// <param name="value">The value.</param>
+ /// <param name="serializer">The calling serializer.</param>
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ if (value == null)
+ {
+ writer.WriteNull();
+ }
+ else if (value is Version)
+ {
+ writer.WriteValue(value.ToString());
+ }
+ else
+ {
+ throw new Exception("Expected Version object value");
+ }
+ }
+
+ /// <summary>
+ /// Reads the JSON representation of the object.
+ /// </summary>
+ /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
+ /// <param name="objectType">Type of the object.</param>
+ /// <param name="existingValue">The existing property value of the JSON that is being converted.</param>
+ /// <param name="serializer">The calling serializer.</param>
+ /// <returns>The object value.</returns>
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ if (reader.TokenType == JsonToken.Null)
+ {
+ return null;
+ }
+ else
+ {
+ if (reader.TokenType == JsonToken.String)
+ {
+ try
+ {
+ Version v = new Version((string) reader.Value);
+ return v;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Error parsing version string: {0}".FormatWith(CultureInfo.InvariantCulture, reader.Value), ex);
+ }
+ }
+ else
+ {
+ throw new Exception("Unexpected token or value when parsing version. Token: {0}, Value: {1}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType, reader.Value));
+ }
+ }
+ }
+
+ /// <summary>
+ /// Determines whether this instance can convert the specified object type.
+ /// </summary>
+ /// <param name="objectType">Type of the object.</param>
+ /// <returns>
+ /// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof (Version);
+ }
+ }
+} \ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs b/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
index cd6a9e2..e3a8296 100644
--- a/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
@@ -1426,9 +1426,11 @@ namespace Newtonsoft.Json.Converters
private IXmlElement CreateElement(string elementName, IXmlDocument document, string elementPrefix, XmlNamespaceManager manager)
{
- return (!string.IsNullOrEmpty(elementPrefix))
- ? document.CreateElement(elementName, manager.LookupNamespace(elementPrefix))
- : document.CreateElement(elementName);
+ string ns = string.IsNullOrEmpty(elementPrefix) ? manager.DefaultNamespace : manager.LookupNamespace(elementPrefix);
+
+ IXmlElement element = (!string.IsNullOrEmpty(ns)) ? document.CreateElement(elementName, ns) : document.CreateElement(elementName);
+
+ return element;
}
private void DeserializeNode(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, IXmlNode currentNode)
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj
index 6b4275f..ca9b1fa 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj
@@ -91,6 +91,7 @@
<Compile Include="Converters\KeyValuePairConverter.cs" />
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
+ <Compile Include="Converters\VersionConverter.cs" />
<Compile Include="JsonConstructorAttribute.cs" />
<Compile Include="Utilities\LinqBridge.cs" />
<Compile Include="Linq\JPath.cs" />
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj
index 4f79b12..54c0188 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj
@@ -103,6 +103,7 @@
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
<Compile Include="ConstructorHandling.cs" />
+ <Compile Include="Converters\VersionConverter.cs" />
<Compile Include="JsonConstructorAttribute.cs" />
<Compile Include="Linq\JPropertyDescriptor.cs" />
<Compile Include="Utilities\DynamicProxy.cs" />
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj
index 8dca56e..1cd5868 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj
@@ -102,6 +102,7 @@
<Compile Include="Converters\KeyValuePairConverter.cs" />
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
+ <Compile Include="Converters\VersionConverter.cs" />
<Compile Include="Converters\XmlNodeConverter.cs" />
<Compile Include="FormatterAssemblyStyle.cs" />
<Compile Include="DefaultValueHandling.cs" />
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj
index 93b4b1c..6825dd5 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj
@@ -75,6 +75,7 @@
<Compile Include="Converters\KeyValuePairConverter.cs" />
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
+ <Compile Include="Converters\VersionConverter.cs" />
<Compile Include="Converters\XmlNodeConverter.cs" />
<Compile Include="FormatterAssemblyStyle.cs" />
<Compile Include="DefaultValueHandling.cs" />
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.csproj
index 980a105..529ca24 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.csproj
@@ -102,6 +102,7 @@
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
<Compile Include="ConstructorHandling.cs" />
+ <Compile Include="Converters\VersionConverter.cs" />
<Compile Include="JsonConstructorAttribute.cs" />
<Compile Include="Utilities\DynamicProxy.cs" />
<Compile Include="Linq\JPath.cs" />
diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs
index 877c5cc..86c838f 100644
--- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs
+++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs
@@ -33,19 +33,19 @@ using System.Security;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
#if WINDOWS_PHONE
-[assembly: AssemblyTitle("Newtonsoft Json.NET Windows Phone")]
+[assembly: AssemblyTitle("Json.NET Windows Phone")]
#elif SILVERLIGHT
-[assembly: AssemblyTitle("Newtonsoft Json.NET Silverlight")]
+[assembly: AssemblyTitle("Json.NET Silverlight")]
#elif PocketPC
-[assembly: AssemblyTitle("Newtonsoft Json.NET Compact")]
+[assembly: AssemblyTitle("Json.NET Compact")]
#elif NET20
-[assembly: AssemblyTitle("Newtonsoft Json.NET .NET 2.0")]
+[assembly: AssemblyTitle("Json.NET .NET 2.0")]
[assembly: AllowPartiallyTrustedCallers]
#elif NET35
-[assembly: AssemblyTitle("Newtonsoft Json.NET .NET 3.5")]
+[assembly: AssemblyTitle("Json.NET .NET 3.5")]
[assembly: AllowPartiallyTrustedCallers]
#else
-[assembly: AssemblyTitle("Newtonsoft Json.NET")]
+[assembly: AssemblyTitle("Json.NET")]
[assembly: AllowPartiallyTrustedCallers]
#endif
@@ -57,11 +57,11 @@ using System.Security;
[assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Newtonsoft")]
-[assembly: AssemblyProduct("Newtonsoft Json.NET")]
-[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
+[assembly: AssemblyProduct("Json.NET")]
+[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -83,9 +83,9 @@ using System.Security;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("4.0.7.0")]
+[assembly: AssemblyVersion("4.0.8.0")]
#if !PocketPC
-[assembly: AssemblyFileVersion("4.0.7.14610")]
+[assembly: AssemblyFileVersion("4.0.8.14611")]
#endif
[assembly: CLSCompliant(true)]