From 21a2a7e4f793e395987d60b3ae0296de885c5774 Mon Sep 17 00:00:00 2001 From: JamesNK Date: Fri, 22 Apr 2011 03:11:42 +0000 Subject: [PATCH] -Demo -Changed build script to support NuGet profiles --- Build/build.ps1 | 36 ++++++++++--------- .../Linq/DynamicTests.cs | 35 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 4 +-- .../Properties/AssemblyInfo.cs | 4 +-- .../Utilities/MiscellaneousUtils.cs | 6 ++-- 5 files changed, 63 insertions(+), 22 deletions(-) diff --git a/Build/build.ps1 b/Build/build.ps1 index e95a9b21..b94aae8f 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -1,10 +1,10 @@ properties { $zipFileName = "Json40r2.zip" - $majorVersion = "4.2" + $majorVersion = "4.0.2" $version = GetVersion $majorVersion $signAssemblies = $false $signKeyPath = "D:\Development\Releases\newtonsoft.snk" - $buildDocumentation = $false + $buildDocumentation = $true $buildNuGet = $true $baseDir = resolve-path .. @@ -15,10 +15,10 @@ $releaseDir = "$baseDir\Release" $workingDir = "$baseDir\Working" $builds = @( - @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "net40-client"; Framework="net-4.0"}, + @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "net40-client,net40-full"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp"; 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-client"; Framework="net-2.0"}, + @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35-client,net35-full"; Framework="net-2.0"}, @{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"} ) } @@ -45,7 +45,7 @@ task Clean { task Build -depends Clean { Write-Host -ForegroundColor Green "Updating assembly version" Write-Host - Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0.0') $version + Update-AssemblyInfoFiles $sourceDir ($majorVersion + '.0') $version foreach ($build in $builds) { @@ -80,14 +80,6 @@ task Package -depends Merge { Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\Package\Bin\$finalDir -recurse } - if ($buildDocumentation) - { - # Sandcastle has issues when compiling with .NET 4 MSBuild - http://shfb.codeplex.com/Thread/View.aspx?ThreadId=50652 - exec { .$env:windir\Microsoft.NET\Framework\v3.5\MSBuild.exe "/t:Clean;Rebuild" /p:Configuration=Release "/p:DocumentationSourcePath=$workingDir\Package\Bin\Net" $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 - } if ($buildNuGet) { New-Item -Path $workingDir\NuGet -ItemType Directory @@ -97,15 +89,27 @@ task Package -depends Merge { { $name = $build.TestsName $finalDir = $build.FinalDir - $frameworkDir = $build.NuGetDir + $frameworkDirs = $build.NuGetDir.Split(",") - Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\NuGet\lib\$frameworkDir -recurse + foreach ($frameworkDir in $frameworkDirs) + { + Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\NuGet\lib\$frameworkDir -recurse + } } exec { .\Tools\NuGet\NuGet.exe pack $workingDir\NuGet\Newtonsoft.Json.nuspec } move -Path .\*.nupkg -Destination $workingDir\NuGet } + if ($buildDocumentation) + { + # Sandcastle has issues when compiling with .NET 4 MSBuild - http://shfb.codeplex.com/Thread/View.aspx?ThreadId=50652 + exec { .$env:windir\Microsoft.NET\Framework\v3.5\MSBuild.exe "/t:Clean;Rebuild" /p:Configuration=Release "/p:DocumentationSourcePath=$workingDir\Package\Bin\Net" $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\ @@ -188,7 +192,7 @@ function GetVersion($majorVersion) $minute = $now.Minute $revision = "{0:00}{1:00}" -f $hour, $minute - return $majorVersion + "." + $minor + "." + $revision + return $majorVersion + "." + $minor } function Update-AssemblyInfoFiles ([string] $sourceDir, [string] $assemblyVersionNumber, [string] $fileVersionNumber) diff --git a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs index 23c360b1..12c6e239 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs @@ -601,6 +601,41 @@ namespace Newtonsoft.Json.Tests.Linq // Admin } + [Test] + public void ImprovedDynamicLinqExample() + { + dynamic product = new JObject(); + product.ProductName = "Elbow Grease"; + product.Enabled = true; + product.Price = 4.90m; + product.StockCount = 9000; + product.StockValue = 44100; + + // All Elbow Grease must go sale! + // 50% off price + + product.Price = product.Price / 2; + product.StockValue = product.StockCount * product.Price; + product.ProductName = product.ProductName + " (SALE)"; + + string json = product.ToString(); + // { + // "ProductName": "Elbow Grease (SALE)", + // "Enabled": true, + // "Price": 2.45, + // "StockCount": 9000, + // "StockValue": 22050.0 + // } + + Assert.AreEqual(@"{ + ""ProductName"": ""Elbow Grease (SALE)"", + ""Enabled"": true, + ""Price"": 2.45, + ""StockCount"": 9000, + ""StockValue"": 22050.0 +}", json); + } + public class DynamicDictionary : DynamicObject { private readonly IDictionary _values = new Dictionary(); diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index 95955c67..c094b45a 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -39,7 +39,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.2.0.0")] +[assembly: AssemblyVersion("4.0.2.0")] #if !PocketPC -[assembly: AssemblyFileVersion("4.2.13610.1823")] +[assembly: AssemblyFileVersion("4.0.2.13622")] #endif diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs index 855dcfef..75ed64fc 100644 --- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs @@ -108,9 +108,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.2.0.0")] +[assembly: AssemblyVersion("4.0.2.0")] #if !PocketPC -[assembly: AssemblyFileVersion("4.2.13610.1823")] +[assembly: AssemblyFileVersion("4.0.2.13622")] #endif [assembly: CLSCompliant(true)] diff --git a/Src/Newtonsoft.Json/Utilities/MiscellaneousUtils.cs b/Src/Newtonsoft.Json/Utilities/MiscellaneousUtils.cs index 84375eb7..1cb44fc5 100644 --- a/Src/Newtonsoft.Json/Utilities/MiscellaneousUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/MiscellaneousUtils.cs @@ -21,12 +21,14 @@ namespace Newtonsoft.Json.Utilities if (objA == null && objB != null) return false; + // comparing an Int32 and Int64 both of the same value returns false + // make types the same then compare if (objA.GetType() != objB.GetType()) { if (ConvertUtils.IsInteger(objA) && ConvertUtils.IsInteger(objB)) - return Convert.ToDecimal(objA).Equals(Convert.ToDecimal(objB)); + return Convert.ToDecimal(objA, CultureInfo.CurrentCulture).Equals(Convert.ToDecimal(objB, CultureInfo.CurrentCulture)); else if ((objA is double || objA is float || objA is decimal) && (objB is double || objB is float || objB is decimal)) - return MathUtils.ApproxEquals(Convert.ToDouble(objA), Convert.ToDouble(objB)); + return MathUtils.ApproxEquals(Convert.ToDouble(objA, CultureInfo.CurrentCulture), Convert.ToDouble(objB, CultureInfo.CurrentCulture)); else return false; }