diff --git a/Build/build.ps1 b/Build/build.ps1 index f9ee44aa..1f6f51c9 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -28,13 +28,13 @@ $nunitConsoleVersion = "3.6.1" $nunitConsolePath = "$buildDir\Temp\NUnit.ConsoleRunner.$nunitConsoleVersion" $builds = @( - @{Name = "Newtonsoft.Json.Roslyn"; TestsName = "Newtonsoft.Json.Tests.Roslyn"; BuildFunction = "NetCliBuild"; TestsFunction = "NetCliTests"; NuGetDir = "netstandard1.0,netstandard1.3"; Framework=$null; Enabled=$true}, - @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net45"; Framework="net-4.0"; Enabled=$true}, - @{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "portable-net45+win8+wpa81+wp8"; Framework="net-4.0"; Enabled=$true}, - @{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "portable-net40+sl5+win8+wpa81+wp8"; Framework="net-4.0"; Enabled=$true}, - @{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net40"; Framework="net-4.0"; Enabled=$true}, - @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net35"; Framework="net-2.0"; Enabled=$true}, - @{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net20"; Framework="net-2.0"; Enabled=$true} + @{Name = "Newtonsoft.Json.Roslyn"; TestsName = "Newtonsoft.Json.Tests.Roslyn"; BuildFunction = "NetCliBuild"; TestsFunction = "NetCliTests"; NuGetDir = "netstandard1.0,netstandard1.3"; TestDir = "netcoreapp1.0,netcoreapp1.1"; Framework=$null; Enabled=$true}, + @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; BuildFunction = $null; TestsFunction = "NUnitTests"; NuGetDir = "net45"; Framework="net-4.0"; Enabled=$true}, + @{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; BuildFunction = $null; TestsFunction = "NUnitTests"; NuGetDir = "portable-net45+win8+wpa81+wp8"; TestDir = "net452"; Framework="net-4.0"; Enabled=$true}, + @{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; BuildFunction = $null; TestsFunction = "NUnitTests"; NuGetDir = "portable-net40+sl5+win8+wpa81+wp8"; TestDir = "net451"; Framework="net-4.0"; Enabled=$true}, + @{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; BuildFunction = $null; TestsFunction = "NUnitTests"; NuGetDir = "net40"; Framework="net-4.0"; Enabled=$true}, + @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; BuildFunction = $null; TestsFunction = "NUnitTests"; NuGetDir = "net35"; Framework="net-2.0"; Enabled=$true}, + @{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; BuildFunction = $null; TestsFunction = "NUnitTests"; NuGetDir = "net20"; Framework="net-2.0"; Enabled=$true} ) } @@ -70,11 +70,21 @@ 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 artifacts /XF *.suo *.user *.lock.json | Out-Default + Copy-Item -Path $baseDir\LICENSE.md -Destination $workingDir\ + mkdir "$workingDir\Build" -Force + Copy-Item -Path $buildDir\install.ps1 -Destination $workingDir\Build\ Write-Host -ForegroundColor Green "Updating assembly version" Write-Host Update-AssemblyInfoFiles $workingSourceDir ($majorVersion + '.0.0') $version + $xml = [xml](Get-Content "$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.Roslyn.csproj") + Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/PackageId" -value $packageId + Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/VersionPrefix" -value $majorWithReleaseVersion + Edit-XmlNodes -doc $xml -xpath "/Project/PropertyGroup/VersionSuffix" -value $nugetPrerelease + + $xml.save("$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.Roslyn.csproj") + foreach ($build in $builds) { $name = $build.Name @@ -86,7 +96,7 @@ task Build -depends Clean { Write-Host -ForegroundColor Green "Key " $signKeyPath Write-Host -ForegroundColor Green "Enabled " $enabled - if ($enabled) + if ($enabled -and $build.BuildFunction) { & $build.BuildFunction $build } @@ -113,50 +123,12 @@ task Package -depends Build { if ($buildNuGet) { - $nugetVersion = GetNuGetVersion + Write-Host -ForegroundColor Green "Creating NuGet package" - New-Item -Path $workingDir\NuGet -ItemType Directory + exec { & $script:msBuildPath "/t:pack" "/p:IncludeSource=true" "/p:Configuration=Release" "$workingSourceDir\Newtonsoft.Json\Newtonsoft.Json.Roslyn.csproj" } - $nuspecPath = "$workingDir\NuGet\Newtonsoft.Json.nuspec" - Copy-Item -Path "$buildDir\Newtonsoft.Json.nuspec" -Destination $nuspecPath -recurse - - Write-Host "Updating nuspec file at $nuspecPath" -ForegroundColor Green - Write-Host - - $xml = [xml](Get-Content $nuspecPath) - Edit-XmlNodes -doc $xml -xpath "//*[local-name() = 'id']" -value $packageId - Edit-XmlNodes -doc $xml -xpath "//*[local-name() = 'version']" -value $nugetVersion - - Write-Host $xml.OuterXml - - $xml.save($nuspecPath) - - New-Item -Path $workingDir\NuGet\tools -ItemType Directory - Copy-Item -Path "$buildDir\install.ps1" -Destination $workingDir\NuGet\tools\install.ps1 -recurse - Copy-Item -Path "$baseDir\LICENSE.md" -Destination $workingDir\NuGet\LICENSE.md -recurse - - foreach ($build in $builds) - { - if ($build.Enabled -and $build.NuGetDir) - { - $name = $build.TestsName - $frameworkDirs = $build.NuGetDir.Split(",") - - foreach ($frameworkDir in $frameworkDirs) - { - robocopy "$workingSourceDir\Newtonsoft.Json\bin\Release\$frameworkDir" $workingDir\NuGet\lib\$frameworkDir *.dll *.pdb *.xml /NFL /NDL /NJS /NC /NS /NP /XO /XF *.CodeAnalysisLog.xml | Out-Default - } - } - } - - robocopy $workingSourceDir $workingDir\NuGet\src *.cs /S /NFL /NDL /NJS /NC /NS /NP /XD Newtonsoft.Json.Tests Newtonsoft.Json.TestConsole obj .vs artifacts | Out-Default - - Write-Host "Building NuGet package with ID $packageId and version $nugetVersion" -ForegroundColor Green - Write-Host - - exec { & $nugetPath pack $nuspecPath -Symbols } - - move -Path .\*.nupkg -Destination $workingDir\NuGet + mkdir $workingDir\NuGet + move -Path $workingSourceDir\Newtonsoft.Json\bin\Release\*.nupkg -Destination $workingDir\NuGet } Write-Host "Build documentation: $buildDocumentation" @@ -204,24 +176,6 @@ task Test -depends Deploy { } } -function MSBuildBuild($build) -{ - $name = $build.Name - $finalDir = $build.NuGetDir - - Write-Host - Write-Host "Restoring $workingSourceDir\$name.sln" -ForegroundColor Green - [Environment]::SetEnvironmentVariable("EnableNuGetPackageRestore", "true", "Process") - exec { & $nugetPath update -self } - exec { & $nugetPath restore "$workingSourceDir\$name.sln" -verbosity detailed -configfile $workingSourceDir\nuget.config | Out-Default } "Error restoring $name" - - $additionalConstants = switch($signAssemblies) { $true { "SIGNED" } default { "" } } - - Write-Host - Write-Host "Building $workingSourceDir\$name.sln" -ForegroundColor Green - exec { & $script:msBuildPath "/t:Clean;Rebuild" /p:Configuration=Release "/p:CopyNuGetImplementations=true" "/p:Platform=Any CPU" "/p:PlatformTarget=AnyCPU" /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$signAssemblies" "/p:TreatWarningsAsErrors=$treatWarningsAsErrors" "/p:AdditionalConstants=$additionalConstants" "$workingSourceDir\$name.sln" | Out-Default } "Error building $name" -} - function EnsureNuGetExists() { if (!(Test-Path $nugetPath)) @@ -252,7 +206,6 @@ function GetMsBuildPath() function NetCliBuild($build) { $name = $build.Name - $framework = $build.NuGetDir $projectPath = "$workingSourceDir\Newtonsoft.Json.Roslyn.sln" $additionalConstants = switch($signAssemblies) { $true { "SIGNED" } default { "" } } @@ -272,24 +225,36 @@ function NetCliTests($build) $name = $build.TestsName $projectPath = "$workingSourceDir\Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.Roslyn.csproj" $location = "$workingSourceDir\Newtonsoft.Json.Tests" + $finalDirs = $build.TestDir.Split(",") + $enabled = $build.Enabled exec { .\Tools\Dotnet\dotnet-install.ps1 -Version $netCliVersion | Out-Default } - try + if ($enabled) { - Set-Location $location + try + { + Set-Location $location - exec { dotnet --version | Out-Default } + exec { dotnet --version | Out-Default } - Write-Host -ForegroundColor Green "Ensuring test project builds for $name" - Write-Host + Write-Host -ForegroundColor Green "Running tests for $name" + Write-Host - exec { dotnet test $projectPath -f netcoreapp1.1 -c Release -l trx | Out-Default } - copy-item -Path "$location\TestResults\*.trx" -Destination $workingDir - } - finally - { - Set-Location $baseDir + foreach ($finalDir in $finalDirs) + { + Write-Host -ForegroundColor Green "Test target $finalDir" + Write-Host + + exec { dotnet test $projectPath -f $finalDir -c Release -l trx | Out-Default } + copy-item -Path "$location\TestResults\*.trx" -Destination $workingDir + } + + } + finally + { + Set-Location $baseDir + } } } @@ -297,21 +262,20 @@ function NUnitTests($build) { $name = $build.TestsName $finalDir = $build.NuGetDir + $testDir = if ($build.TestDir -ne $null) { $build.TestDir } else { $finalDir } $framework = $build.Framework - $testDir = "$workingDir\Deployed\Bin\$finalDir" + $testRunDir = "$workingDir\Deployed\Bin\$finalDir" Write-Host -ForegroundColor Green "Copying test assembly $name to deployed directory" Write-Host - robocopy "$workingSourceDir\Newtonsoft.Json.Tests\bin\Release\$finalDir" $workingDir\Deployed\Bin\$finalDir /MIR /NFL /NDL /NJS /NC /NS /NP /XO | Out-Default - - Copy-Item -Path "$workingSourceDir\Newtonsoft.Json.Tests\bin\Release\$finalDir\Newtonsoft.Json.Tests.dll" -Destination $testDir + robocopy "$workingSourceDir\Newtonsoft.Json.Tests\bin\Release\$testDir" $testRunDir /MIR /NFL /NDL /NJS /NC /NS /NP /XO | Out-Default Write-Host -ForegroundColor Green "Running NUnit tests " $name Write-Host try { - Set-Location $testDir - exec { & $nunitConsolePath\tools\nunit3-console.exe "$testDir\Newtonsoft.Json.Tests.dll" --framework=$framework --result=$workingDir\$name.xml | Out-Default } "Error running $name tests" + Set-Location $testRunDir + exec { & $nunitConsolePath\tools\nunit3-console.exe "$testRunDir\Newtonsoft.Json.Tests.dll" --framework=$framework --result=$workingDir\$name.xml | Out-Default } "Error running $name tests" } finally { @@ -319,17 +283,6 @@ function NUnitTests($build) } } -function GetNuGetVersion() -{ - $nugetVersion = $majorWithReleaseVersion - if ($nugetPrerelease -ne $null) - { - $nugetVersion = $nugetVersion + "-" + $nugetPrerelease - } - - return $nugetVersion -} - function GetVersion($majorVersion) { $now = [DateTime]::Now diff --git a/Src/Newtonsoft.Json.Net20.sln b/Src/Newtonsoft.Json.Net20.sln index ebb76225..d415876a 100644 --- a/Src/Newtonsoft.Json.Net20.sln +++ b/Src/Newtonsoft.Json.Net20.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Net20", "Newtonsoft.Json\Newtonsoft.Json.Net20.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}" EndProject diff --git a/Src/Newtonsoft.Json.Net35.sln b/Src/Newtonsoft.Json.Net35.sln index eb7de416..89b797b1 100644 --- a/Src/Newtonsoft.Json.Net35.sln +++ b/Src/Newtonsoft.Json.Net35.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Net35", "Newtonsoft.Json\Newtonsoft.Json.Net35.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}" EndProject diff --git a/Src/Newtonsoft.Json.Net40.sln b/Src/Newtonsoft.Json.Net40.sln index 5af5dcbc..162ecc54 100644 --- a/Src/Newtonsoft.Json.Net40.sln +++ b/Src/Newtonsoft.Json.Net40.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Net40", "Newtonsoft.Json\Newtonsoft.Json.Net40.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}" EndProject diff --git a/Src/Newtonsoft.Json.Portable.sln b/Src/Newtonsoft.Json.Portable.sln index 21705b08..d6288e29 100644 --- a/Src/Newtonsoft.Json.Portable.sln +++ b/Src/Newtonsoft.Json.Portable.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Portable", "Newtonsoft.Json\Newtonsoft.Json.Portable.csproj", "{959F7F85-C98B-4876-971A-9036224578E4}" EndProject diff --git a/Src/Newtonsoft.Json.Portable40.sln b/Src/Newtonsoft.Json.Portable40.sln index 0529cddc..3fba6697 100644 --- a/Src/Newtonsoft.Json.Portable40.sln +++ b/Src/Newtonsoft.Json.Portable40.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Portable40", "Newtonsoft.Json\Newtonsoft.Json.Portable40.csproj", "{959F7F85-C98B-4876-971A-9036224578E4}" EndProject diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/BenchmarkConstants.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/BenchmarkConstants.cs index 93e90a2c..d6b57d32 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/BenchmarkConstants.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/BenchmarkConstants.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS namespace Newtonsoft.Json.Tests.Benchmarks { diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeBenchmarks.cs index 04653d28..4c1ddc65 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeComparisonBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeComparisonBenchmarks.cs index 57f1df17..b0ab7aa3 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeComparisonBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/DeserializeComparisonBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/JTokenBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/JTokenBenchmarks.cs index a4f03657..f5200f7b 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/JTokenBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/JTokenBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/JValueConvertBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/JValueConvertBenchmarks.cs index ab6398e6..36de80e0 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/JValueConvertBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/JValueConvertBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextReaderBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextReaderBenchmarks.cs index 64bb9f15..27f8625c 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextReaderBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextReaderBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System.IO; using System.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextWriterBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextWriterBenchmarks.cs index a1cbac30..68db23eb 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextWriterBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/JsonTextWriterBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System.IO; using BenchmarkDotNet.Attributes; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/LargeJArrayBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/LargeJArrayBenchmarks.cs index 2b3a941a..8ed55418 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/LargeJArrayBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/LargeJArrayBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/LowLevelBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/LowLevelBenchmarks.cs index eac38903..6cf7f7de 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/LowLevelBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/LowLevelBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/Runner.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/Runner.cs index 213e5a82..4b8778ff 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/Runner.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/Runner.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeBenchmarks.cs index 4a484fde..ed48a249 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeComparisonBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeComparisonBenchmarks.cs index a7dfa8ad..923bea7e 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeComparisonBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/SerializeComparisonBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Benchmarks/XmlNodeConverterBenchmarks.cs b/Src/Newtonsoft.Json.Tests/Benchmarks/XmlNodeConverterBenchmarks.cs index e41a11cb..8561c908 100644 --- a/Src/Newtonsoft.Json.Tests/Benchmarks/XmlNodeConverterBenchmarks.cs +++ b/Src/Newtonsoft.Json.Tests/Benchmarks/XmlNodeConverterBenchmarks.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 +#if HAVE_BENCHMARKS using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs index e8145f7c..868c75ce 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE || DNXCORE50) +#if !(NET35 || NET20 || PORTABLE || PORTABLE40 || DNXCORE50) using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs index c7afa7ef..cd471581 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE || DNXCORE50) +#if !(NET35 || NET20 || DNXCORE50) using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/CreateJsonDynamic.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/CreateJsonDynamic.cs index f92c5875..7b4b0a89 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/CreateJsonDynamic.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/CreateJsonDynamic.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35) +#if !(NET20 || NET35 || PORTABLE40) using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/QueryJsonDynamic.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/QueryJsonDynamic.cs index 7db8b040..5ca0101a 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/QueryJsonDynamic.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Linq/QueryJsonDynamic.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35) +#if !(NET20 || NET35 || PORTABLE40) using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs index 88576578..1ea214f9 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !DNXCORE50 +#if !(DNXCORE50 || PORTABLE || PORTABLE40) using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeWithDependencyInjection.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeWithDependencyInjection.cs index 0ba41418..4ac884d2 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeWithDependencyInjection.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeWithDependencyInjection.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || DNXCORE50) +#if !(NET20 || NET35 || NET40 || DNXCORE50 || PORTABLE40 || PORTABLE) using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs index 559d83c2..2313f5aa 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !DNXCORE50 +#if !(DNXCORE50 || PORTABLE || PORTABLE40) using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertJsonToXml.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertJsonToXml.cs index 484a19e7..07861979 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertJsonToXml.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertJsonToXml.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !NET20 +#if !(NET20 || PORTABLE40) using System; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJson.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJson.cs index 6010ec9a..188e6885 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJson.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJson.cs @@ -36,7 +36,7 @@ using NUnit.Framework; #endif -#if !(DNXCORE50 || NET20) +#if !(DNXCORE50 || NET20 || PORTABLE || PORTABLE40) namespace Newtonsoft.Json.Tests.Documentation.Samples.Xml { diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJsonForceArray.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJsonForceArray.cs index be83962a..aa4a00fe 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJsonForceArray.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Xml/ConvertXmlToJsonForceArray.cs @@ -36,7 +36,7 @@ using NUnit.Framework; #endif -#if !(NET20 || DNXCORE50) +#if !(NET20 || DNXCORE50 || PORTABLE || PORTABLE40) namespace Newtonsoft.Json.Tests.Documentation.Samples.Xml { diff --git a/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs index d50d8662..7c02ae49 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE || DNXCORE50) +#if !(NET35 || NET20 || DNXCORE50) using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj index feb3e2ec..d0917c8e 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj @@ -326,6 +326,7 @@ + diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Roslyn.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Roslyn.csproj index 514c994f..e1b4fb8f 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Roslyn.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Roslyn.csproj @@ -6,18 +6,19 @@ - net45;net40;net35;net20;netcoreapp1.1 - netcoreapp1.1 - 10.0.1 + net45;net451;net452;net40;net35;net20;netcoreapp1.1;netcoreapp1.0 + 1.0 James Newton-King en-US Copyright © James Newton-King 2008 Newtonsoft.Json.Tests false - Full + Full + + PreserveNewest @@ -39,6 +40,7 @@ + @@ -57,8 +59,53 @@ - NET45;$(AdditionalConstants) + NET45;HAVE_BENCHMARKS;$(AdditionalConstants) + + + + + + + + + + + + + + + + + + + + .NETPortable,Version=v0.0,Profile=Profile328 + PORTABLE40;$(AdditionalConstants) + + + + + + + + + + + + + + + + + + + + + .NETPortable,Version=v0.0,Profile=Profile259 + PORTABLE;$(AdditionalConstants) + + @@ -75,6 +122,7 @@ NET40;$(AdditionalConstants) + @@ -88,6 +136,7 @@ NET35;$(AdditionalConstants) + @@ -96,6 +145,7 @@ NET20;$(AdditionalConstants) + @@ -105,16 +155,29 @@ - - - - - - NETSTANDARD1_3;DNXCORE50;PORTABLE;$(AdditionalConstants) + .NETStandard,Version=v1.3 + NETSTANDARD1_3;DNXCORE50;PORTABLE;HAVE_BENCHMARKS;$(AdditionalConstants) + + + + + + + + + + + + + + + + .NETStandard,Version=v1.0 + NETSTANDARD1_0;DNXCORE50;PORTABLE;$(AdditionalConstants) \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Utilities/ConvertUtilsTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/ConvertUtilsTests.cs index 94dd81b1..25557b6b 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/ConvertUtilsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/ConvertUtilsTests.cs @@ -215,7 +215,10 @@ namespace Newtonsoft.Json.Tests.Utilities AssertDecimalTryParse("1.2345678901234567890123456789e-26", ParseResult.Success, 0.0000000000000000000000000123M); AssertDecimalTryParse("1.2345678901234567890123456789e-28", ParseResult.Success, 0.0000000000000000000000000001M); AssertDecimalTryParse("1.2345678901234567890123456789e-29", ParseResult.Success, 0M); + +#if !(NET20 || NET35) AssertDecimalTryParse("1E-999", ParseResult.Success, 0M); +#endif for (decimal i = -100; i < 100; i += 0.1m) { diff --git a/Src/Newtonsoft.Json.sln b/Src/Newtonsoft.Json.sln index d7956f25..0a294d56 100644 --- a/Src/Newtonsoft.Json.sln +++ b/Src/Newtonsoft.Json.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json", "Newtonsoft.Json\Newtonsoft.Json.csproj", "{EEEA67F9-9089-481D-A4DC-0966DEC9FD7D}" EndProject diff --git a/Src/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs b/Src/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs index 3a960728..52490131 100644 --- a/Src/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs +++ b/Src/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs @@ -124,10 +124,6 @@ namespace Newtonsoft.Json.Converters public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { bool nullable = ReflectionUtils.IsNullableType(objectType); - Type t = (nullable) - ? Nullable.GetUnderlyingType(objectType) - : objectType; - if (reader.TokenType == JsonToken.Null) { if (!ReflectionUtils.IsNullableType(objectType)) @@ -138,6 +134,12 @@ namespace Newtonsoft.Json.Converters return null; } +#if HAVE_DATE_TIME_OFFSET + Type t = (nullable) + ? Nullable.GetUnderlyingType(objectType) + : objectType; +#endif + if (reader.TokenType == JsonToken.Date) { #if HAVE_DATE_TIME_OFFSET diff --git a/Src/Newtonsoft.Json/Converters/JavaScriptDateTimeConverter.cs b/Src/Newtonsoft.Json/Converters/JavaScriptDateTimeConverter.cs index db7e837d..40b18dee 100644 --- a/Src/Newtonsoft.Json/Converters/JavaScriptDateTimeConverter.cs +++ b/Src/Newtonsoft.Json/Converters/JavaScriptDateTimeConverter.cs @@ -111,10 +111,10 @@ namespace Newtonsoft.Json.Converters throw JsonSerializationException.Create(reader, "Unexpected token parsing date. Expected EndConstructor, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType)); } +#if HAVE_DATE_TIME_OFFSET Type t = (ReflectionUtils.IsNullableType(objectType)) ? Nullable.GetUnderlyingType(objectType) : objectType; -#if HAVE_DATE_TIME_OFFSET if (t == typeof(DateTimeOffset)) { return new DateTimeOffset(d); diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Roslyn.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Roslyn.csproj index bd794753..f4c96950 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Roslyn.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Roslyn.csproj @@ -23,7 +23,8 @@ 1.6.1 - + + Json.NET