Permalink
Browse files

Initial version.

  • Loading branch information...
1 parent 8880c66 commit fc1138725b072e74c7212d7d34e2e9df8717db02 Stuart Dallas committed Apr 27, 2012
Showing 474 changed files with 107,576 additions and 5 deletions.
View
@@ -3,4 +3,7 @@ bin
obj
# mstest test results
-TestResults
+TestResults
+Local.testsettings
+TraceAndTestImpact.testsettings
+datasift.vsmdi
View
Binary file not shown.
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <id>Newtonsoft.Json</id>
+ <version>4.5.3</version>
+ <title>Json.NET</title>
+ <description>Json.NET is a popular high-performance JSON framework for .NET</description>
+ <authors>James Newton-King</authors>
+ <language>en-US</language>
+ <projectUrl>http://james.newtonking.com/projects/json-net.aspx</projectUrl>
+ <licenseUrl>http://json.codeplex.com/license</licenseUrl>
+ <tags>json</tags>
+ </metadata>
+</package>
@@ -0,0 +1,200 @@
+properties {
+ $zipFileName = "Json45r3.zip"
+ $majorVersion = "4.5"
+ $majorWithReleaseVersion = "4.5.3"
+ $version = GetVersion $majorWithReleaseVersion
+ $signAssemblies = $false
+ $signKeyPath = "D:\Development\Releases\newtonsoft.snk"
+ $buildDocumentation = $false
+ $buildNuGet = $false
+
+ $baseDir = resolve-path ..
+ $buildDir = "$baseDir\Build"
+ $sourceDir = "$baseDir\Src"
+ $toolsDir = "$baseDir\Tools"
+ $docDir = "$baseDir\Doc"
+ $releaseDir = "$baseDir\Release"
+ $workingDir = "$baseDir\Working"
+ $builds = @(
+ @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
+ @{Name = "Newtonsoft.Json.Metro"; TestsName = $null; Constants="NETFX_CORE"; FinalDir="Metro"; NuGetDir = "winrt45"; Framework="net-4.5"; Sign=$true},
+
+ # unsigned SL/WP
+ @{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},
+ # signed SL/WP
+ @{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone\Signed"; NuGetDir = $null; Framework="net-4.0"; Sign=$true},
+ @{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight\Signed"; NuGetDir = $null; Framework="net-4.0"; Sign=$true},
+
+ @{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}
+ )
+}
+
+$framework = '4.0x86'
+
+task default -depends Test
+
+# Ensure a clean working directory
+task Clean {
+ Set-Location $baseDir
+
+ if (Test-Path -path $workingDir)
+ {
+ Write-Output "Deleting Working Directory"
+
+ del $workingDir -Recurse -Force
+ }
+
+ New-Item -Path $workingDir -ItemType Directory
+}
+
+# Build each solution, optionally signed
+task Build -depends Clean {
+ Write-Host -ForegroundColor Green "Updating assembly version"
+ Write-Host
+ Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0.0') $version
+
+ foreach ($build in $builds)
+ {
+ $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:Platform=Any CPU" /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$sign" (GetConstants $build.Constants $sign) ".\Src\$name.sln" } "Error building $name"
+ }
+}
+
+# Optional build documentation, add files to final zip
+task Package -depends Build {
+ foreach ($build in $builds)
+ {
+ $name = $build.TestsName
+ $finalDir = $build.FinalDir
+
+ robocopy "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" $workingDir\Package\Bin\$finalDir /NP /XO /XF *.pri
+ }
+
+ if ($buildNuGet)
+ {
+ New-Item -Path $workingDir\NuGet -ItemType Directory
+ Copy-Item -Path "$buildDir\Newtonsoft.Json.nuspec" -Destination $workingDir\NuGet\Newtonsoft.Json.nuspec -recurse
+
+ foreach ($build in $builds)
+ {
+ if ($build.NuGetDir -ne $null)
+ {
+ $name = $build.TestsName
+ $finalDir = $build.FinalDir
+ $frameworkDirs = $build.NuGetDir.Split(",")
+
+ foreach ($frameworkDir in $frameworkDirs)
+ {
+ robocopy "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" $workingDir\NuGet\lib\$frameworkDir /NP /XO /XF *.pri
+ }
+ }
+ }
+
+ exec { .\Tools\NuGet\NuGet.exe pack $workingDir\NuGet\Newtonsoft.Json.nuspec }
+ move -Path .\*.nupkg -Destination $workingDir\NuGet
+ }
+
+ if ($buildDocumentation)
+ {
+ $mainBuild = $builds | where { $_.Name -eq "Newtonsoft.Json" } | select -first 1
+ $mainBuildFinalDir = $mainBuild.FinalDir
+ $documentationSourcePath = "$workingDir\Package\Bin\$mainBuildFinalDir"
+ Write-Host -ForegroundColor Green "Building documentation from $documentationSourcePath"
+
+ # Sandcastle has issues when compiling with .NET 4 MSBuild - http://shfb.codeplex.com/Thread/View.aspx?ThreadId=50652
+ exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release "/p:DocumentationSourcePath=$documentationSourcePath" $docDir\doc.shfbproj } "Error building documentation. Check that you have Sandcastle, Sandcastle Help File Builder and HTML Help Workshop installed."
+
+ move -Path $workingDir\Documentation\Documentation.chm -Destination $workingDir\Package\Documentation.chm
+ move -Path $workingDir\Documentation\LastBuild.log -Destination $workingDir\Documentation.log
+ }
+
+ Copy-Item -Path $docDir\readme.txt -Destination $workingDir\Package\
+ Copy-Item -Path $docDir\versions.txt -Destination $workingDir\Package\Bin\
+
+ robocopy $sourceDir $workingDir\Package\Source\Src /MIR /NP /XD .svn bin obj TestResults AppPackages /XF *.suo *.user
+ robocopy $buildDir $workingDir\Package\Source\Build /MIR /NP /XD .svn
+ robocopy $docDir $workingDir\Package\Source\Doc /MIR /NP /XD .svn
+ robocopy $toolsDir $workingDir\Package\Source\Tools /MIR /NP /XD .svn
+
+ exec { .\Tools\7-zip\7za.exe a -tzip $workingDir\$zipFileName $workingDir\Package\* } "Error zipping"
+}
+
+# Unzip package to a location
+task Deploy -depends Package {
+ exec { .\Tools\7-zip\7za.exe x -y "-o$workingDir\Deployed" $workingDir\$zipFileName } "Error unzipping"
+}
+
+# Run tests on deployed files
+task Test -depends Deploy {
+ foreach ($build in $builds)
+ {
+ $name = $build.TestsName
+ if ($name -ne $null)
+ {
+ $finalDir = $build.FinalDir
+ $framework = $build.Framework
+
+ Write-Host -ForegroundColor Green "Copying test assembly $name to deployed directory"
+ Write-Host
+ robocopy ".\Src\Newtonsoft.Json.Tests\bin\Release\$finalDir" $workingDir\Deployed\Bin\$finalDir /NP /XO /XF LinqBridge.dll
+
+ Copy-Item -Path ".\Src\Newtonsoft.Json.Tests\bin\Release\$finalDir\Newtonsoft.Json.Tests.dll" -Destination $workingDir\Deployed\Bin\$finalDir\
+
+ Write-Host -ForegroundColor Green "Running tests " $name
+ Write-Host
+ exec { .\Tools\NUnit\nunit-console.exe "$workingDir\Deployed\Bin\$finalDir\Newtonsoft.Json.Tests.dll" /framework=$framework /xml:$workingDir\$name.xml } "Error running $name tests"
+ }
+ }
+}
+
+function GetConstants($constants, $includeSigned)
+{
+ $signed = switch($includeSigned) { $true { ";SIGNED" } default { "" } }
+
+ return "/p:DefineConstants=`"TRACE;$constants$signed`""
+}
+
+function GetVersion($majorVersion)
+{
+ $now = [DateTime]::Now
+
+ $year = $now.Year - 2000
+ $month = $now.Month
+ $totalMonthsSince2000 = ($year * 12) + $month
+ $day = $now.Day
+ $minor = "{0}{1:00}" -f $totalMonthsSince2000, $day
+
+ $hour = $now.Hour
+ $minute = $now.Minute
+ $revision = "{0:00}{1:00}" -f $hour, $minute
+
+ return $majorVersion + "." + $minor
+}
+
+function Update-AssemblyInfoFiles ([string] $sourceDir, [string] $assemblyVersionNumber, [string] $fileVersionNumber)
+{
+ $assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
+ $fileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
+ $assemblyVersion = 'AssemblyVersion("' + $assemblyVersionNumber + '")';
+ $fileVersion = 'AssemblyFileVersion("' + $fileVersionNumber + '")';
+
+ Get-ChildItem -Path $sourceDir -r -filter AssemblyInfo.cs | ForEach-Object {
+
+ $filename = $_.Directory.ToString() + '\' + $_.Name
+ Write-Host $filename
+ $filename + ' -> ' + $version
+
+ (Get-Content $filename) | ForEach-Object {
+ % {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
+ % {$_ -replace $fileVersionPattern, $fileVersion }
+ } | Set-Content $filename
+ }
+}
@@ -0,0 +1,2 @@
+powershell -Command "& {Import-Module ..\Tools\PSake\psake.psm1; Invoke-psake .\build.ps1 %*}"
+pause
@@ -0,0 +1,5 @@
+cls
+
+Import-Module '..\Tools\PSake\psake.psm1'
+Invoke-psake '.\build.ps1' Test -framework 3.5
+Remove-Module psake
@@ -0,0 +1,92 @@
+<html>
+
+ <head>
+ <title>Contract Resolver</title>
+ <link href="styles.css" rel="stylesheet" type="text/css" />
+ <link href="custom.css" rel="stylesheet" type="text/css" />
+ </head>
+
+ <body>
+
+ <div id="control">
+ <span class="productTitle">Json.NET - Quick Starts & API Documentation</span><br />
+ <span class="topicTitle">Contract Resolvers</span></div>
+
+ <div id="content">
+ <span style="color: DarkGray"> </span>
+
+
+ <p>The <a href="./html/T_Newtonsoft_Json_Serialization_IContractResolver.htm">IContractResolver</a> interface provides a way to customize how the JsonSerializer serializes and deserializes .NET objects to JSON.</p>
+ <p>Implementing the IContractResolver interface and then assigning an instance to a JsonSerializer lets you control
+ whether the object is serialized as a JSON object or JSON array, what object members should be serialized, how they are serialized and what they are called.</p>
+
+ <h4>DefaultContractResolver</h4>
+ <p>The <a href="./html/T_Newtonsoft_Json_Serialization_DefaultContractResolver.htm">DefaultContractResolver</a> is the default resolver used by the serializer. It provides many avenues of extensibility in the form of virtual methods that can be overriden.</p>
+
+ <h4>CamelCasePropertyNamesContractResolver</h4>
+ <p><a href="./html/T_Newtonsoft_Json_Serialization_CamelCasePropertyNamesContractResolver.htm">CamelCasePropertyNamesContractResolver</a> inherits from DefaultContractResolver and simply overrides the JSON property name to be written in <a href="http://en.wikipedia.org/wiki/CamelCase" target="_blank">camelcase</a>.</p>
+
+ <div class="overflowpanel"> <div class="code"> <div style="font-family: courier new; color: black; font-size: 10pt;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);">Product</span> product = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Product</span></pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExpiryDate = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">DateTime</span>(2010, 12, 20, 18, 1, 0, <span style="color: rgb(43, 145, 175);">DateTimeKind</span>.Utc),</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name = <span style="color: rgb(163, 21, 21);">"Widget"</span>,</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Price = 9.99m,</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sizes = <span style="color: blue;">new</span>[] {<span style="color: rgb(163, 21, 21);">"Small"</span>, <span style="color: rgb(163, 21, 21);">"Medium"</span>, <span style="color: rgb(163, 21, 21);">"Large"</span>}</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };</pre>
+
+ <pre style="margin: 0px;">&nbsp;</pre>
+
+ <pre style="margin: 0px;"><span style="color: blue;">string</span> json = </pre>
+
+ <pre style="margin: 0px;">&nbsp; <span style="color: rgb(43, 145, 175);">JsonConvert</span>.SerializeObject(</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; product,</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: rgb(43, 145, 175);">Formatting</span>.Indented,</pre>
+
+ <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">JsonSerializerSettings</span> { ContractResolver = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">CamelCasePropertyNamesContractResolver</span>() }</pre>
+
+ <pre style="margin: 0px;">&nbsp; );</pre>
+
+ <pre style="margin: 0px;">&nbsp;</pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//{</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp; "name": "Widget",</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp; "expiryDate": "\/Date(1292868060000)\/",</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp; "price": 9.99,</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp; "sizes": [</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp;&nbsp;&nbsp; "Small",</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp;&nbsp;&nbsp; "Medium",</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp;&nbsp;&nbsp; "Large"</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//&nbsp; ]</span></pre>
+
+ <pre style="margin: 0px;"><span style="color: green;">//}</span></pre>
+ </div>
+ </div>
+</div>
+
+
+ <div id="footer">
+
+
+
+ </div>
+ </div>
+
+ </body>
+
+</html>
Oops, something went wrong.

0 comments on commit fc11387

Please sign in to comment.