From ab2906874f5b710a6d5c3d5b738993fe7da6435a Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 18 Oct 2015 13:42:31 +1300 Subject: [PATCH] -Changed DateTimeOffset JValue to return TypeCode.Object -Incremented version to 8.0.1-beta1 --- Build/build.ps1 | 40 ++++--------------- .../Linq/DynamicTests.cs | 8 ++++ Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs | 5 +++ Src/Newtonsoft.Json/Linq/JValue.cs | 9 ----- 4 files changed, 21 insertions(+), 41 deletions(-) diff --git a/Build/build.ps1 b/Build/build.ps1 index 707c55bf..bd10374e 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -1,7 +1,7 @@ properties { - $zipFileName = "Json70r2.zip" - $majorVersion = "7.0" - $majorWithReleaseVersion = "7.0.2" + $zipFileName = "Json80r1.zip" + $majorVersion = "8.0" + $majorWithReleaseVersion = "8.0.1" $nugetPrelease = "beta1" $version = GetVersion $majorWithReleaseVersion $packageId = "Newtonsoft.Json" @@ -22,9 +22,9 @@ $workingDir = "$baseDir\$workingName" $workingSourceDir = "$workingDir\Src" $builds = @( - @{Name = "Newtonsoft.Json.Dotnet"; TestsName = "Newtonsoft.Json.Tests.Dotnet"; BuildFunction = "DnxBuild"; TestsFunction = "DnxTests"; Constants="dotnet"; FinalDir="Dotnet"; NuGetDir = "dotnet"; Framework=$null}, + @{Name = "Newtonsoft.Json.Dotnet"; TestsName = "Newtonsoft.Json.Tests.Dotnet"; BuildFunction = "DnxBuild"; TestsFunction = "DnxTests"; Constants="dotnet"; FinalDir=$null; NuGetDir = $null; Framework=$null}, @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants=""; FinalDir="Net45"; NuGetDir = "net45"; Framework="net-4.0"}, - @{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="PORTABLE"; FinalDir="Portable"; NuGetDir = "portable-net45+wp80+win8+wpa81"; Framework="net-4.0"}, + @{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="PORTABLE"; FinalDir="Portable"; NuGetDir = "portable-net45+wp80+win8+wpa81+dnxcore50"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="PORTABLE40"; FinalDir="Portable40"; NuGetDir = "portable-net40+sl5+wp80+win8+wpa81"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="NET40"; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"}, @@ -56,7 +56,7 @@ task Clean { task Build -depends Clean { Write-Host "Copying source to working source directory $workingSourceDir" - robocopy $sourceDir $workingSourceDir /MIR /NP /XD bin obj TestResults AppPackages $packageDirs .vs /XF *.suo *.user project.lock.json *.project.lock.json | Out-Default + robocopy $sourceDir $workingSourceDir /MIR /NP /XD bin obj TestResults AppPackages $packageDirs .vs /XF *.suo *.user *.lock.json | Out-Default Write-Host -ForegroundColor Green "Updating assembly version" Write-Host @@ -214,19 +214,7 @@ function DnxBuild($build) Write-Host -ForegroundColor Green "Restoring packages for $name" Write-Host - exec { - try { - dnu restore $projectPath | Out-Default - Write-Host "Restore last exit code: $lastexitcode" - } - catch [System.Management.Automation.RemoteException] - { - Write-Host "Restore last exit code: $lastexitcode" - Write-Host ("Restore exception: " + $_.ToString()) - $global:lastexitcode = 0 - $lastexitcode = 0 - } - } + exec { dnu restore $projectPath | Out-Default } Write-Host -ForegroundColor Green "Building $projectPath" exec { dnu build $projectPath --configuration Release | Out-Default } @@ -245,19 +233,7 @@ function DnxTests($build) Write-Host -ForegroundColor Green "Restoring packages for $name" Write-Host - exec { - try { - dnu restore "$workingSourceDir\Newtonsoft.Json.Tests\project.json" | Out-Default - Write-Host "Restore last exit code: $lastexitcode" - } - catch [System.Management.Automation.RemoteException] - { - Write-Host "Restore last exit code: $lastexitcode" - Write-Host ("Restore exception: " + $_.ToString()) - $global:lastexitcode = 0 - $lastexitcode = 0 - } - } + exec { dnu restore "$workingSourceDir\Newtonsoft.Json.Tests\project.json" | Out-Default } Write-Host -ForegroundColor Green "Ensuring test project builds for $name" Write-Host diff --git a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs index 1252ed26..80ebcd81 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs @@ -114,13 +114,21 @@ namespace Newtonsoft.Json.Tests.Linq Stopwatch sw = new Stopwatch(); sw.Start(); + int count = 0; foreach (dynamic o in d) { + if (count > 10) + { + break; + } + foreach (dynamic friend in o.friends) { UpdateValueCount(counts, friend.id); UpdateValueCount(counts, ((string) friend.name).Split(' ')[0]); } + + count++; } Console.WriteLine("Time (secs): " + sw.Elapsed.TotalSeconds); diff --git a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs index 031f0ec3..94b89632 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs @@ -658,6 +658,11 @@ namespace Newtonsoft.Json.Tests.Linq v = new JValue(new BigInteger(3)); Assert.AreEqual(TypeCode.Object, v.GetTypeCode()); #endif + +#if !(NET20) + v = new JValue(new DateTimeOffset(2000, 12, 12, 12, 12, 12, TimeSpan.Zero)); + Assert.AreEqual(TypeCode.Object, v.GetTypeCode()); +#endif } [Test] diff --git a/Src/Newtonsoft.Json/Linq/JValue.cs b/Src/Newtonsoft.Json/Linq/JValue.cs index 8e2cf36b..24fee13e 100644 --- a/Src/Newtonsoft.Json/Linq/JValue.cs +++ b/Src/Newtonsoft.Json/Linq/JValue.cs @@ -973,15 +973,6 @@ namespace Newtonsoft.Json.Linq if (_value == null) return TypeCode.Empty; -#if !NET20 - if (_value is DateTimeOffset) - return TypeCode.DateTime; -#endif -#if !(NET20 || NET35 || PORTABLE40) - if (_value is BigInteger) - return TypeCode.Object; -#endif - IConvertible convertable = _value as IConvertible; if (convertable == null)