This commit is contained in:
Markus Cozowicz
2016-07-06 09:47:25 -04:00
28 changed files with 672 additions and 94 deletions
+22 -22
View File
@@ -19,28 +19,28 @@
<group targetFramework=".NETPortable4.5-Profile259" /> <group targetFramework=".NETPortable4.5-Profile259" />
<group targetFramework=".NETPortable4.0-Profile328" /> <group targetFramework=".NETPortable4.0-Profile328" />
<group targetFramework=".NETStandard1.0"> <group targetFramework=".NETStandard1.0">
<dependency id="Microsoft.CSharp" version="4.0.1-rc2-24027" /> <dependency id="Microsoft.CSharp" version="4.0.1" />
<dependency id="System.Collections" version="4.0.11-rc2-24027" /> <dependency id="System.Collections" version="4.0.11" />
<dependency id="System.Diagnostics.Debug" version="4.0.11-rc2-24027" /> <dependency id="System.Diagnostics.Debug" version="4.0.11" />
<dependency id="System.Dynamic.Runtime" version="4.0.11-rc2-24027" /> <dependency id="System.Dynamic.Runtime" version="4.0.11" />
<dependency id="System.Globalization" version="4.0.11-rc2-24027" /> <dependency id="System.Globalization" version="4.0.11" />
<dependency id="System.IO" version="4.1.0-rc2-24027" /> <dependency id="System.IO" version="4.1.0" />
<dependency id="System.Linq" version="4.1.0-rc2-24027" /> <dependency id="System.Linq" version="4.1.0" />
<dependency id="System.Linq.Expressions" version="4.0.11-rc2-24027" /> <dependency id="System.Linq.Expressions" version="4.1.0" />
<dependency id="System.ObjectModel" version="4.0.12-rc2-24027" /> <dependency id="System.ObjectModel" version="4.0.12" />
<dependency id="System.Reflection" version="4.1.0-rc2-24027" /> <dependency id="System.Reflection" version="4.1.0" />
<dependency id="System.Reflection.Extensions" version="4.0.1-rc2-24027" /> <dependency id="System.Reflection.Extensions" version="4.0.1" />
<dependency id="System.Resources.ResourceManager" version="4.0.1-rc2-24027" /> <dependency id="System.Resources.ResourceManager" version="4.0.1" />
<dependency id="System.Runtime" version="4.1.0-rc2-24027" /> <dependency id="System.Runtime" version="4.1.0" />
<dependency id="System.Runtime.Extensions" version="4.1.0-rc2-24027" /> <dependency id="System.Runtime.Extensions" version="4.1.0" />
<dependency id="System.Runtime.Serialization.Primitives" version="4.1.1-rc2-24027" /> <dependency id="System.Runtime.Serialization.Primitives" version="4.1.1" />
<dependency id="System.Text.Encoding" version="4.0.11-rc2-24027" /> <dependency id="System.Text.Encoding" version="4.0.11" />
<dependency id="System.Text.Encoding.Extensions" version="4.0.11-rc2-24027" /> <dependency id="System.Text.Encoding.Extensions" version="4.0.11" />
<dependency id="System.Text.RegularExpressions" version="4.0.12-rc2-24027" /> <dependency id="System.Text.RegularExpressions" version="4.1.0" />
<dependency id="System.Threading" version="4.0.11-rc2-24027" /> <dependency id="System.Threading" version="4.0.11" />
<dependency id="System.Threading.Tasks" version="4.0.11-rc2-24027" /> <dependency id="System.Threading.Tasks" version="4.0.11" />
<dependency id="System.Xml.ReaderWriter" version="4.0.11-rc2-24027" /> <dependency id="System.Xml.ReaderWriter" version="4.0.11" />
<dependency id="System.Xml.XDocument" version="4.0.11-rc2-24027" /> <dependency id="System.Xml.XDocument" version="4.0.11" />
</group> </group>
</dependencies> </dependencies>
</metadata> </metadata>
+4 -5
View File
@@ -2,7 +2,7 @@
$zipFileName = "Json90r1.zip" $zipFileName = "Json90r1.zip"
$majorVersion = "9.0" $majorVersion = "9.0"
$majorWithReleaseVersion = "9.0.1" $majorWithReleaseVersion = "9.0.1"
$nugetPrerelease = "beta1" $nugetPrerelease = $null
$version = GetVersion $majorWithReleaseVersion $version = GetVersion $majorWithReleaseVersion
$packageId = "Newtonsoft.Json" $packageId = "Newtonsoft.Json"
$signAssemblies = $false $signAssemblies = $false
@@ -11,7 +11,7 @@
$buildNuGet = $true $buildNuGet = $true
$treatWarningsAsErrors = $false $treatWarningsAsErrors = $false
$workingName = if ($workingName) {$workingName} else {"Working"} $workingName = if ($workingName) {$workingName} else {"Working"}
$netCliVersion = "1.0.0-preview1-002702" $netCliVersion = "1.0.0-preview3-003171"
$baseDir = resolve-path .. $baseDir = resolve-path ..
$buildDir = "$baseDir\Build" $buildDir = "$baseDir\Build"
@@ -54,7 +54,6 @@ task Clean {
# Build each solution, optionally signed # Build each solution, optionally signed
task Build -depends Clean { 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
@@ -206,7 +205,7 @@ function NetCliBuild($build)
$name = $build.Name $name = $build.Name
$projectPath = "$workingSourceDir\Newtonsoft.Json\project.json" $projectPath = "$workingSourceDir\Newtonsoft.Json\project.json"
exec { .\Tools\Dotnet\install.ps1 -Version $netCliVersion | Out-Default } exec { .\Tools\Dotnet\dotnet-install.ps1 -Version $netCliVersion | Out-Default }
exec { dotnet --version | Out-Default } exec { dotnet --version | Out-Default }
Write-Host -ForegroundColor Green "Restoring packages for $name" Write-Host -ForegroundColor Green "Restoring packages for $name"
@@ -221,7 +220,7 @@ function NetCliTests($build)
{ {
$name = $build.TestsName $name = $build.TestsName
exec { .\Tools\Dotnet\install.ps1 -Version $netCliVersion | Out-Default } exec { .\Tools\Dotnet\dotnet-install.ps1 -Version $netCliVersion | Out-Default }
exec { dotnet --version | Out-Default } exec { dotnet --version | Out-Default }
Write-Host -ForegroundColor Green "Restoring packages for $name" Write-Host -ForegroundColor Green "Restoring packages for $name"
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="NamingStrategyAttributes" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This sample uses <codeEntityReference>T:Newtonsoft.Json.Serialization.NamingStrategy</codeEntityReference>
types specified on attributes to control serialized property names.</para>
</introduction>
<section>
<title>Sample</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategyAttributes.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategyAttributes.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="NamingStrategyCamelCase" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This sample uses a <codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCaseNamingStrategy</codeEntityReference>
specified using a contract resolver to camel case serialized property names.</para>
</introduction>
<section>
<title>Sample</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategyCamelCase.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategyCamelCase.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="NamingStrategySkipDictionaryKeys" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This sample configures a <codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCaseNamingStrategy</codeEntityReference>
to not camel case dictionary keys.</para>
</introduction>
<section>
<title>Sample</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategySkipDictionaryKeys.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategySkipDictionaryKeys.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="NamingStrategySkipSpecifiedNames" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This sample configures a <codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCaseNamingStrategy</codeEntityReference>
to not camel case properties that already have a name specified with an attribute.</para>
</introduction>
<section>
<title>Sample</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategySkipSpecifiedNames.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategySkipSpecifiedNames.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="NamingStrategySnakeCase" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This sample uses a <codeEntityReference>T:Newtonsoft.Json.Serialization.SnakeCaseNamingStrategy</codeEntityReference>
specified using a contract resolver to snake case serialized property names.</para>
</introduction>
<section>
<title>Sample</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategySnakeCase.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Serializer\NamingStrategySnakeCase.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+3
View File
@@ -48,6 +48,8 @@
(a member must have the JsonProperty or DataMember attribute to be serialized), opt-out (everything is (a member must have the JsonProperty or DataMember attribute to be serialized), opt-out (everything is
serialized by default but can be ignored with the JsonIgnoreAttribute, Json.NET's default behavior) or serialized by default but can be ignored with the JsonIgnoreAttribute, Json.NET's default behavior) or
fields (all public and private fields are serialized and properties are ignored).</para> fields (all public and private fields are serialized and properties are ignored).</para>
<para>The NamingStrategy setting on this attributes can be set to a <codeEntityReference>T:Newtonsoft.Json.Serialization.NamingStrategy</codeEntityReference>
type that specifies how property names are serialized.</para>
<para>Json.NET serializes .NET classes that implement IEnumerable as a JSON array populated with the <para>Json.NET serializes .NET classes that implement IEnumerable as a JSON array populated with the
IEnumerable values. Placing the <codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference> IEnumerable values. Placing the <codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference>
overrides this behavior and forces the serializer to serialize the class's fields and properties.</para> overrides this behavior and forces the serializer to serialize the class's fields and properties.</para>
@@ -77,6 +79,7 @@
<listItem><para>JsonPropertyAttribute indicates that a property should be serialized when member serialization is set to opt-in.</para></listItem> <listItem><para>JsonPropertyAttribute indicates that a property should be serialized when member serialization is set to opt-in.</para></listItem>
<listItem><para>It includes non-public properties in serialization and deserialization.</para></listItem> <listItem><para>It includes non-public properties in serialization and deserialization.</para></listItem>
<listItem><para>It can be used to customize type name, reference, null, and default value handling for the property value.</para></listItem> <listItem><para>It can be used to customize type name, reference, null, and default value handling for the property value.</para></listItem>
<listItem><para>It can be used to customize the <codeEntityReference>T:Newtonsoft.Json.Serialization.NamingStrategy</codeEntityReference> of the serialized property name.</para></listItem>
<listItem><para>It can be used to customize the property's collection items JsonConverter, type name handling, and reference handling.</para></listItem> <listItem><para>It can be used to customize the property's collection items JsonConverter, type name handling, and reference handling.</para></listItem>
</list> </list>
+9 -4
View File
@@ -30,7 +30,7 @@
<Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" /> <Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" />
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" /> <Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
<Topic id="Samples" visible="True" isExpanded="true" title="Samples"> <Topic id="Samples" visible="True" isExpanded="true" title="Samples">
<Topic id="d6e185d5-c992-44fc-8d8f-d9acc2bbec2f" visible="True" noFile="true" title="Serializing JSON"> <Topic id="d6e185d5-c992-44fc-8d8f-d9acc2bbec2f" visible="True" noFile="true" isExpanded="true" title="Serializing JSON">
<Topic id="SerializeObject" visible="True" title="Serialize an Object" /> <Topic id="SerializeObject" visible="True" title="Serialize an Object" />
<Topic id="SerializeCollection" visible="True" title="Serialize a Collection" /> <Topic id="SerializeCollection" visible="True" title="Serialize a Collection" />
<Topic id="SerializeDictionary" visible="True" title="Serialize a Dictionary" /> <Topic id="SerializeDictionary" visible="True" title="Serialize a Dictionary" />
@@ -72,6 +72,7 @@
<Topic id="JsonConverterAttributeProperty" visible="True" title="JsonConverterAttribute on a property" /> <Topic id="JsonConverterAttributeProperty" visible="True" title="JsonConverterAttribute on a property" />
<Topic id="JsonObjectAttributeOptIn" visible="True" title="JsonObjectAttribute opt-in serialization" /> <Topic id="JsonObjectAttributeOptIn" visible="True" title="JsonObjectAttribute opt-in serialization" />
<Topic id="JsonObjectAttributeOverrideIEnumerable" visible="True" title="JsonObjectAttribute force object serialization" /> <Topic id="JsonObjectAttributeOverrideIEnumerable" visible="True" title="JsonObjectAttribute force object serialization" />
<Topic id="NamingStrategyAttributes" visible="True" isSelected="true" title="JsonObjectAttribute NamingStrategy setting" />
<Topic id="JsonPropertyName" visible="True" title="JsonPropertyAttribute name" /> <Topic id="JsonPropertyName" visible="True" title="JsonPropertyAttribute name" />
<Topic id="JsonPropertyOrder" visible="True" title="JsonPropertyAttribute order" /> <Topic id="JsonPropertyOrder" visible="True" title="JsonPropertyAttribute order" />
<Topic id="JsonPropertyRequired" visible="True" title="JsonPropertyAttribute required" /> <Topic id="JsonPropertyRequired" visible="True" title="JsonPropertyAttribute required" />
@@ -90,8 +91,12 @@
<Topic id="DeserializeExtensionData" visible="True" title="Deserialize ExtensionData" /> <Topic id="DeserializeExtensionData" visible="True" title="Deserialize ExtensionData" />
<Topic id="DeserializeDateFormatString" visible="True" title="Deserialize DateFormatString" /> <Topic id="DeserializeDateFormatString" visible="True" title="Deserialize DateFormatString" />
<Topic id="SerializeDateFormatString" visible="True" title="Serialize DateFormatString" /> <Topic id="SerializeDateFormatString" visible="True" title="Serialize DateFormatString" />
<Topic id="NamingStrategyCamelCase" visible="True" title="Camel case property names" />
<Topic id="NamingStrategySnakeCase" visible="True" title="Snake case property names" />
<Topic id="NamingStrategySkipDictionaryKeys" visible="True" title="Configure NamingStrategy dictionary serialiation" />
<Topic id="NamingStrategySkipSpecifiedNames" visible="True" title="Configure NamingStrategy property name serialization" />
</Topic> </Topic>
<Topic id="68b9fad2-5436-4e35-a734-9b9d751cc3e5" visible="True" noFile="true" isExpanded="true" title="LINQ to JSON"> <Topic id="68b9fad2-5436-4e35-a734-9b9d751cc3e5" visible="True" noFile="true" title="LINQ to JSON">
<Topic id="CreateJsonManually" visible="True" title="Create JSON manually" /> <Topic id="CreateJsonManually" visible="True" title="Create JSON manually" />
<Topic id="CreateJsonCollectionInitializer" visible="True" title="Create JSON using Collection Initializers" /> <Topic id="CreateJsonCollectionInitializer" visible="True" title="Create JSON using Collection Initializers" />
<Topic id="CreateJsonDeclaratively" visible="True" title="Create JSON declaratively with LINQ" /> <Topic id="CreateJsonDeclaratively" visible="True" title="Create JSON declaratively with LINQ" />
@@ -110,7 +115,7 @@
<Topic id="QueryJsonDynamic" visible="True" title="Querying JSON with dynamic" /> <Topic id="QueryJsonDynamic" visible="True" title="Querying JSON with dynamic" />
<Topic id="QueryJsonLinq" visible="True" title="Querying JSON with LINQ" /> <Topic id="QueryJsonLinq" visible="True" title="Querying JSON with LINQ" />
<Topic id="QueryJsonSelectToken" visible="True" title="Querying JSON with SelectToken" /> <Topic id="QueryJsonSelectToken" visible="True" title="Querying JSON with SelectToken" />
<Topic id="QueryJsonSelectTokenEscaped" visible="True" isSelected="true" title="Querying JSON with SelectToken and escaped properties" /> <Topic id="QueryJsonSelectTokenEscaped" visible="True" title="Querying JSON with SelectToken and escaped properties" />
<Topic id="QueryJsonSelectTokenWithLinq" visible="True" title="Querying JSON with SelectToken and LINQ" /> <Topic id="QueryJsonSelectTokenWithLinq" visible="True" title="Querying JSON with SelectToken and LINQ" />
<Topic id="QueryJsonSelectTokenJsonPath" visible="True" title="Querying JSON with JSONPath" /> <Topic id="QueryJsonSelectTokenJsonPath" visible="True" title="Querying JSON with JSONPath" />
<Topic id="ReadJson" visible="True" title="Read JSON from a file" /> <Topic id="ReadJson" visible="True" title="Read JSON from a file" />
@@ -152,7 +157,7 @@
<Topic id="DeserializeFromBson" visible="True" title="Deserialize from BSON" /> <Topic id="DeserializeFromBson" visible="True" title="Deserialize from BSON" />
<Topic id="DeserializeFromBsonCollection" visible="True" title="Deserialize a Collection from BSON" /> <Topic id="DeserializeFromBsonCollection" visible="True" title="Deserialize a Collection from BSON" />
</Topic> </Topic>
<Topic id="ca145ed0-f377-4f1c-9479-d1629082fc6e" visible="True" noFile="true" isExpanded="true" title="Reading and Writing JSON"> <Topic id="ca145ed0-f377-4f1c-9479-d1629082fc6e" visible="True" noFile="true" title="Reading and Writing JSON">
<Topic id="ReadJsonWithJsonTextReader" visible="True" title="Read JSON with JsonTextReader" /> <Topic id="ReadJsonWithJsonTextReader" visible="True" title="Read JSON with JsonTextReader" />
<Topic id="WriteJsonWithJsonTextWriter" visible="True" title="Write JSON with JsonTextWriter" /> <Topic id="WriteJsonWithJsonTextWriter" visible="True" title="Write JSON with JsonTextWriter" />
<Topic id="ReadMultipleContentWithJsonReader" visible="True" title="Read Multiple Fragments With JsonReader" /> <Topic id="ReadMultipleContentWithJsonReader" visible="True" title="Read Multiple Fragments With JsonReader" />
+6 -1
View File
@@ -8,7 +8,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{fd19f68e-72c8-4576-9775-b4480b0db686}</ProjectGuid> <ProjectGuid>{fd19f68e-72c8-4576-9775-b4480b0db686}</ProjectGuid>
<SHFBSchemaVersion>1.9.9.0</SHFBSchemaVersion> <SHFBSchemaVersion>2015.6.5.0</SHFBSchemaVersion>
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual <!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
Studio adds them anyway --> Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName> <AssemblyName>Documentation</AssemblyName>
@@ -100,6 +100,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="icons\favicon.ico" /> <Content Include="icons\favicon.ico" />
<None Include="Samples\Serializer\NamingStrategyAttributes.aml" />
<None Include="Samples\Serializer\NamingStrategySnakeCase.aml" />
<None Include="Samples\Serializer\NamingStrategySkipSpecifiedNames.aml" />
<None Include="Samples\Serializer\NamingStrategySkipDictionaryKeys.aml" />
<None Include="Samples\Serializer\NamingStrategyCamelCase.aml" />
<None Include="Samples\Linq\QueryJsonSelectTokenEscaped.aml" /> <None Include="Samples\Linq\QueryJsonSelectTokenEscaped.aml" />
<None Include="Samples\Serializer\JsonConstructorAttribute.aml" /> <None Include="Samples\Serializer\JsonConstructorAttribute.aml" />
<None Include="Samples\Json\ReadMultipleContentWithJsonReader.aml" /> <None Include="Samples\Json\ReadMultipleContentWithJsonReader.aml" />
@@ -0,0 +1,83 @@
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#if DNXCORE50
using Xunit;
using Test = Xunit.FactAttribute;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
#else
using NUnit.Framework;
#endif
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
[TestFixture]
public class NamingStrategyAttributes : TestFixtureBase
{
#region Types
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
[JsonProperty(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public int SnakeRating { get; set; }
}
#endregion
[Test]
public void Example()
{
#region Usage
User user = new User
{
FirstName = "Tom",
LastName = "Riddle",
SnakeRating = 10
};
string json = JsonConvert.SerializeObject(user, Formatting.Indented);
Console.WriteLine(json);
// {
// "firstName": "Tom",
// "lastName": "Riddle",
// "snake_rating": 10
// }
#endregion
StringAssert.AreEqual(@"{
""firstName"": ""Tom"",
""lastName"": ""Riddle"",
""snake_rating"": 10
}", json);
}
}
}
@@ -0,0 +1,86 @@
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#if DNXCORE50
using Xunit;
using Test = Xunit.FactAttribute;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
#else
using NUnit.Framework;
#endif
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
[TestFixture]
public class NamingStrategyCamelCase : TestFixtureBase
{
#region Types
public class User
{
public string UserName { get; set; }
public bool Enabled { get; set; }
}
#endregion
[Test]
public void Example()
{
#region Usage
User user1 = new User
{
UserName = "jamesn",
Enabled = true
};
DefaultContractResolver contractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
};
string json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Console.WriteLine(json);
// {
// "userName": "jamesn",
// "enabled": true
// }
#endregion
StringAssert.AreEqual(@"{
""userName"": ""jamesn"",
""enabled"": true
}", json);
}
}
}
@@ -0,0 +1,106 @@
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#if DNXCORE50
using Xunit;
using Test = Xunit.FactAttribute;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
#else
using NUnit.Framework;
#endif
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
[TestFixture]
public class NamingStrategySkipDictionaryKeys : TestFixtureBase
{
#region Types
public class DailyHighScores
{
public DateTime Date { get; set; }
public string Game { get; set; }
public Dictionary<string, int> UserPoints { get; set; }
}
#endregion
[Test]
public void Example()
{
#region Usage
DailyHighScores dailyHighScores = new DailyHighScores
{
Date = new DateTime(2016, 6, 27, 0, 0, 0, DateTimeKind.Utc),
Game = "Donkey Kong",
UserPoints = new Dictionary<string, int>
{
["JamesNK"] = 9001,
["JoC"] = 1337,
["JessicN"] = 1000
}
};
DefaultContractResolver contractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
ProcessDictionaryKeys = false
}
};
string json = JsonConvert.SerializeObject(dailyHighScores, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Console.WriteLine(json);
// {
// "date": "2016-06-27T00:00:00Z",
// "game": "Donkey Kong",
// "userPoints": {
// "JamesNK": 9001,
// "JoC": 1337,
// "JessicN": 1000
// }
// }
#endregion
StringAssert.AreEqual(@"{
""date"": ""2016-06-27T00:00:00Z"",
""game"": ""Donkey Kong"",
""userPoints"": {
""JamesNK"": 9001,
""JoC"": 1337,
""JessicN"": 1000
}
}", json);
}
}
}
@@ -0,0 +1,94 @@
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#if DNXCORE50
using Xunit;
using Test = Xunit.FactAttribute;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
#else
using NUnit.Framework;
#endif
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
[TestFixture]
public class NamingStrategySkipSpecifiedNames : TestFixtureBase
{
#region Types
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
[JsonProperty(PropertyName = "UPN")]
public string Upn { get; set; }
}
#endregion
[Test]
public void Example()
{
#region Usage
User user = new User
{
FirstName = "John",
LastName = "Smith",
Upn = "john.smith@acme.com"
};
DefaultContractResolver contractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
OverrideSpecifiedNames = false
}
};
string json = JsonConvert.SerializeObject(user, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Console.WriteLine(json);
// {
// "firstName": "John",
// "lastName": "Smith",
// "UPN": "john.smith@acme.com"
// }
#endregion
StringAssert.AreEqual(@"{
""firstName"": ""John"",
""lastName"": ""Smith"",
""UPN"": ""john.smith@acme.com""
}", json);
}
}
}
@@ -0,0 +1,86 @@
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#if DNXCORE50
using Xunit;
using Test = Xunit.FactAttribute;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
#else
using NUnit.Framework;
#endif
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
[TestFixture]
public class NamingStrategySnakeCase : TestFixtureBase
{
#region Types
public class User
{
public string UserName { get; set; }
public bool Enabled { get; set; }
}
#endregion
[Test]
public void Example()
{
#region Usage
User user1 = new User
{
UserName = "jamesn",
Enabled = true
};
DefaultContractResolver contractResolver = new DefaultContractResolver
{
NamingStrategy = new SnakeCaseNamingStrategy()
};
string json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Console.WriteLine(json);
// {
// "user_name": "jamesn",
// "enabled": true
// }
#endregion
StringAssert.AreEqual(@"{
""user_name"": ""jamesn"",
""enabled"": true
}", json);
}
}
}
@@ -157,6 +157,10 @@
</Compile> </Compile>
<Compile Include="Documentation\Samples\Serializer\DeserializeMetadataPropertyHandling.cs" /> <Compile Include="Documentation\Samples\Serializer\DeserializeMetadataPropertyHandling.cs" />
<Compile Include="Documentation\Samples\Serializer\JsonConstructorAttribute.cs" /> <Compile Include="Documentation\Samples\Serializer\JsonConstructorAttribute.cs" />
<Compile Include="Documentation\Samples\Serializer\NamingStrategyAttributes.cs" />
<Compile Include="Documentation\Samples\Serializer\NamingStrategySkipSpecifiedNames.cs" />
<Compile Include="Documentation\Samples\Serializer\NamingStrategySkipDictionaryKeys.cs" />
<Compile Include="Documentation\Samples\Serializer\NamingStrategyCamelCase.cs" />
<Compile Include="Documentation\Samples\Serializer\SerializeDateFormatString.cs" /> <Compile Include="Documentation\Samples\Serializer\SerializeDateFormatString.cs" />
<Compile Include="Documentation\Samples\Serializer\DeserializeCollection.cs" /> <Compile Include="Documentation\Samples\Serializer\DeserializeCollection.cs" />
<Compile Include="Documentation\Samples\Serializer\DeserializeConstructorHandling.cs" /> <Compile Include="Documentation\Samples\Serializer\DeserializeConstructorHandling.cs" />
@@ -205,6 +209,7 @@
<Compile Include="Documentation\Samples\Serializer\SerializeUnindentedJson.cs" /> <Compile Include="Documentation\Samples\Serializer\SerializeUnindentedJson.cs" />
<Compile Include="Documentation\Samples\Serializer\SerializeWithJsonConverters.cs" /> <Compile Include="Documentation\Samples\Serializer\SerializeWithJsonConverters.cs" />
<Compile Include="Documentation\Samples\Serializer\SerializeWithJsonSerializerToFile.cs" /> <Compile Include="Documentation\Samples\Serializer\SerializeWithJsonSerializerToFile.cs" />
<Compile Include="Documentation\Samples\Serializer\NamingStrategySnakeCase.cs" />
<Compile Include="Documentation\Samples\Serializer\TraceWriter.cs" /> <Compile Include="Documentation\Samples\Serializer\TraceWriter.cs" />
<Compile Include="Documentation\Samples\Xml\ConvertJsonToXml.cs" /> <Compile Include="Documentation\Samples\Xml\ConvertJsonToXml.cs" />
<Compile Include="Documentation\Samples\Xml\ConvertXmlToJson.cs" /> <Compile Include="Documentation\Samples\Xml\ConvertXmlToJson.cs" />
@@ -1,9 +1,9 @@
{ {
"dependencies": { "dependencies": {
"Autofac": "4.0.0-beta7-130", "Autofac": "4.0.0-rc2-240",
"FSharp.Core": "4.0.0.1", "FSharp.Core": "4.0.0.1",
"NUnit": "2.6.2", "NUnit": "2.6.2",
"System.Buffers": "4.0.0-rc2-24027", "System.Buffers": "4.0.0",
"System.Collections.Immutable": "1.1.37" "System.Collections.Immutable": "1.1.37"
}, },
"frameworks": { "frameworks": {
@@ -41,7 +41,9 @@ using System.Linq;
#endif #endif
using System.Text; using System.Text;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities;
#if NETFX_CORE #if NETFX_CORE
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -1561,7 +1563,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
StringAssert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests]], mscorlib"", ""$type"": """ + ReflectionUtils.GetTypeName(typeof(List<Event1[,]>), 0, DefaultSerializationBinder.Instance) + @""",
""$values"": [ ""$values"": [
{ {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests"",
@@ -7234,7 +7234,7 @@ Path '', line 1, position 1.");
""Longitude"": -117.766684, ""Longitude"": -117.766684,
""TimeStamp"": ""2000-03-01T23:59:59Z"", ""TimeStamp"": ""2000-03-01T23:59:59Z"",
""Payload"": { ""Payload"": {
""$type"": ""System.Byte[], mscorlib"", ""$type"": """ + ReflectionUtils.GetTypeName(typeof(byte[]), 0, DefaultSerializationBinder.Instance) + @""",
""$value"": ""AAECAwQFBgcICQ=="" ""$value"": ""AAECAwQFBgcICQ==""
} }
}", jsonString); }", jsonString);
@@ -28,6 +28,7 @@ using System.Collections.Generic;
using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters;
using System.Text; using System.Text;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NETFX_CORE #if NETFX_CORE
@@ -133,7 +134,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string serializedString = JsonConvert.SerializeObject(inputContext, jsonSerializerSettings); string serializedString = JsonConvert.SerializeObject(inputContext, jsonSerializerSettings);
StringAssert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Guid, mscorlib]], mscorlib"", ""$type"": """ + ReflectionUtils.GetTypeName(typeof(Dictionary<string, Guid>), 0, DefaultSerializationBinder.Instance) + @""",
""k1"": ""5dd2dba0-20c0-49f8-a054-1fa3b0a8d774"" ""k1"": ""5dd2dba0-20c0-49f8-a054-1fa3b0a8d774""
}", serializedString); }", serializedString);
@@ -165,7 +166,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""Longitude"": -117.766684, ""Longitude"": -117.766684,
""TimeStamp"": ""2000-03-01T23:59:59Z"", ""TimeStamp"": ""2000-03-01T23:59:59Z"",
""Payload"": { ""Payload"": {
""$type"": ""System.Byte[], mscorlib"", ""$type"": """ + ReflectionUtils.GetTypeName(typeof(byte[]), 0, DefaultSerializationBinder.Instance) + @""",
""$value"": ""AAECAwQFBgcICQ=="" ""$value"": ""AAECAwQFBgcICQ==""
} }
}", jsonString); }", jsonString);
@@ -29,7 +29,9 @@ using System.IO;
using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters;
using System.Text; using System.Text;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities;
#if NETFX_CORE #if NETFX_CORE
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -116,7 +118,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""$type"": ""Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+Container, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+Container, Newtonsoft.Json.Tests"",
""ListA"": { ""ListA"": {
""$id"": ""2"", ""$id"": ""2"",
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+ContentA, Newtonsoft.Json.Tests]], mscorlib"", ""$type"": """ + ReflectionUtils.GetTypeName(typeof(List<ContentA>), 0, DefaultSerializationBinder.Instance) + @""",
""$values"": [ ""$values"": [
{ {
""$id"": ""3"", ""$id"": ""3"",
@@ -127,7 +129,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}, },
""ListB"": { ""ListB"": {
""$id"": ""4"", ""$id"": ""4"",
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+ContentA, Newtonsoft.Json.Tests]], mscorlib"", ""$type"": """ + ReflectionUtils.GetTypeName(typeof(List<ContentA>), 0, DefaultSerializationBinder.Instance) + @""",
""$values"": [ ""$values"": [
{ {
""$ref"": ""3"" ""$ref"": ""3""
@@ -24,6 +24,7 @@ using NUnit.Framework;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities;
#if NET20 #if NET20
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
@@ -551,12 +552,12 @@ Newtonsoft.Json Error: 0 : Error!
}); });
Assert.AreEqual("Started serializing System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[0].Message); Assert.AreEqual("Started serializing System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[0].Message);
Assert.AreEqual("Writing type name 'System.Collections.Generic.List`1[[System.Object, mscorlib]], mscorlib' for System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[1].Message); Assert.AreEqual("Writing type name '" + ReflectionUtils.GetTypeName(typeof(List<object>), 0, DefaultSerializationBinder.Instance) + "' for System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[1].Message);
Assert.AreEqual("Started serializing System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values'.", traceWriter.TraceRecords[2].Message); Assert.AreEqual("Started serializing System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values'.", traceWriter.TraceRecords[2].Message);
Assert.AreEqual("Writing type name 'System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.String, mscorlib]], mscorlib' for System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[3].Message); Assert.AreEqual("Writing type name '" + ReflectionUtils.GetTypeName(typeof(Dictionary<string, string>), 0, DefaultSerializationBinder.Instance) + "' for System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[3].Message);
Assert.AreEqual("Finished serializing System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[4].Message); Assert.AreEqual("Finished serializing System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[4].Message);
Assert.AreEqual("Started serializing System.Version. Path '$values[0]'.", traceWriter.TraceRecords[5].Message); Assert.AreEqual("Started serializing System.Version. Path '$values[0]'.", traceWriter.TraceRecords[5].Message);
Assert.AreEqual("Writing type name 'System.Version, mscorlib' for System.Version. Path '$values[1]'.", traceWriter.TraceRecords[6].Message); Assert.AreEqual("Writing type name '" + ReflectionUtils.GetTypeName(typeof(Version), 0, DefaultSerializationBinder.Instance) + "' for System.Version. Path '$values[1]'.", traceWriter.TraceRecords[6].Message);
Assert.AreEqual("Finished serializing System.Version. Path '$values[1]'.", traceWriter.TraceRecords[7].Message); Assert.AreEqual("Finished serializing System.Version. Path '$values[1]'.", traceWriter.TraceRecords[7].Message);
Assert.AreEqual("Finished serializing System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[8].Message); Assert.AreEqual("Finished serializing System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[8].Message);
} }
+4 -4
View File
@@ -298,12 +298,12 @@ namespace Newtonsoft.Json.Tests
} }
#if NETFX_CORE #if NETFX_CORE
public static class Console public static class Console
{
public static void WriteLine(params object[] args)
{ {
public static void WriteLine(params object[] args)
{
}
} }
}
#endif #endif
public static class CustomAssert public static class CustomAssert
+6 -6
View File
@@ -89,14 +89,14 @@
"dependencies": { "dependencies": {
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"type": "platform", "type": "platform",
"version": "1.0.0-rc2-3002702" "version": "1.0.0"
}, },
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027", "System.Runtime.Serialization.Primitives": "4.1.1",
"System.Xml.XmlSerializer": "4.0.11-rc2-24027", "System.Xml.XmlSerializer": "4.0.11",
"System.Runtime.Serialization.Json": "4.0.2-rc2-24027", "System.Runtime.Serialization.Json": "4.0.2",
"System.Runtime.Serialization.Xml": "4.1.1-rc2-24027", "System.Runtime.Serialization.Xml": "4.1.1",
"xunit": "2.1.0", "xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-build10015" "dotnet-test-xunit": "2.2.0-preview2-build1029"
}, },
"imports": [ "imports": [
"dnxcore50", "dnxcore50",
+22 -22
View File
@@ -106,28 +106,28 @@
] ]
}, },
"dependencies": { "dependencies": {
"Microsoft.CSharp": "4.0.1-rc2-24027", "Microsoft.CSharp": "4.0.1",
"System.Collections": "4.0.11-rc2-24027", "System.Collections": "4.0.11",
"System.Diagnostics.Debug": "4.0.11-rc2-24027", "System.Diagnostics.Debug": "4.0.11",
"System.Dynamic.Runtime": "4.0.11-rc2-24027", "System.Dynamic.Runtime": "4.0.11",
"System.Globalization": "4.0.11-rc2-24027", "System.Globalization": "4.0.11",
"System.IO": "4.1.0-rc2-24027", "System.IO": "4.1.0",
"System.Linq": "4.1.0-rc2-24027", "System.Linq": "4.1.0",
"System.Linq.Expressions": "4.0.11-rc2-24027", "System.Linq.Expressions": "4.1.0",
"System.ObjectModel": "4.0.12-rc2-24027", "System.ObjectModel": "4.0.12",
"System.Reflection": "4.1.0-rc2-24027", "System.Reflection": "4.1.0",
"System.Reflection.Extensions": "4.0.1-rc2-24027", "System.Reflection.Extensions": "4.0.1",
"System.Resources.ResourceManager": "4.0.1-rc2-24027", "System.Resources.ResourceManager": "4.0.1",
"System.Runtime": "4.1.0-rc2-24027", "System.Runtime": "4.1.0",
"System.Runtime.Extensions": "4.1.0-rc2-24027", "System.Runtime.Extensions": "4.1.0",
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027", "System.Runtime.Serialization.Primitives": "4.1.1",
"System.Text.Encoding": "4.0.11-rc2-24027", "System.Text.Encoding": "4.0.11",
"System.Text.Encoding.Extensions": "4.0.11-rc2-24027", "System.Text.Encoding.Extensions": "4.0.11",
"System.Text.RegularExpressions": "4.0.12-rc2-24027", "System.Text.RegularExpressions": "4.1.0",
"System.Threading": "4.0.11-rc2-24027", "System.Threading": "4.0.11",
"System.Threading.Tasks": "4.0.11-rc2-24027", "System.Threading.Tasks": "4.0.11",
"System.Xml.ReaderWriter": "4.0.11-rc2-24027", "System.Xml.ReaderWriter": "4.0.11",
"System.Xml.XDocument": "4.0.11-rc2-24027" "System.Xml.XDocument": "4.0.11"
} }
} }
} }
+2 -2
View File
@@ -3,8 +3,8 @@
<packageSources> <packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below --> <!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear /> <clear />
<!--<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />--> <!--<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />-->
<add key="NuGet.org (v3)" value="https://api.nuget.org/v3/index.json" /> <add key="NuGet.org (v3)" value="https://api.nuget.org/v3/index.json" />
</packageSources> </packageSources>
</configuration> </configuration>
+35 -15
View File
@@ -29,6 +29,9 @@
Default: <auto> - this value represents currently running OS architecture Default: <auto> - this value represents currently running OS architecture
Architecture of dotnet binaries to be installed. Architecture of dotnet binaries to be installed.
Possible values are: <auto>, x64 and x86 Possible values are: <auto>, x64 and x86
.PARAMETER SharedRuntime
Default: false
Installs just the shared runtime bits, not the entire SDK
.PARAMETER DebugSymbols .PARAMETER DebugSymbols
If set the installer will include symbols in the installation. If set the installer will include symbols in the installation.
.PARAMETER DryRun .PARAMETER DryRun
@@ -47,10 +50,11 @@
#> #>
[cmdletbinding()] [cmdletbinding()]
param( param(
[string]$Channel="preview", [string]$Channel="rel-1.0.0",
[string]$Version="Latest", [string]$Version="Latest",
[string]$InstallDir="<auto>", [string]$InstallDir="<auto>",
[string]$Architecture="<auto>", [string]$Architecture="<auto>",
[switch]$SharedRuntime,
[switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet. [switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet.
[switch]$DryRun, [switch]$DryRun,
[switch]$NoPath, [switch]$NoPath,
@@ -68,11 +72,11 @@ $VersionRegEx="/\d+\.\d+[^/]+/"
$OverrideNonVersionedFiles=$true $OverrideNonVersionedFiles=$true
function Say($str) { function Say($str) {
Write-Host "dotnet_install: $str" Write-Host "dotnet-install: $str"
} }
function Say-Verbose($str) { function Say-Verbose($str) {
Write-Verbose "dotnet_install: $str" Write-Verbose "dotnet-install: $str"
} }
function Say-Invocation($Invocation) { function Say-Invocation($Invocation) {
@@ -114,9 +118,22 @@ function Get-Version-Info-From-Version-Text([string]$VersionText) {
function Get-Latest-Version-Info([string]$AzureFeed, [string]$AzureChannel, [string]$CLIArchitecture) { function Get-Latest-Version-Info([string]$AzureFeed, [string]$AzureChannel, [string]$CLIArchitecture) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
$VersionFileUrl = "$AzureFeed/$AzureChannel/dnvm/latest.win.$CLIArchitecture.version" $VersionFileUrl = $null
if ($SharedRuntime) {
$VersionFileUrl = "$AzureFeed/$AzureChannel/dnvm/latest.sharedfx.win.$CLIArchitecture.version"
}
else {
$VersionFileUrl = "$AzureFeed/Sdk/$AzureChannel/latest.version"
}
$Response = Invoke-WebRequest -UseBasicParsing $VersionFileUrl $Response = Invoke-WebRequest -UseBasicParsing $VersionFileUrl
$VersionText = [Text.Encoding]::UTF8.GetString($Response.Content)
switch ($Response.Headers.'Content-Type'){
{ ($_ -eq "application/octet-stream") } { $VersionText = [Text.Encoding]::UTF8.GetString($Response.Content) }
{ ($_ -eq "text/plain") } { $VersionText = $Response.Content }
default { throw "``$Response.Headers.'Content-Type'`` is an unknown .version file content type." }
}
$VersionInfo = Get-Version-Info-From-Version-Text $VersionText $VersionInfo = Get-Version-Info-From-Version-Text $VersionText
@@ -130,9 +147,8 @@ function Get-Azure-Channel-From-Channel([string]$Channel) {
# For compatibility with build scripts accept also directly Azure channels names # For compatibility with build scripts accept also directly Azure channels names
switch ($Channel.ToLower()) { switch ($Channel.ToLower()) {
{ ($_ -eq "future") -or ($_ -eq "dev") } { return "dev" } { ($_ -eq "future") -or ($_ -eq "dev") } { return "dev" }
{ ($_ -eq "preview") -or ($_ -eq "beta") } { return "beta" }
{ $_ -eq "production" } { throw "Production channel does not exist yet" } { $_ -eq "production" } { throw "Production channel does not exist yet" }
default { throw "``$Channel`` is an invalid channel name. Use one of the following: ``future``, ``preview``, ``production``" } default { return $_ }
} }
} }
@@ -153,13 +169,16 @@ function Get-Download-Links([string]$AzureFeed, [string]$AzureChannel, [string]$
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
$ret = @() $ret = @()
$files = @("dotnet-dev")
foreach ($file in $files) { if ($SharedRuntime) {
$PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/$file-win-$CLIArchitecture.$SpecificVersion.zip" $PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
Say-Verbose "Constructed payload URL: $PayloadURL"
$ret += $PayloadURL
} }
else {
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
}
Say-Verbose "Constructed payload URL: $PayloadURL"
$ret += $PayloadURL
return $ret return $ret
} }
@@ -300,7 +319,7 @@ if ($DryRun) {
Say "- $DownloadLink" Say "- $DownloadLink"
} }
Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir" Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir"
return exit 0
} }
$InstallRoot = Resolve-Installation-Path $InstallDir $InstallRoot = Resolve-Installation-Path $InstallDir
@@ -310,7 +329,7 @@ $IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -Relativ
Say-Verbose ".NET SDK installed? $IsSdkInstalled" Say-Verbose ".NET SDK installed? $IsSdkInstalled"
if ($IsSdkInstalled) { if ($IsSdkInstalled) {
Say ".NET SDK version $SpecificVersion is already installed." Say ".NET SDK version $SpecificVersion is already installed."
return exit 0
} }
New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null
@@ -329,10 +348,11 @@ foreach ($DownloadLink in $DownloadLinks) {
$BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath) $BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath)
if (-Not $NoPath) { if (-Not $NoPath) {
Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process." Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process."
$env:path += ";$BinPath" $env:path = "$BinPath;" + $env:path
} }
else { else {
Say "Binaries of dotnet can be found in $BinPath" Say "Binaries of dotnet can be found in $BinPath"
} }
Say "Installation finished" Say "Installation finished"
exit 0
Binary file not shown.