This commit is contained in:
James Newton-King
2017-04-08 14:59:31 +12:00
parent 3531e705a1
commit c89b5b45aa
37 changed files with 173 additions and 150 deletions
+50 -97
View File
@@ -28,13 +28,13 @@
$nunitConsoleVersion = "3.6.1" $nunitConsoleVersion = "3.6.1"
$nunitConsolePath = "$buildDir\Temp\NUnit.ConsoleRunner.$nunitConsoleVersion" $nunitConsolePath = "$buildDir\Temp\NUnit.ConsoleRunner.$nunitConsoleVersion"
$builds = @( $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.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 = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net45"; Framework="net-4.0"; 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 = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "portable-net45+win8+wpa81+wp8"; 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 = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "portable-net40+sl5+win8+wpa81+wp8"; 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 = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net40"; 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 = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net35"; Framework="net-2.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 = "MSBuildBuild"; TestsFunction = "NUnitTests"; NuGetDir = "net20"; 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" 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 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 -ForegroundColor Green "Updating assembly version"
Write-Host Write-Host
Update-AssemblyInfoFiles $workingSourceDir ($majorVersion + '.0.0') $version 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) foreach ($build in $builds)
{ {
$name = $build.Name $name = $build.Name
@@ -86,7 +96,7 @@ task Build -depends Clean {
Write-Host -ForegroundColor Green "Key " $signKeyPath Write-Host -ForegroundColor Green "Key " $signKeyPath
Write-Host -ForegroundColor Green "Enabled " $enabled Write-Host -ForegroundColor Green "Enabled " $enabled
if ($enabled) if ($enabled -and $build.BuildFunction)
{ {
& $build.BuildFunction $build & $build.BuildFunction $build
} }
@@ -113,50 +123,12 @@ task Package -depends Build {
if ($buildNuGet) 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" mkdir $workingDir\NuGet
Copy-Item -Path "$buildDir\Newtonsoft.Json.nuspec" -Destination $nuspecPath -recurse move -Path $workingSourceDir\Newtonsoft.Json\bin\Release\*.nupkg -Destination $workingDir\NuGet
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
} }
Write-Host "Build documentation: $buildDocumentation" 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() function EnsureNuGetExists()
{ {
if (!(Test-Path $nugetPath)) if (!(Test-Path $nugetPath))
@@ -252,7 +206,6 @@ function GetMsBuildPath()
function NetCliBuild($build) function NetCliBuild($build)
{ {
$name = $build.Name $name = $build.Name
$framework = $build.NuGetDir
$projectPath = "$workingSourceDir\Newtonsoft.Json.Roslyn.sln" $projectPath = "$workingSourceDir\Newtonsoft.Json.Roslyn.sln"
$additionalConstants = switch($signAssemblies) { $true { "SIGNED" } default { "" } } $additionalConstants = switch($signAssemblies) { $true { "SIGNED" } default { "" } }
@@ -272,24 +225,36 @@ function NetCliTests($build)
$name = $build.TestsName $name = $build.TestsName
$projectPath = "$workingSourceDir\Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.Roslyn.csproj" $projectPath = "$workingSourceDir\Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.Roslyn.csproj"
$location = "$workingSourceDir\Newtonsoft.Json.Tests" $location = "$workingSourceDir\Newtonsoft.Json.Tests"
$finalDirs = $build.TestDir.Split(",")
$enabled = $build.Enabled
exec { .\Tools\Dotnet\dotnet-install.ps1 -Version $netCliVersion | Out-Default } 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 -ForegroundColor Green "Running tests for $name"
Write-Host Write-Host
exec { dotnet test $projectPath -f netcoreapp1.1 -c Release -l trx | Out-Default } foreach ($finalDir in $finalDirs)
copy-item -Path "$location\TestResults\*.trx" -Destination $workingDir {
} Write-Host -ForegroundColor Green "Test target $finalDir"
finally Write-Host
{
Set-Location $baseDir 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 $name = $build.TestsName
$finalDir = $build.NuGetDir $finalDir = $build.NuGetDir
$testDir = if ($build.TestDir -ne $null) { $build.TestDir } else { $finalDir }
$framework = $build.Framework $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 -ForegroundColor Green "Copying test assembly $name to deployed directory"
Write-Host Write-Host
robocopy "$workingSourceDir\Newtonsoft.Json.Tests\bin\Release\$finalDir" $workingDir\Deployed\Bin\$finalDir /MIR /NFL /NDL /NJS /NC /NS /NP /XO | Out-Default robocopy "$workingSourceDir\Newtonsoft.Json.Tests\bin\Release\$testDir" $testRunDir /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
Write-Host -ForegroundColor Green "Running NUnit tests " $name Write-Host -ForegroundColor Green "Running NUnit tests " $name
Write-Host Write-Host
try try
{ {
Set-Location $testDir Set-Location $testRunDir
exec { & $nunitConsolePath\tools\nunit3-console.exe "$testDir\Newtonsoft.Json.Tests.dll" --framework=$framework --result=$workingDir\$name.xml | Out-Default } "Error running $name tests" exec { & $nunitConsolePath\tools\nunit3-console.exe "$testRunDir\Newtonsoft.Json.Tests.dll" --framework=$framework --result=$workingDir\$name.xml | Out-Default } "Error running $name tests"
} }
finally finally
{ {
@@ -319,17 +283,6 @@ function NUnitTests($build)
} }
} }
function GetNuGetVersion()
{
$nugetVersion = $majorWithReleaseVersion
if ($nugetPrerelease -ne $null)
{
$nugetVersion = $nugetVersion + "-" + $nugetPrerelease
}
return $nugetVersion
}
function GetVersion($majorVersion) function GetVersion($majorVersion)
{ {
$now = [DateTime]::Now $now = [DateTime]::Now
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Net20", "Newtonsoft.Json\Newtonsoft.Json.Net20.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}"
EndProject EndProject
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Net35", "Newtonsoft.Json\Newtonsoft.Json.Net35.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}"
EndProject EndProject
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Net40", "Newtonsoft.Json\Newtonsoft.Json.Net40.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}"
EndProject EndProject
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Portable", "Newtonsoft.Json\Newtonsoft.Json.Portable.csproj", "{959F7F85-C98B-4876-971A-9036224578E4}"
EndProject EndProject
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Portable40", "Newtonsoft.Json\Newtonsoft.Json.Portable40.csproj", "{959F7F85-C98B-4876-971A-9036224578E4}"
EndProject EndProject
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
namespace Newtonsoft.Json.Tests.Benchmarks namespace Newtonsoft.Json.Tests.Benchmarks
{ {
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System.IO; using System.IO;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40) || DNXCORE50 #if HAVE_BENCHMARKS
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE || DNXCORE50) #if !(NET35 || NET20 || PORTABLE || PORTABLE40 || DNXCORE50)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE || DNXCORE50) #if !(NET35 || NET20 || DNXCORE50)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35) #if !(NET20 || NET35 || PORTABLE40)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35) #if !(NET20 || NET35 || PORTABLE40)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !DNXCORE50 #if !(DNXCORE50 || PORTABLE || PORTABLE40)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || DNXCORE50) #if !(NET20 || NET35 || NET40 || DNXCORE50 || PORTABLE40 || PORTABLE)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !DNXCORE50 #if !(DNXCORE50 || PORTABLE || PORTABLE40)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !NET20 #if !(NET20 || PORTABLE40)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -36,7 +36,7 @@ using NUnit.Framework;
#endif #endif
#if !(DNXCORE50 || NET20) #if !(DNXCORE50 || NET20 || PORTABLE || PORTABLE40)
namespace Newtonsoft.Json.Tests.Documentation.Samples.Xml namespace Newtonsoft.Json.Tests.Documentation.Samples.Xml
{ {
@@ -36,7 +36,7 @@ using NUnit.Framework;
#endif #endif
#if !(NET20 || DNXCORE50) #if !(NET20 || DNXCORE50 || PORTABLE || PORTABLE40)
namespace Newtonsoft.Json.Tests.Documentation.Samples.Xml namespace Newtonsoft.Json.Tests.Documentation.Samples.Xml
{ {
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE || DNXCORE50) #if !(NET35 || NET20 || DNXCORE50)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -326,6 +326,7 @@
<Compile Include="TestObjects\WidgetId1.cs" /> <Compile Include="TestObjects\WidgetId1.cs" />
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" /> <Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
<Compile Include="TestObjects\WithEnums.cs" /> <Compile Include="TestObjects\WithEnums.cs" />
<Compile Include="Utilities\ConvertUtilsTests.cs" />
<Compile Include="Utilities\DateTimeUtilsTests.cs" /> <Compile Include="Utilities\DateTimeUtilsTests.cs" />
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" /> <Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" /> <Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
@@ -6,18 +6,19 @@
</ItemGroup> </ItemGroup>
</Target> </Target>
<PropertyGroup> <PropertyGroup>
<TargetFrameworks Condition="'$(DotnetOnly)'==''">net45;net40;net35;net20;netcoreapp1.1</TargetFrameworks> <TargetFrameworks>net45;net451;net452;net40;net35;net20;netcoreapp1.1;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotnetOnly)'=='true'">netcoreapp1.1</TargetFrameworks> <VersionPrefix>1.0</VersionPrefix>
<VersionPrefix>10.0.1</VersionPrefix>
<Authors>James Newton-King</Authors> <Authors>James Newton-King</Authors>
<NeutralLanguage>en-US</NeutralLanguage> <NeutralLanguage>en-US</NeutralLanguage>
<Copyright>Copyright © James Newton-King 2008</Copyright> <Copyright>Copyright © James Newton-King 2008</Copyright>
<AssemblyName>Newtonsoft.Json.Tests</AssemblyName> <AssemblyName>Newtonsoft.Json.Tests</AssemblyName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!-- Workaround for https://github.com/nunit/nunit3-vs-adapter/issues/296 --> <!-- Workaround for https://github.com/nunit/nunit3-vs-adapter/issues/296 -->
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp1.1'">Full</DebugType> <DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp1.0' AND '$(TargetFramework)' != 'netcoreapp1.1'">Full</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- Tracking for removal https://github.com/Microsoft/vstest/issues/472 -->
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
<None Remove="**\*.orig" /> <None Remove="**\*.orig" />
<None Include="large.json"> <None Include="large.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -39,6 +40,7 @@
</None> </None>
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Roslyn.csproj" /> <ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Roslyn.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net45'"> <ItemGroup Condition="'$(TargetFramework)'=='net45'">
<PackageReference Include="NUnit" Version="3.6.0" /> <PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
@@ -57,8 +59,53 @@
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net45'"> <PropertyGroup Condition="'$(TargetFramework)'=='net45'">
<DefineConstants>NET45;$(AdditionalConstants)</DefineConstants> <DefineConstants>NET45;HAVE_BENCHMARKS;$(AdditionalConstants)</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net451'">
<PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
<PackageReference Include="Autofac" Version="4.4.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.10.2" />
<PackageReference Include="FSharp.Core" Version="4.1.2" />
<PackageReference Include="System.Buffers" Version="4.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Data.DataSetExtensions" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net451'">
<ReferringTargetFrameworkForProjectReferences>.NETPortable,Version=v0.0,Profile=Profile328</ReferringTargetFrameworkForProjectReferences>
<DefineConstants>PORTABLE40;$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net452'">
<PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
<PackageReference Include="Autofac" Version="4.4.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.10.2" />
<PackageReference Include="FSharp.Core" Version="4.1.2" />
<PackageReference Include="System.Buffers" Version="4.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Data.DataSetExtensions" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net452'">
<ReferringTargetFrameworkForProjectReferences>.NETPortable,Version=v0.0,Profile=Profile259</ReferringTargetFrameworkForProjectReferences>
<DefineConstants>PORTABLE;$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net40'"> <ItemGroup Condition="'$(TargetFramework)'=='net40'">
<PackageReference Include="NUnit" Version="3.6.0" /> <PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
@@ -75,6 +122,7 @@
<PropertyGroup Condition="'$(TargetFramework)'=='net40'"> <PropertyGroup Condition="'$(TargetFramework)'=='net40'">
<DefineConstants>NET40;$(AdditionalConstants)</DefineConstants> <DefineConstants>NET40;$(AdditionalConstants)</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net35'"> <ItemGroup Condition="'$(TargetFramework)'=='net35'">
<PackageReference Include="NUnit" Version="3.6.0" /> <PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
@@ -88,6 +136,7 @@
<PropertyGroup Condition="'$(TargetFramework)'=='net35'"> <PropertyGroup Condition="'$(TargetFramework)'=='net35'">
<DefineConstants>NET35;$(AdditionalConstants)</DefineConstants> <DefineConstants>NET35;$(AdditionalConstants)</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net20'"> <ItemGroup Condition="'$(TargetFramework)'=='net20'">
<PackageReference Include="NUnit" Version="3.6.0" /> <PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
@@ -96,6 +145,7 @@
<PropertyGroup Condition="'$(TargetFramework)'=='net20'"> <PropertyGroup Condition="'$(TargetFramework)'=='net20'">
<DefineConstants>NET20;$(AdditionalConstants)</DefineConstants> <DefineConstants>NET20;$(AdditionalConstants)</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'"> <ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'">
<PackageReference Include="BenchmarkDotNet" Version="0.10.2" /> <PackageReference Include="BenchmarkDotNet" Version="0.10.2" />
<PackageReference Include="FSharp.Core" Version="4.1.2" /> <PackageReference Include="FSharp.Core" Version="4.1.2" />
@@ -105,16 +155,29 @@
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" /> <PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" /> <PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" /> <PackageReference Include="System.ValueTuple" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.2.0" /> <PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<!-- Tracking for removal https://github.com/Microsoft/vstest/issues/472 -->
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'"> <PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'">
<DefineConstants>NETSTANDARD1_3;DNXCORE50;PORTABLE;$(AdditionalConstants)</DefineConstants> <ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v1.3</ReferringTargetFrameworkForProjectReferences>
<DefineConstants>NETSTANDARD1_3;DNXCORE50;PORTABLE;HAVE_BENCHMARKS;$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.0'">
<PackageReference Include="FSharp.Core" Version="4.1.2" />
<PackageReference Include="System.ObjectModel" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Xml" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp1.0'">
<ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v1.0</ReferringTargetFrameworkForProjectReferences>
<DefineConstants>NETSTANDARD1_0;DNXCORE50;PORTABLE;$(AdditionalConstants)</DefineConstants>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
@@ -215,7 +215,10 @@ namespace Newtonsoft.Json.Tests.Utilities
AssertDecimalTryParse("1.2345678901234567890123456789e-26", ParseResult.Success, 0.0000000000000000000000000123M); AssertDecimalTryParse("1.2345678901234567890123456789e-26", ParseResult.Success, 0.0000000000000000000000000123M);
AssertDecimalTryParse("1.2345678901234567890123456789e-28", ParseResult.Success, 0.0000000000000000000000000001M); AssertDecimalTryParse("1.2345678901234567890123456789e-28", ParseResult.Success, 0.0000000000000000000000000001M);
AssertDecimalTryParse("1.2345678901234567890123456789e-29", ParseResult.Success, 0M); AssertDecimalTryParse("1.2345678901234567890123456789e-29", ParseResult.Success, 0M);
#if !(NET20 || NET35)
AssertDecimalTryParse("1E-999", ParseResult.Success, 0M); AssertDecimalTryParse("1E-999", ParseResult.Success, 0M);
#endif
for (decimal i = -100; i < 100; i += 0.1m) for (decimal i = -100; i < 100; i += 0.1m)
{ {
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 15
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json", "Newtonsoft.Json\Newtonsoft.Json.csproj", "{EEEA67F9-9089-481D-A4DC-0966DEC9FD7D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json", "Newtonsoft.Json\Newtonsoft.Json.csproj", "{EEEA67F9-9089-481D-A4DC-0966DEC9FD7D}"
EndProject EndProject
@@ -124,10 +124,6 @@ namespace Newtonsoft.Json.Converters
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{ {
bool nullable = ReflectionUtils.IsNullableType(objectType); bool nullable = ReflectionUtils.IsNullableType(objectType);
Type t = (nullable)
? Nullable.GetUnderlyingType(objectType)
: objectType;
if (reader.TokenType == JsonToken.Null) if (reader.TokenType == JsonToken.Null)
{ {
if (!ReflectionUtils.IsNullableType(objectType)) if (!ReflectionUtils.IsNullableType(objectType))
@@ -138,6 +134,12 @@ namespace Newtonsoft.Json.Converters
return null; return null;
} }
#if HAVE_DATE_TIME_OFFSET
Type t = (nullable)
? Nullable.GetUnderlyingType(objectType)
: objectType;
#endif
if (reader.TokenType == JsonToken.Date) if (reader.TokenType == JsonToken.Date)
{ {
#if HAVE_DATE_TIME_OFFSET #if HAVE_DATE_TIME_OFFSET
@@ -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)); 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)) Type t = (ReflectionUtils.IsNullableType(objectType))
? Nullable.GetUnderlyingType(objectType) ? Nullable.GetUnderlyingType(objectType)
: objectType; : objectType;
#if HAVE_DATE_TIME_OFFSET
if (t == typeof(DateTimeOffset)) if (t == typeof(DateTimeOffset))
{ {
return new DateTimeOffset(d); return new DateTimeOffset(d);
@@ -23,7 +23,8 @@
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion> <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="../../LICENSE.md" Pack="true" PackagePath="LICENSE.md" /> <None Include="..\..\LICENSE.md" Pack="true" PackagePath="LICENSE.md" />
<None Include="..\..\Build\install.ps1" Pack="true" PackagePath="tools\install.ps1" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net45'"> <PropertyGroup Condition="'$(TargetFramework)'=='net45'">
<AssemblyTitle>Json.NET</AssemblyTitle> <AssemblyTitle>Json.NET</AssemblyTitle>