Change ifdefs to be by feature, not by platform (#1146)

* First pass

* Second pass

* Third pass

* Temporarily change build script to build only portable

* Add portable features for release build

* Add feature constants to build script

* Add more feature constants to build script

* Fix build issues

* Fix build issues

* Get rid of constants in build.ps1

* HAVE_NUMERICS -> HAVE_BIG_INTEGER

* Remove HAVE_NULLABLE

* Remove HAVE_NUMERICS from csprojs

* Add missing ifdef

* Add feature defines to pj

* Re-enable netstd builds

* Fix defines in pj

* Trying to get better build outputs

* Trying to get the build error

* Use newer cli

* Address review feedback; make netstd build work

* Introduce HAVE_DB_NULL_TYPE

* Adapt to upstream changes; address remaining review feedback

* Adapt to upstream changes; address remaining review feedback

* Rename some constants for constistency

* Address review feedback

* -Fixed build with signed assembly

* Fix merge erorr

* Address review feedback

* Introduce HAVE_NON_SERIALIZED_ATTRIBUTE

* HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE
This commit is contained in:
Florian Greinacher
2017-01-12 11:07:02 +13:00
committed by James Newton-King
parent eb96cb9f62
commit b8e60c773b
114 changed files with 642 additions and 550 deletions
+1
View File
@@ -17,3 +17,4 @@ _ReSharper.*
*.nuget.props *.nuget.props
*.nuget.targets *.nuget.targets
*.orig *.orig
.DS_Store
+18 -24
View File
@@ -24,14 +24,14 @@
$workingSourceDir = "$workingDir\Src" $workingSourceDir = "$workingDir\Src"
$nugetPath = "$buildDir\nuget.exe" $nugetPath = "$buildDir\nuget.exe"
$builds = @( $builds = @(
@{Name = "Newtonsoft.Json.Dotnet"; TestsName = "Newtonsoft.Json.Tests.Dotnet"; BuildFunction = "NetCliBuild"; TestsFunction = "NetCliTests"; Constants="NETSTANDARD1_0"; FinalDir="netstandard1.0"; NuGetDir = "netstandard1.0"; Framework=$null}, @{Name = "Newtonsoft.Json.Dotnet"; TestsName = "Newtonsoft.Json.Tests.Dotnet"; BuildFunction = "NetCliBuild"; TestsFunction = "NetCliTests"; FinalDir="netstandard1.0"; NuGetDir = "netstandard1.0"; Framework=$null},
@{Name = "Newtonsoft.Json.Dotnet"; TestsName = "Newtonsoft.Json.Tests.Dotnet"; BuildFunction = "NetCliBuild"; TestsFunction = "NetCliTests"; Constants="NETSTANDARD1_1"; FinalDir="netstandard1.1"; NuGetDir = "netstandard1.1"; Framework=$null}, @{Name = "Newtonsoft.Json.Dotnet"; TestsName = "Newtonsoft.Json.Tests.Dotnet"; BuildFunction = "NetCliBuild"; TestsFunction = "NetCliTests"; FinalDir="netstandard1.1"; NuGetDir = "netstandard1.1"; Framework=$null},
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants=""; FinalDir="Net45"; NuGetDir = "net45"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; FinalDir="Net45"; NuGetDir = "net45"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="PORTABLE"; FinalDir="Portable"; NuGetDir = "portable-net45+wp80+win8+wpa81"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; FinalDir="Portable"; NuGetDir = "portable-net45+wp80+win8+wpa81"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="PORTABLE40"; FinalDir="Portable40"; NuGetDir = "portable-net40+sl5+wp80+win8+wpa81"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; FinalDir="Portable40"; NuGetDir = "portable-net40+sl5+wp80+win8+wpa81"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="NET40"; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"}, @{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"},
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"}, @{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"},
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"} @{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; BuildFunction = "MSBuildBuild"; TestsFunction = "NUnitTests"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"}
) )
} }
@@ -198,11 +198,11 @@ function MSBuildBuild($build)
exec { & $nugetPath update -self } exec { & $nugetPath update -self }
exec { & $nugetPath restore "$workingSourceDir\$name.sln" -verbosity detailed -configfile $workingSourceDir\nuget.config | Out-Default } "Error restoring $name" exec { & $nugetPath restore "$workingSourceDir\$name.sln" -verbosity detailed -configfile $workingSourceDir\nuget.config | Out-Default } "Error restoring $name"
$constants = GetConstants $build.Constants $signAssemblies $additionalConstants = switch($signAssemblies) { $true { "SIGNED" } default { "" } }
Write-Host Write-Host
Write-Host "Building $workingSourceDir\$name.sln" -ForegroundColor Green Write-Host "Building $workingSourceDir\$name.sln" -ForegroundColor Green
exec { msbuild "/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:VisualStudioVersion=14.0" /p:DefineConstants=`"$constants`" "$workingSourceDir\$name.sln" | Out-Default } "Error building $name" exec { msbuild "/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:VisualStudioVersion=14.0" "/p:AdditionalConstants=$additionalConstants" "$workingSourceDir\$name.sln" | Out-Default } "Error building $name"
} }
function EnsureNuGetExists() function EnsureNuGetExists()
@@ -283,13 +283,6 @@ function GetNuGetVersion()
return $nugetVersion return $nugetVersion
} }
function GetConstants($constants, $includeSigned)
{
$signed = switch($includeSigned) { $true { ";SIGNED" } default { "" } }
return "CODE_ANALYSIS;TRACE;$constants$signed"
}
function GetVersion($majorVersion) function GetVersion($majorVersion)
{ {
$now = [DateTime]::Now $now = [DateTime]::Now
@@ -359,15 +352,16 @@ function Update-Project {
[string] $sign [string] $sign
) )
$file = switch($sign) { $true { $signKeyPath } default { $null } } $file = switch($sign) { $true { $signKeyPath } default { $null } }
$signed = switch($sign) { $true { ";SIGNED" } default { "" } }
$constants = "CODE_ANALYSIS;TRACE$signed"
$json = (Get-Content $projectPath) -join "`n" | ConvertFrom-Json
$options = @{"warningsAsErrors" = $true; "xmlDoc" = $true; "keyFile" = $file; "define" = ($constants -split ";") }
Add-Member -InputObject $json -MemberType NoteProperty -Name "buildOptions" -Value $options -Force
$json = (Get-Content $projectPath) -join "`n" | ConvertFrom-Json $json.version = GetNuGetVersion
$options = @{"warningsAsErrors" = $true; "xmlDoc" = $true; "keyFile" = $file; "define" = ((GetConstants "dotnet" $sign) -split ";") }
Add-Member -InputObject $json -MemberType NoteProperty -Name "buildOptions" -Value $options -Force
$json.version = GetNuGetVersion ConvertTo-Json $json -Depth 10 | Set-Content $projectPath
ConvertTo-Json $json -Depth 10 | Set-Content $projectPath
} }
function Execute-Command($command) { function Execute-Command($command) {
@@ -72,37 +72,28 @@
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations"> <Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.Entity"> <Reference Include="System.Data.Entity">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Data.Linq"> <Reference Include="System.Data.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization"> <Reference Include="System.Runtime.Serialization">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Security" /> <Reference Include="System.Security" />
<Reference Include="System.ServiceModel"> <Reference Include="System.ServiceModel">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.ServiceModel.Web"> <Reference Include="System.ServiceModel.Web">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Web.Extensions"> <Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+2 -2
View File
@@ -54,7 +54,7 @@ namespace Newtonsoft.Json.Bson
public void Close() public void Close()
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_STREAM_READER_WRITER_CLOSE
_writer.Close(); _writer.Close();
#else #else
_writer.Dispose(); _writer.Dispose();
@@ -149,7 +149,7 @@ namespace Newtonsoft.Json.Bson
ticks = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(dateTime, false); ticks = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(dateTime, false);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
else else
{ {
DateTimeOffset dateTimeOffset = (DateTimeOffset)value.Value; DateTimeOffset dateTimeOffset = (DateTimeOffset)value.Value;
+1 -1
View File
@@ -232,7 +232,7 @@ namespace Newtonsoft.Json.Bson
if (CloseInput) if (CloseInput)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_STREAM_READER_WRITER_CLOSE
_reader?.Close(); _reader?.Close();
#else #else
_reader?.Dispose(); _reader?.Dispose();
+5 -5
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -27,7 +27,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Text; using System.Text;
@@ -234,7 +234,7 @@ namespace Newtonsoft.Json.Bson
/// <param name="value">The <see cref="Object"/> value to write.</param> /// <param name="value">The <see cref="Object"/> value to write.</param>
public override void WriteValue(object value) public override void WriteValue(object value)
{ {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
InternalWriteValue(JsonToken.Integer); InternalWriteValue(JsonToken.Integer);
@@ -386,7 +386,7 @@ namespace Newtonsoft.Json.Bson
{ {
base.WriteValue(value); base.WriteValue(value);
string s = null; string s = null;
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_CHAR_TO_STRING_WITH_CULTURE
s = value.ToString(CultureInfo.InvariantCulture); s = value.ToString(CultureInfo.InvariantCulture);
#else #else
s = value.ToString(); s = value.ToString();
@@ -436,7 +436,7 @@ namespace Newtonsoft.Json.Bson
AddValue(value, BsonType.Date); AddValue(value, BsonType.Date);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
using System; using System;
using System.Data.SqlTypes; using System.Data.SqlTypes;
using System.Globalization; using System.Globalization;
@@ -37,7 +37,7 @@ namespace Newtonsoft.Json.Converters
/// </summary> /// </summary>
public class BinaryConverter : JsonConverter public class BinaryConverter : JsonConverter
{ {
#if !NET20 #if HAVE_LINQ
private const string BinaryTypeName = "System.Data.Linq.Binary"; private const string BinaryTypeName = "System.Data.Linq.Binary";
private const string BinaryToArrayName = "ToArray"; private const string BinaryToArrayName = "ToArray";
private ReflectionObject _reflectionObject; private ReflectionObject _reflectionObject;
@@ -64,7 +64,7 @@ namespace Newtonsoft.Json.Converters
private byte[] GetByteArray(object value) private byte[] GetByteArray(object value)
{ {
#if !(NET20) #if HAVE_LINQ
if (value.GetType().AssignableToTypeName(BinaryTypeName)) if (value.GetType().AssignableToTypeName(BinaryTypeName))
{ {
EnsureReflectionObject(value.GetType()); EnsureReflectionObject(value.GetType());
@@ -79,7 +79,7 @@ namespace Newtonsoft.Json.Converters
throw new JsonSerializationException("Unexpected value type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, value.GetType())); throw new JsonSerializationException("Unexpected value type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, value.GetType()));
} }
#if !NET20 #if HAVE_LINQ
private void EnsureReflectionObject(Type t) private void EnsureReflectionObject(Type t)
{ {
if (_reflectionObject == null) if (_reflectionObject == null)
@@ -131,7 +131,7 @@ namespace Newtonsoft.Json.Converters
? Nullable.GetUnderlyingType(objectType) ? Nullable.GetUnderlyingType(objectType)
: objectType; : objectType;
#if !NET20 #if HAVE_LINQ
if (t.AssignableToTypeName(BinaryTypeName)) if (t.AssignableToTypeName(BinaryTypeName))
{ {
EnsureReflectionObject(t); EnsureReflectionObject(t);
@@ -181,7 +181,7 @@ namespace Newtonsoft.Json.Converters
/// </returns> /// </returns>
public override bool CanConvert(Type objectType) public override bool CanConvert(Type objectType)
{ {
#if !NET20 #if HAVE_LINQ
if (objectType.AssignableToTypeName(BinaryTypeName)) if (objectType.AssignableToTypeName(BinaryTypeName))
{ {
return true; return true;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
using System; using System;
using System.Data; using System.Data;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@@ -45,7 +45,7 @@ namespace Newtonsoft.Json.Converters
{ {
return true; return true;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?)) if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?))
{ {
return true; return true;
@@ -23,12 +23,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20) #if HAVE_FSHARP_TYPES
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -248,7 +248,7 @@ namespace Newtonsoft.Json.Converters
// all fsharp objects have CompilationMappingAttribute // all fsharp objects have CompilationMappingAttribute
// get the fsharp assembly from the attribute and initialize latebound methods // get the fsharp assembly from the attribute and initialize latebound methods
object[] attributes; object[] attributes;
#if !(DOTNET || PORTABLE) #if HAVE_FULL_REFLECTION
attributes = objectType.GetCustomAttributes(true); attributes = objectType.GetCustomAttributes(true);
#else #else
attributes = objectType.GetTypeInfo().GetCustomAttributes(true).ToArray(); attributes = objectType.GetTypeInfo().GetCustomAttributes(true).ToArray();
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ENTITY_FRAMEWORK
using System; using System;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System.Globalization; using System.Globalization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -92,7 +92,7 @@ namespace Newtonsoft.Json.Converters
text = dateTime.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture); text = dateTime.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
DateTimeOffset dateTimeOffset = (DateTimeOffset)value; DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
@@ -124,11 +124,9 @@ 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);
#if !NET20
Type t = (nullable) Type t = (nullable)
? Nullable.GetUnderlyingType(objectType) ? Nullable.GetUnderlyingType(objectType)
: objectType; : objectType;
#endif
if (reader.TokenType == JsonToken.Null) if (reader.TokenType == JsonToken.Null)
{ {
@@ -142,7 +140,7 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType == JsonToken.Date) if (reader.TokenType == JsonToken.Date)
{ {
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (t == typeof(DateTimeOffset)) if (t == typeof(DateTimeOffset))
{ {
return (reader.Value is DateTimeOffset) ? reader.Value : new DateTimeOffset((DateTime)reader.Value); return (reader.Value is DateTimeOffset) ? reader.Value : new DateTimeOffset((DateTime)reader.Value);
@@ -170,7 +168,7 @@ namespace Newtonsoft.Json.Converters
return null; return null;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (t == typeof(DateTimeOffset)) if (t == typeof(DateTimeOffset))
{ {
if (!string.IsNullOrEmpty(_dateTimeFormat)) if (!string.IsNullOrEmpty(_dateTimeFormat))
@@ -50,7 +50,7 @@ namespace Newtonsoft.Json.Converters
DateTime utcDateTime = dateTime.ToUniversalTime(); DateTime utcDateTime = dateTime.ToUniversalTime();
ticks = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(utcDateTime); ticks = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(utcDateTime);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
DateTimeOffset dateTimeOffset = (DateTimeOffset)value; DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
@@ -111,16 +111,15 @@ 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 !NET20
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);
} }
#endif #endif
return d; return d;
} }
} }
@@ -31,7 +31,7 @@ using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -23,8 +23,9 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PORTABLE40 #if (HAVE_XML_DOCUMENT || HAVE_XLINQ)
#if !(PORTABLE || NET20 || NET35) || NETSTANDARD1_1
#if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System; using System;
@@ -32,7 +33,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Xml; using System.Xml;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
#if !(NET20 || PORTABLE40) #if HAVE_XLINQ
using System.Xml.Linq; using System.Xml.Linq;
#endif #endif
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
@@ -40,7 +41,7 @@ using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Converters namespace Newtonsoft.Json.Converters
{ {
#region XmlNodeWrappers #region XmlNodeWrappers
#if !DOTNET && !PORTABLE && !PORTABLE40 #if HAVE_XML_DOCUMENT
internal class XmlDocumentWrapper : XmlNodeWrapper, IXmlDocument internal class XmlDocumentWrapper : XmlNodeWrapper, IXmlDocument
{ {
private readonly XmlDocument _document; private readonly XmlDocument _document;
@@ -403,7 +404,7 @@ namespace Newtonsoft.Json.Converters
#endregion #endregion
#region XNodeWrappers #region XNodeWrappers
#if !NET20 #if HAVE_XLINQ
internal class XDeclarationWrapper : XObjectWrapper, IXmlDeclaration internal class XDeclarationWrapper : XObjectWrapper, IXmlDeclaration
{ {
internal XDeclaration Declaration { get; private set; } internal XDeclaration Declaration { get; private set; }
@@ -1045,14 +1046,14 @@ namespace Newtonsoft.Json.Converters
private IXmlNode WrapXml(object value) private IXmlNode WrapXml(object value)
{ {
#if !NET20 #if HAVE_XLINQ
XObject xObject = value as XObject; XObject xObject = value as XObject;
if (xObject != null) if (xObject != null)
{ {
return XContainerWrapper.WrapNode(xObject); return XContainerWrapper.WrapNode(xObject);
} }
#endif #endif
#if !(DOTNET || PORTABLE) #if HAVE_XML_DOCUMENT
XmlNode node = value as XmlNode; XmlNode node = value as XmlNode;
if (node != null) if (node != null)
{ {
@@ -1428,7 +1429,7 @@ namespace Newtonsoft.Json.Converters
IXmlDocument document = null; IXmlDocument document = null;
IXmlNode rootNode = null; IXmlNode rootNode = null;
#if !NET20 #if HAVE_XLINQ
if (typeof(XObject).IsAssignableFrom(objectType)) if (typeof(XObject).IsAssignableFrom(objectType))
{ {
if (objectType != typeof(XDocument) && objectType != typeof(XElement)) if (objectType != typeof(XDocument) && objectType != typeof(XElement))
@@ -1441,7 +1442,7 @@ namespace Newtonsoft.Json.Converters
rootNode = document; rootNode = document;
} }
#endif #endif
#if !(DOTNET || PORTABLE) #if HAVE_XML_DOCUMENT
if (typeof(XmlNode).IsAssignableFrom(objectType)) if (typeof(XmlNode).IsAssignableFrom(objectType))
{ {
if (objectType != typeof(XmlDocument)) if (objectType != typeof(XmlDocument))
@@ -1480,7 +1481,7 @@ namespace Newtonsoft.Json.Converters
DeserializeNode(reader, document, manager, rootNode); DeserializeNode(reader, document, manager, rootNode);
} }
#if !NET20 #if HAVE_XLINQ
if (objectType == typeof(XElement)) if (objectType == typeof(XElement))
{ {
XElement element = (XElement)document.DocumentElement.WrappedNode; XElement element = (XElement)document.DocumentElement.WrappedNode;
@@ -1653,7 +1654,7 @@ namespace Newtonsoft.Json.Converters
} }
else if (reader.TokenType == JsonToken.Integer) else if (reader.TokenType == JsonToken.Integer)
{ {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (reader.Value is BigInteger) if (reader.Value is BigInteger)
{ {
return ((BigInteger)reader.Value).ToString(CultureInfo.InvariantCulture); return ((BigInteger)reader.Value).ToString(CultureInfo.InvariantCulture);
@@ -1681,7 +1682,7 @@ namespace Newtonsoft.Json.Converters
} }
else if (reader.TokenType == JsonToken.Date) else if (reader.TokenType == JsonToken.Date)
{ {
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (reader.Value is DateTimeOffset) if (reader.Value is DateTimeOffset)
{ {
return XmlConvert.ToString((DateTimeOffset)reader.Value); return XmlConvert.ToString((DateTimeOffset)reader.Value);
@@ -1743,7 +1744,7 @@ namespace Newtonsoft.Json.Converters
{ {
element.SetAttributeNode(document.CreateAttribute("json:Array", JsonNamespaceUri, "true")); element.SetAttributeNode(document.CreateAttribute("json:Array", JsonNamespaceUri, "true"));
#if !NET20 #if HAVE_XLINQ
// linq to xml doesn't automatically include prefixes via the namespace manager // linq to xml doesn't automatically include prefixes via the namespace manager
if (element is XElementWrapper) if (element is XElementWrapper)
{ {
@@ -2065,13 +2066,13 @@ namespace Newtonsoft.Json.Converters
/// </returns> /// </returns>
public override bool CanConvert(Type valueType) public override bool CanConvert(Type valueType)
{ {
#if !NET20 #if HAVE_XLINQ
if (typeof(XObject).IsAssignableFrom(valueType)) if (typeof(XObject).IsAssignableFrom(valueType))
{ {
return true; return true;
} }
#endif #endif
#if !(DOTNET || PORTABLE) #if HAVE_XML_DOCUMENT
if (typeof(XmlNode).IsAssignableFrom(valueType)) if (typeof(XmlNode).IsAssignableFrom(valueType))
{ {
return true; return true;
+1 -1
View File
@@ -39,7 +39,7 @@ namespace Newtonsoft.Json
/// Date formatted strings, e.g. <c>"\/Date(1198908717056)\/"</c> and <c>"2012-03-21T05:40Z"</c>, are parsed to <see cref="DateTime"/>. /// Date formatted strings, e.g. <c>"\/Date(1198908717056)\/"</c> and <c>"2012-03-21T05:40Z"</c>, are parsed to <see cref="DateTime"/>.
/// </summary> /// </summary>
DateTime = 1, DateTime = 1,
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Date formatted strings, e.g. <c>"\/Date(1198908717056)\/"</c> and <c>"2012-03-21T05:40Z"</c>, are parsed to <see cref="DateTimeOffset"/>. /// Date formatted strings, e.g. <c>"\/Date(1198908717056)\/"</c> and <c>"2012-03-21T05:40Z"</c>, are parsed to <see cref="DateTimeOffset"/>.
/// </summary> /// </summary>
@@ -1,5 +1,5 @@
 
#if DOTNET || PORTABLE40 || PORTABLE #if !HAVE_BINARY_SERIALIZATION
namespace System.Runtime.Serialization.Formatters namespace System.Runtime.Serialization.Formatters
{ {
+14 -14
View File
@@ -26,10 +26,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Globalization; using System.Globalization;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_TPL
using System.Threading.Tasks; using System.Threading.Tasks;
#endif #endif
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -38,7 +38,7 @@ using System.Xml;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System.Text; using System.Text;
#if !(NET20 || PORTABLE40) #if HAVE_XLINQ
using System.Xml.Linq; using System.Xml.Linq;
#endif #endif
@@ -127,7 +127,7 @@ namespace Newtonsoft.Json
} }
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Converts the <see cref="DateTimeOffset"/> to its JSON string representation. /// Converts the <see cref="DateTimeOffset"/> to its JSON string representation.
/// </summary> /// </summary>
@@ -238,7 +238,7 @@ namespace Newtonsoft.Json
return value.ToString(null, CultureInfo.InvariantCulture); return value.ToString(null, CultureInfo.InvariantCulture);
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
private static string ToStringInternal(BigInteger value) private static string ToStringInternal(BigInteger value)
{ {
return value.ToString(null, CultureInfo.InvariantCulture); return value.ToString(null, CultureInfo.InvariantCulture);
@@ -366,7 +366,7 @@ namespace Newtonsoft.Json
{ {
string text; string text;
string qc; string qc;
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_CHAR_TO_STRING_WITH_CULTURE
text = value.ToString("D", CultureInfo.InvariantCulture); text = value.ToString("D", CultureInfo.InvariantCulture);
qc = quoteChar.ToString(CultureInfo.InvariantCulture); qc = quoteChar.ToString(CultureInfo.InvariantCulture);
#else #else
@@ -496,11 +496,11 @@ namespace Newtonsoft.Json
return ToString((DateTime)value); return ToString((DateTime)value);
case PrimitiveTypeCode.Decimal: case PrimitiveTypeCode.Decimal:
return ToString((decimal)value); return ToString((decimal)value);
#if !(DOTNET || PORTABLE) #if HAVE_DB_NULL_TYPE_CODE
case PrimitiveTypeCode.DBNull: case PrimitiveTypeCode.DBNull:
return Null; return Null;
#endif #endif
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffset: case PrimitiveTypeCode.DateTimeOffset:
return ToString((DateTimeOffset)value); return ToString((DateTimeOffset)value);
#endif #endif
@@ -510,7 +510,7 @@ namespace Newtonsoft.Json
return ToString((Uri)value); return ToString((Uri)value);
case PrimitiveTypeCode.TimeSpan: case PrimitiveTypeCode.TimeSpan:
return ToString((TimeSpan)value); return ToString((TimeSpan)value);
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
case PrimitiveTypeCode.BigInteger: case PrimitiveTypeCode.BigInteger:
return ToStringInternal((BigInteger)value); return ToStringInternal((BigInteger)value);
#endif #endif
@@ -661,7 +661,7 @@ namespace Newtonsoft.Json
return sw.ToString(); return sw.ToString();
} }
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_TPL
/// <summary> /// <summary>
/// Asynchronously serializes the specified object to a JSON string. /// Asynchronously serializes the specified object to a JSON string.
/// Serialization will happen on a new thread. /// Serialization will happen on a new thread.
@@ -864,7 +864,7 @@ namespace Newtonsoft.Json
} }
} }
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_TPL
/// <summary> /// <summary>
/// Asynchronously deserializes the JSON to the specified .NET type. /// Asynchronously deserializes the JSON to the specified .NET type.
/// Deserialization will happen on a new thread. /// Deserialization will happen on a new thread.
@@ -969,7 +969,7 @@ namespace Newtonsoft.Json
} }
} }
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_TPL
/// <summary> /// <summary>
/// Asynchronously populates the object with values from the JSON string using <see cref="JsonSerializerSettings"/>. /// Asynchronously populates the object with values from the JSON string using <see cref="JsonSerializerSettings"/>.
/// </summary> /// </summary>
@@ -991,7 +991,7 @@ namespace Newtonsoft.Json
#endregion #endregion
#region Xml #region Xml
#if !(PORTABLE40 || PORTABLE || DOTNET) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Serializes the <see cref="XmlNode"/> to a JSON string. /// Serializes the <see cref="XmlNode"/> to a JSON string.
/// </summary> /// </summary>
@@ -1071,7 +1071,7 @@ namespace Newtonsoft.Json
} }
#endif #endif
#if !NET20 && !PORTABLE40 #if HAVE_XLINQ
/// <summary> /// <summary>
/// Serializes the <see cref="XNode"/> to a JSON string. /// Serializes the <see cref="XNode"/> to a JSON string.
/// </summary> /// </summary>
+2 -2
View File
@@ -35,7 +35,7 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// The exception thrown when an error occurs during JSON serialization or deserialization. /// The exception thrown when an error occurs during JSON serialization or deserialization.
/// </summary> /// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
[Serializable] [Serializable]
#endif #endif
public class JsonException : Exception public class JsonException : Exception
@@ -68,7 +68,7 @@ namespace Newtonsoft.Json
{ {
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonException"/> class. /// Initializes a new instance of the <see cref="JsonException"/> class.
/// </summary> /// </summary>
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
+7 -7
View File
@@ -27,12 +27,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Globalization; using System.Globalization;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -193,7 +193,7 @@ namespace Newtonsoft.Json
set set
{ {
if (value < DateParseHandling.None || if (value < DateParseHandling.None ||
#if !NET20 #if HAVE_DATE_TIME_OFFSET
value > DateParseHandling.DateTimeOffset value > DateParseHandling.DateTimeOffset
#else #else
value > DateParseHandling.DateTime value > DateParseHandling.DateTime
@@ -629,7 +629,7 @@ namespace Newtonsoft.Json
if (!(Value is double)) if (!(Value is double))
{ {
double d; double d;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (Value is BigInteger) if (Value is BigInteger)
{ {
d = (double)(BigInteger)Value; d = (double)(BigInteger)Value;
@@ -689,7 +689,7 @@ namespace Newtonsoft.Json
case JsonToken.Integer: case JsonToken.Integer:
case JsonToken.Float: case JsonToken.Float:
bool b; bool b;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (Value is BigInteger) if (Value is BigInteger)
{ {
b = (BigInteger)Value != 0; b = (BigInteger)Value != 0;
@@ -796,7 +796,7 @@ namespace Newtonsoft.Json
case JsonToken.EndArray: case JsonToken.EndArray:
return null; return null;
case JsonToken.Date: case JsonToken.Date:
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (Value is DateTimeOffset) if (Value is DateTimeOffset)
{ {
SetToken(JsonToken.Date, ((DateTimeOffset)Value).DateTime, false); SetToken(JsonToken.Date, ((DateTimeOffset)Value).DateTime, false);
@@ -838,7 +838,7 @@ namespace Newtonsoft.Json
throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Reads the next JSON token from the source as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>. /// Reads the next JSON token from the source as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>.
/// </summary> /// </summary>
+2 -2
View File
@@ -33,7 +33,7 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// The exception thrown when an error occurs while reading JSON text. /// The exception thrown when an error occurs while reading JSON text.
/// </summary> /// </summary>
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
[Serializable] [Serializable]
#endif #endif
public class JsonReaderException : JsonException public class JsonReaderException : JsonException
@@ -84,7 +84,7 @@ namespace Newtonsoft.Json
{ {
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonReaderException"/> class. /// Initializes a new instance of the <see cref="JsonReaderException"/> class.
/// </summary> /// </summary>
@@ -33,7 +33,7 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// The exception thrown when an error occurs during JSON serialization or deserialization. /// The exception thrown when an error occurs during JSON serialization or deserialization.
/// </summary> /// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
[Serializable] [Serializable]
#endif #endif
public class JsonSerializationException : JsonException public class JsonSerializationException : JsonException
@@ -66,7 +66,7 @@ namespace Newtonsoft.Json
{ {
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonSerializationException"/> class. /// Initializes a new instance of the <see cref="JsonSerializationException"/> class.
/// </summary> /// </summary>
+5 -5
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -23,12 +23,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -41,7 +41,7 @@ namespace Newtonsoft.Json
{ {
// It's not safe to perform the async methods here in a derived class as if the synchronous equivalent // It's not safe to perform the async methods here in a derived class as if the synchronous equivalent
// has been overriden then the asychronous method will no longer be doing the same operation // has been overriden then the asychronous method will no longer be doing the same operation
#if !(NET20 || NET35 || NET40 || PORTABLE40) // Double-check this isn't included inappropriately. #if HAVE_ASYNC // Double-check this isn't included inappropriately.
private readonly bool _safeAsync; private readonly bool _safeAsync;
#endif #endif
@@ -1397,7 +1397,7 @@ namespace Newtonsoft.Json
case '9': case '9':
await ParseNumberAsync(ReadType.Read, cancellationToken).ConfigureAwait(false); await ParseNumberAsync(ReadType.Read, cancellationToken).ConfigureAwait(false);
bool b; bool b;
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (Value is BigInteger) if (Value is BigInteger)
{ {
b = (BigInteger)Value != 0; b = (BigInteger)Value != 0;
+11 -11
View File
@@ -27,7 +27,7 @@ using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.IO; using System.IO;
using System.Globalization; using System.Globalization;
#if !(PORTABLE || PORTABLE40 || NET35 || NET20) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
@@ -42,7 +42,7 @@ namespace Newtonsoft.Json
ReadAsString, ReadAsString,
ReadAsDecimal, ReadAsDecimal,
ReadAsDateTime, ReadAsDateTime,
#if !NET20 #if HAVE_DATE_TIME_OFFSET
ReadAsDateTimeOffset, ReadAsDateTimeOffset,
#endif #endif
ReadAsDouble, ReadAsDouble,
@@ -83,7 +83,7 @@ namespace Newtonsoft.Json
_reader = reader; _reader = reader;
_lineNumber = 1; _lineNumber = 1;
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
_safeAsync = GetType() == typeof(JsonTextReader); _safeAsync = GetType() == typeof(JsonTextReader);
#endif #endif
} }
@@ -178,7 +178,7 @@ namespace Newtonsoft.Json
{ {
dateParseHandling = DateParseHandling.DateTime; dateParseHandling = DateParseHandling.DateTime;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
else if (readType == ReadType.ReadAsDateTimeOffset) else if (readType == ReadType.ReadAsDateTimeOffset)
{ {
dateParseHandling = DateParseHandling.DateTimeOffset; dateParseHandling = DateParseHandling.DateTimeOffset;
@@ -198,7 +198,7 @@ namespace Newtonsoft.Json
return; return;
} }
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
else else
{ {
DateTimeOffset dt; DateTimeOffset dt;
@@ -694,7 +694,7 @@ namespace Newtonsoft.Json
} }
return ReadDateTimeString((string)Value); return ReadDateTimeString((string)Value);
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case ReadType.ReadAsDateTimeOffset: case ReadType.ReadAsDateTimeOffset:
if (Value is DateTimeOffset) if (Value is DateTimeOffset)
{ {
@@ -764,7 +764,7 @@ namespace Newtonsoft.Json
case '9': case '9':
ParseNumber(ReadType.Read); ParseNumber(ReadType.Read);
bool b; bool b;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (Value is BigInteger) if (Value is BigInteger)
{ {
b = (BigInteger)Value != 0; b = (BigInteger)Value != 0;
@@ -965,7 +965,7 @@ namespace Newtonsoft.Json
} }
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Reads the next JSON token from the underlying <see cref="TextReader"/> as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>. /// Reads the next JSON token from the underlying <see cref="TextReader"/> as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>.
/// </summary> /// </summary>
@@ -2071,7 +2071,7 @@ namespace Newtonsoft.Json
} }
else if (parseResult == ParseResult.Overflow) else if (parseResult == ParseResult.Overflow)
{ {
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
string number = _stringReference.ToString(); string number = _stringReference.ToString();
if (number.Length > MaximumJavascriptIntegerCharacterLength) if (number.Length > MaximumJavascriptIntegerCharacterLength)
@@ -2132,7 +2132,7 @@ namespace Newtonsoft.Json
return JsonReaderException.Create(this, message, ex); return JsonReaderException.Create(this, message, ex);
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
// By using the BigInteger type in a separate method, // By using the BigInteger type in a separate method,
// the runtime can execute the ParseNumber even if // the runtime can execute the ParseNumber even if
// the System.Numerics.BigInteger.Parse method is // the System.Numerics.BigInteger.Parse method is
@@ -2485,7 +2485,7 @@ namespace Newtonsoft.Json
if (CloseInput) if (CloseInput)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_STREAM_READER_WRITER_CLOSE
_reader?.Close(); _reader?.Close();
#else #else
_reader?.Dispose(); _reader?.Dispose();
+7 -7
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -23,12 +23,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -40,7 +40,7 @@ namespace Newtonsoft.Json
{ {
// It's not safe to perform the async methods here in a derived class as if the synchronous equivalent // It's not safe to perform the async methods here in a derived class as if the synchronous equivalent
// has been overriden then the asychronous method will no longer be doing the same operation. // has been overriden then the asychronous method will no longer be doing the same operation.
#if !(NET20 || NET35 || NET40 || PORTABLE40) // Double-check this isn't included inappropriately. #if HAVE_ASYNC // Double-check this isn't included inappropriately.
private readonly bool _safeAsync; private readonly bool _safeAsync;
#endif #endif
@@ -882,7 +882,7 @@ namespace Newtonsoft.Json
await InternalWriteValueAsync(JsonToken.String, cancellationToken).ConfigureAwait(false); await InternalWriteValueAsync(JsonToken.String, cancellationToken).ConfigureAwait(false);
await _writer.WriteAsync(_quoteChar).ConfigureAwait(false); await _writer.WriteAsync(_quoteChar).ConfigureAwait(false);
#if !(DOTNET || PORTABLE) #if HAVE_CHAR_TO_STRING_WITH_CULTURE
await _writer.WriteAsync(value.ToString("D", CultureInfo.InvariantCulture), cancellationToken).ConfigureAwait(false); await _writer.WriteAsync(value.ToString("D", CultureInfo.InvariantCulture), cancellationToken).ConfigureAwait(false);
#else #else
await _writer.WriteAsync(value.ToString("D"), cancellationToken).ConfigureAwait(false); await _writer.WriteAsync(value.ToString("D"), cancellationToken).ConfigureAwait(false);
@@ -970,7 +970,7 @@ namespace Newtonsoft.Json
return value == null ? DoWriteNullAsync(cancellationToken) : WriteIntegerValueAsync(value.GetValueOrDefault(), cancellationToken); return value == null ? DoWriteNullAsync(cancellationToken) : WriteIntegerValueAsync(value.GetValueOrDefault(), cancellationToken);
} }
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
internal Task WriteValueAsync(BigInteger value, CancellationToken cancellationToken) internal Task WriteValueAsync(BigInteger value, CancellationToken cancellationToken)
{ {
return WriteValueInternalAsync(JsonToken.Integer, value.ToString(CultureInfo.InvariantCulture), cancellationToken); return WriteValueInternalAsync(JsonToken.Integer, value.ToString(CultureInfo.InvariantCulture), cancellationToken);
@@ -993,7 +993,7 @@ namespace Newtonsoft.Json
{ {
return WriteNullAsync(cancellationToken); return WriteNullAsync(cancellationToken);
} }
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
return WriteValueAsync((BigInteger)value, cancellationToken); return WriteValueAsync((BigInteger)value, cancellationToken);
+8 -8
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -26,7 +26,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Text; using System.Text;
@@ -162,7 +162,7 @@ namespace Newtonsoft.Json
UpdateCharEscapeFlags(); UpdateCharEscapeFlags();
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
_safeAsync = GetType() == typeof(JsonTextWriter); _safeAsync = GetType() == typeof(JsonTextWriter);
#endif #endif
} }
@@ -196,7 +196,7 @@ namespace Newtonsoft.Json
if (CloseOutput) if (CloseOutput)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_STREAM_READER_WRITER_CLOSE
_writer?.Close(); _writer?.Close();
#else #else
_writer?.Dispose(); _writer?.Dispose();
@@ -388,7 +388,7 @@ namespace Newtonsoft.Json
/// <param name="value">The <see cref="Object"/> value to write.</param> /// <param name="value">The <see cref="Object"/> value to write.</param>
public override void WriteValue(object value) public override void WriteValue(object value)
{ {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
InternalWriteValue(JsonToken.Integer); InternalWriteValue(JsonToken.Integer);
@@ -676,7 +676,7 @@ namespace Newtonsoft.Json
} }
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
@@ -721,7 +721,7 @@ namespace Newtonsoft.Json
string text = null; string text = null;
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_CHAR_TO_STRING_WITH_CULTURE
text = value.ToString("D", CultureInfo.InvariantCulture); text = value.ToString("D", CultureInfo.InvariantCulture);
#else #else
text = value.ToString("D"); text = value.ToString("D");
@@ -741,7 +741,7 @@ namespace Newtonsoft.Json
InternalWriteValue(JsonToken.String); InternalWriteValue(JsonToken.String);
string text; string text;
#if (NET35 || NET20) #if !HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE
text = value.ToString(); text = value.ToString();
#else #else
text = value.ToString(null, CultureInfo.InvariantCulture); text = value.ToString(null, CultureInfo.InvariantCulture);
+6 -6
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -34,7 +34,7 @@ using Newtonsoft.Json.Utilities;
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.IO; using System.IO;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -490,7 +490,7 @@ namespace Newtonsoft.Json
return dateTime; return dateTime;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Reads the next JSON token from the underlying <see cref="JsonReader"/> as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>. /// Reads the next JSON token from the underlying <see cref="JsonReader"/> as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>.
/// </summary> /// </summary>
@@ -714,7 +714,7 @@ namespace Newtonsoft.Json
{ {
IEnumerable<string> unmatchedRequiredProperties = requiredProperties.Where(kv => !kv.Value).Select(kv => kv.Key); IEnumerable<string> unmatchedRequiredProperties = requiredProperties.Where(kv => !kv.Value).Select(kv => kv.Key);
RaiseError("Required properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties RaiseError("Required properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties
#if NET20 || NET35 #if !HAVE_STRING_JOIN_WITH_ENUMERABLE
.ToArray() .ToArray()
#endif #endif
)), schema); )), schema);
@@ -852,7 +852,7 @@ namespace Newtonsoft.Json
if (schema.DivisibleBy != null) if (schema.DivisibleBy != null)
{ {
bool notDivisible; bool notDivisible;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
// not that this will lose any decimal point on DivisibleBy // not that this will lose any decimal point on DivisibleBy
+7 -7
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -23,12 +23,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -612,7 +612,7 @@ namespace Newtonsoft.Json
case JsonToken.Integer: case JsonToken.Integer:
ValidationUtils.ArgumentNotNull(value, nameof(value)); ValidationUtils.ArgumentNotNull(value, nameof(value));
return return
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
value is BigInteger ? WriteValueAsync((BigInteger)value, cancellationToken) : value is BigInteger ? WriteValueAsync((BigInteger)value, cancellationToken) :
#endif #endif
WriteValueAsync(Convert.ToInt64(value, CultureInfo.InvariantCulture), cancellationToken); WriteValueAsync(Convert.ToInt64(value, CultureInfo.InvariantCulture), cancellationToken);
@@ -1652,7 +1652,7 @@ namespace Newtonsoft.Json
return writer.WriteValueAsync((TimeSpan)value, cancellationToken); return writer.WriteValueAsync((TimeSpan)value, cancellationToken);
case PrimitiveTypeCode.TimeSpanNullable: case PrimitiveTypeCode.TimeSpanNullable:
return writer.WriteValueAsync(value == null ? (TimeSpan?)null : (TimeSpan)value, cancellationToken); return writer.WriteValueAsync(value == null ? (TimeSpan?)null : (TimeSpan)value, cancellationToken);
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
case PrimitiveTypeCode.BigInteger: case PrimitiveTypeCode.BigInteger:
// this will call to WriteValueAsync(object) // this will call to WriteValueAsync(object)
@@ -1668,12 +1668,12 @@ namespace Newtonsoft.Json
return writer.WriteValueAsync((string)value, cancellationToken); return writer.WriteValueAsync((string)value, cancellationToken);
case PrimitiveTypeCode.Bytes: case PrimitiveTypeCode.Bytes:
return writer.WriteValueAsync((byte[])value, cancellationToken); return writer.WriteValueAsync((byte[])value, cancellationToken);
#if !(PORTABLE || DOTNET) #if HAVE_DB_NULL_TYPE_CODE
case PrimitiveTypeCode.DBNull: case PrimitiveTypeCode.DBNull:
return writer.WriteNullAsync(cancellationToken); return writer.WriteNullAsync(cancellationToken);
#endif #endif
default: default:
#if !PORTABLE #if HAVE_ICONVERTIBLE
IConvertible convertable = value as IConvertible; IConvertible convertable = value as IConvertible;
if (convertable != null) if (convertable != null)
{ {
+11 -11
View File
@@ -26,12 +26,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Globalization; using System.Globalization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -532,7 +532,7 @@ namespace Newtonsoft.Json
break; break;
case JsonToken.Integer: case JsonToken.Integer:
ValidationUtils.ArgumentNotNull(value, nameof(value)); ValidationUtils.ArgumentNotNull(value, nameof(value));
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
WriteValue((BigInteger)value); WriteValue((BigInteger)value);
@@ -587,7 +587,7 @@ namespace Newtonsoft.Json
break; break;
case JsonToken.Date: case JsonToken.Date:
ValidationUtils.ArgumentNotNull(value, nameof(value)); ValidationUtils.ArgumentNotNull(value, nameof(value));
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (value is DateTimeOffset) if (value is DateTimeOffset)
{ {
WriteValue((DateTimeOffset)value); WriteValue((DateTimeOffset)value);
@@ -1049,7 +1049,7 @@ namespace Newtonsoft.Json
InternalWriteValue(JsonToken.Date); InternalWriteValue(JsonToken.Date);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
@@ -1306,7 +1306,7 @@ namespace Newtonsoft.Json
} }
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Writes a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/> value. /// Writes a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
@@ -1401,7 +1401,7 @@ namespace Newtonsoft.Json
} }
else else
{ {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
// this is here because adding a WriteValue(BigInteger) to JsonWriter will // this is here because adding a WriteValue(BigInteger) to JsonWriter will
// mean the user has to add a reference to System.Numerics.dll // mean the user has to add a reference to System.Numerics.dll
if (value is BigInteger) if (value is BigInteger)
@@ -1533,7 +1533,7 @@ namespace Newtonsoft.Json
case PrimitiveTypeCode.DateTimeNullable: case PrimitiveTypeCode.DateTimeNullable:
writer.WriteValue((value == null) ? (DateTime?)null : (DateTime)value); writer.WriteValue((value == null) ? (DateTime?)null : (DateTime)value);
break; break;
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffset: case PrimitiveTypeCode.DateTimeOffset:
writer.WriteValue((DateTimeOffset)value); writer.WriteValue((DateTimeOffset)value);
break; break;
@@ -1559,7 +1559,7 @@ namespace Newtonsoft.Json
case PrimitiveTypeCode.TimeSpanNullable: case PrimitiveTypeCode.TimeSpanNullable:
writer.WriteValue((value == null) ? (TimeSpan?)null : (TimeSpan)value); writer.WriteValue((value == null) ? (TimeSpan?)null : (TimeSpan)value);
break; break;
#if !(PORTABLE || PORTABLE40 || NET35 || NET20) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
case PrimitiveTypeCode.BigInteger: case PrimitiveTypeCode.BigInteger:
// this will call to WriteValue(object) // this will call to WriteValue(object)
writer.WriteValue((BigInteger)value); writer.WriteValue((BigInteger)value);
@@ -1578,13 +1578,13 @@ namespace Newtonsoft.Json
case PrimitiveTypeCode.Bytes: case PrimitiveTypeCode.Bytes:
writer.WriteValue((byte[])value); writer.WriteValue((byte[])value);
break; break;
#if !(PORTABLE || DOTNET) #if HAVE_DB_NULL_TYPE_CODE
case PrimitiveTypeCode.DBNull: case PrimitiveTypeCode.DBNull:
writer.WriteNull(); writer.WriteNull();
break; break;
#endif #endif
default: default:
#if !PORTABLE #if HAVE_ICONVERTIBLE
IConvertible convertible = value as IConvertible; IConvertible convertible = value as IConvertible;
if (convertible != null) if (convertible != null)
{ {
+2 -2
View File
@@ -33,7 +33,7 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// The exception thrown when an error occurs while writing JSON text. /// The exception thrown when an error occurs while writing JSON text.
/// </summary> /// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
[Serializable] [Serializable]
#endif #endif
public class JsonWriterException : JsonException public class JsonWriterException : JsonException
@@ -72,7 +72,7 @@ namespace Newtonsoft.Json
{ {
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonWriterException"/> class. /// Initializes a new instance of the <see cref="JsonWriterException"/> class.
/// </summary> /// </summary>
+1 -1
View File
@@ -27,7 +27,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Globalization; using System.Globalization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
+1 -1
View File
@@ -32,7 +32,7 @@ namespace Newtonsoft.Json.Linq
/// </summary> /// </summary>
/// <typeparam name="T">The type of token.</typeparam> /// <typeparam name="T">The type of token.</typeparam>
public interface IJEnumerable< public interface IJEnumerable<
#if !(NET20 || NET35) #if HAVE_VARIANT_TYPE_PARAMETERS
out out
#endif #endif
T> : IEnumerable<T> where T : JToken T> : IEnumerable<T> where T : JToken
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Globalization; using System.Globalization;
+22 -22
View File
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !PORTABLE40 #if HAVE_INOTIFY_COLLECTION_CHANGED
using System.Collections.Specialized; using System.Collections.Specialized;
#endif #endif
using System.Threading; using System.Threading;
@@ -33,7 +33,7 @@ using Newtonsoft.Json.Utilities;
using System.Collections; using System.Collections;
using System.Globalization; using System.Globalization;
using System.ComponentModel; using System.ComponentModel;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -45,16 +45,16 @@ namespace Newtonsoft.Json.Linq
/// <summary> /// <summary>
/// Represents a token that can contain other tokens. /// Represents a token that can contain other tokens.
/// </summary> /// </summary>
public abstract partial class JContainer : JToken, IList<JToken>     public abstract partial class JContainer : JToken, IList<JToken>
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_COMPONENT_MODEL
, ITypedList, IBindingList , ITypedList, IBindingList
#endif #endif
, IList , IList
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
, INotifyCollectionChanged , INotifyCollectionChanged
#endif #endif
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
internal ListChangedEventHandler _listChanged; internal ListChangedEventHandler _listChanged;
internal AddingNewEventHandler _addingNew; internal AddingNewEventHandler _addingNew;
@@ -76,7 +76,7 @@ namespace Newtonsoft.Json.Linq
remove { _addingNew -= value; } remove { _addingNew -= value; }
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
internal NotifyCollectionChangedEventHandler _collectionChanged; internal NotifyCollectionChangedEventHandler _collectionChanged;
/// <summary> /// <summary>
@@ -96,7 +96,7 @@ namespace Newtonsoft.Json.Linq
protected abstract IList<JToken> ChildrenTokens { get; } protected abstract IList<JToken> ChildrenTokens { get; }
private object _syncRoot; private object _syncRoot;
#if !(PORTABLE40) #if (HAVE_COMPONENT_MODEL || HAVE_INOTIFY_COLLECTION_CHANGED)
private bool _busy; private bool _busy;
#endif #endif
@@ -119,7 +119,7 @@ namespace Newtonsoft.Json.Linq
internal void CheckReentrancy() internal void CheckReentrancy()
{ {
#if !(PORTABLE40) #if (HAVE_COMPONENT_MODEL || HAVE_INOTIFY_COLLECTION_CHANGED)
if (_busy) if (_busy)
{ {
throw new InvalidOperationException("Cannot change {0} during a collection change event.".FormatWith(CultureInfo.InvariantCulture, GetType())); throw new InvalidOperationException("Cannot change {0} during a collection change event.".FormatWith(CultureInfo.InvariantCulture, GetType()));
@@ -132,7 +132,7 @@ namespace Newtonsoft.Json.Linq
return new List<JToken>(); return new List<JToken>();
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
/// <summary> /// <summary>
/// Raises the <see cref="AddingNew"/> event. /// Raises the <see cref="AddingNew"/> event.
/// </summary> /// </summary>
@@ -164,7 +164,7 @@ namespace Newtonsoft.Json.Linq
} }
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
/// <summary> /// <summary>
/// Raises the <see cref="CollectionChanged"/> event. /// Raises the <see cref="CollectionChanged"/> event.
/// </summary> /// </summary>
@@ -384,13 +384,13 @@ namespace Newtonsoft.Json.Linq
children.Insert(index, item); children.Insert(index, item);
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
if (_listChanged != null) if (_listChanged != null)
{ {
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index)); OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
if (_collectionChanged != null) if (_collectionChanged != null)
{ {
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index)); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
@@ -432,13 +432,13 @@ namespace Newtonsoft.Json.Linq
children.RemoveAt(index); children.RemoveAt(index);
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
if (_listChanged != null) if (_listChanged != null)
{ {
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index)); OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
if (_collectionChanged != null) if (_collectionChanged != null)
{ {
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index)); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
@@ -512,13 +512,13 @@ namespace Newtonsoft.Json.Linq
existing.Previous = null; existing.Previous = null;
existing.Next = null; existing.Next = null;
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_COMPONENT_MODEL
if (_listChanged != null) if (_listChanged != null)
{ {
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index)); OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
if (_collectionChanged != null) if (_collectionChanged != null)
{ {
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, existing, index)); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, existing, index));
@@ -541,13 +541,13 @@ namespace Newtonsoft.Json.Linq
children.Clear(); children.Clear();
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
if (_listChanged != null) if (_listChanged != null)
{ {
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
if (_collectionChanged != null) if (_collectionChanged != null)
{ {
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
@@ -875,7 +875,7 @@ namespace Newtonsoft.Json.Linq
return hashCode; return hashCode;
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
string ITypedList.GetListName(PropertyDescriptor[] listAccessors) string ITypedList.GetListName(PropertyDescriptor[] listAccessors)
{ {
return string.Empty; return string.Empty;
@@ -1048,7 +1048,7 @@ namespace Newtonsoft.Json.Linq
#endregion #endregion
#region IBindingList Members #region IBindingList Members
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_COMPONENT_MODEL
void IBindingList.AddIndex(PropertyDescriptor property) void IBindingList.AddIndex(PropertyDescriptor property)
{ {
} }
@@ -1151,7 +1151,7 @@ namespace Newtonsoft.Json.Linq
} }
break; break;
case MergeArrayHandling.Union: case MergeArrayHandling.Union:
#if !NET20 #if HAVE_HASH_SET
HashSet<JToken> items = new HashSet<JToken>(target, EqualityComparer); HashSet<JToken> items = new HashSet<JToken>(target, EqualityComparer);
foreach (JToken item in content) foreach (JToken item in content)
+1 -1
View File
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
+13 -14
View File
@@ -25,23 +25,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if HAVE_INOTIFY_COLLECTION_CHANGED
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
#if !PORTABLE40
using System.Collections.Specialized; using System.Collections.Specialized;
#endif #endif
using System.ComponentModel; using System.ComponentModel;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System.Dynamic; using System.Dynamic;
using System.Linq.Expressions; using System.Linq.Expressions;
#endif #endif
using System.IO; using System.IO;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Globalization; using System.Globalization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Linq namespace Newtonsoft.Json.Linq
@@ -53,10 +52,10 @@ namespace Newtonsoft.Json.Linq
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParse" title="Parsing a JSON Object from Text" /> /// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParse" title="Parsing a JSON Object from Text" />
/// </example> /// </example>
public partial class JObject : JContainer, IDictionary<string, JToken>, INotifyPropertyChanged public partial class JObject : JContainer, IDictionary<string, JToken>, INotifyPropertyChanged
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
, ICustomTypeDescriptor , ICustomTypeDescriptor
#endif #endif
#if !(NET20 || PORTABLE40 || PORTABLE) #if HAVE_INOTIFY_PROPERTY_CHANGING
, INotifyPropertyChanging , INotifyPropertyChanging
#endif #endif
{ {
@@ -76,7 +75,7 @@ namespace Newtonsoft.Json.Linq
/// </summary> /// </summary>
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
#if !(NET20 || PORTABLE || PORTABLE40) #if HAVE_INOTIFY_PROPERTY_CHANGING
/// <summary> /// <summary>
/// Occurs when a property value is changing. /// Occurs when a property value is changing.
/// </summary> /// </summary>
@@ -208,13 +207,13 @@ namespace Newtonsoft.Json.Linq
internal void InternalPropertyChanged(JProperty childProperty) internal void InternalPropertyChanged(JProperty childProperty)
{ {
OnPropertyChanged(childProperty.Name); OnPropertyChanged(childProperty.Name);
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
if (_listChanged != null) if (_listChanged != null)
{ {
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, IndexOfItem(childProperty))); OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, IndexOfItem(childProperty)));
} }
#endif #endif
#if !(NET20 || NET35 || PORTABLE40) #if HAVE_INOTIFY_COLLECTION_CHANGED
if (_collectionChanged != null) if (_collectionChanged != null)
{ {
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, childProperty, childProperty, IndexOfItem(childProperty))); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, childProperty, childProperty, IndexOfItem(childProperty)));
@@ -224,7 +223,7 @@ namespace Newtonsoft.Json.Linq
internal void InternalPropertyChanging(JProperty childProperty) internal void InternalPropertyChanging(JProperty childProperty)
{ {
#if !(NET20 || PORTABLE40 || PORTABLE) #if HAVE_INOTIFY_PROPERTY_CHANGING
OnPropertyChanging(childProperty.Name); OnPropertyChanging(childProperty.Name);
#endif #endif
} }
@@ -333,7 +332,7 @@ namespace Newtonsoft.Json.Linq
} }
else else
{ {
#if !(NET20 || PORTABLE40 || PORTABLE) #if HAVE_INOTIFY_PROPERTY_CHANGING
OnPropertyChanging(propertyName); OnPropertyChanging(propertyName);
#endif #endif
Add(new JProperty(propertyName, value)); Add(new JProperty(propertyName, value));
@@ -705,7 +704,7 @@ namespace Newtonsoft.Json.Linq
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
#if !(PORTABLE40 || PORTABLE || NET20) #if HAVE_INOTIFY_PROPERTY_CHANGING
/// <summary> /// <summary>
/// Raises the <see cref="PropertyChanging"/> event with the provided arguments. /// Raises the <see cref="PropertyChanging"/> event with the provided arguments.
/// </summary> /// </summary>
@@ -716,7 +715,7 @@ namespace Newtonsoft.Json.Linq
} }
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
// include custom type descriptor on JObject rather than use a provider because the properties are specific to a type // include custom type descriptor on JObject rather than use a provider because the properties are specific to a type
#region ICustomTypeDescriptor #region ICustomTypeDescriptor
@@ -790,7 +789,7 @@ namespace Newtonsoft.Json.Linq
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
/// <summary> /// <summary>
/// Returns the <see cref="DynamicMetaObject"/> responsible for binding operations performed on this object. /// Returns the <see cref="DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary> /// </summary>
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_COMPONENT_MODEL
using System; using System;
using System.ComponentModel; using System.ComponentModel;
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Globalization; using System.Globalization;
+45 -45
View File
@@ -26,12 +26,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Linq.JsonPath;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System.Dynamic; using System.Dynamic;
using System.Linq.Expressions; using System.Linq.Expressions;
#endif #endif
using System.IO; using System.IO;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Text; using System.Text;
@@ -39,7 +39,7 @@ using Newtonsoft.Json.Utilities;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Collections; using System.Collections;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -52,10 +52,10 @@ namespace Newtonsoft.Json.Linq
/// Represents an abstract JSON token. /// Represents an abstract JSON token.
/// </summary> /// </summary>
public abstract partial class JToken : IJEnumerable<JToken>, IJsonLineInfo public abstract partial class JToken : IJEnumerable<JToken>, IJsonLineInfo
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ICLONEABLE
, ICloneable , ICloneable
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
, IDynamicMetaObjectProvider , IDynamicMetaObjectProvider
#endif #endif
{ {
@@ -68,7 +68,7 @@ namespace Newtonsoft.Json.Linq
private static readonly JTokenType[] BooleanTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean }; private static readonly JTokenType[] BooleanTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
private static readonly JTokenType[] NumberTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean }; private static readonly JTokenType[] NumberTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
private static readonly JTokenType[] BigIntegerTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean, JTokenType.Bytes }; private static readonly JTokenType[] BigIntegerTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean, JTokenType.Bytes };
#endif #endif
private static readonly JTokenType[] StringTypes = new[] { JTokenType.Date, JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean, JTokenType.Bytes, JTokenType.Guid, JTokenType.TimeSpan, JTokenType.Uri }; private static readonly JTokenType[] StringTypes = new[] { JTokenType.Date, JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean, JTokenType.Bytes, JTokenType.Guid, JTokenType.TimeSpan, JTokenType.Uri };
@@ -492,7 +492,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Boolean.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Boolean.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return Convert.ToBoolean((int)(BigInteger)v.Value); return Convert.ToBoolean((int)(BigInteger)v.Value);
@@ -502,7 +502,7 @@ namespace Newtonsoft.Json.Linq
return Convert.ToBoolean(v.Value, CultureInfo.InvariantCulture); return Convert.ToBoolean(v.Value, CultureInfo.InvariantCulture);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="System.DateTimeOffset"/>. /// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="System.DateTimeOffset"/>.
/// </summary> /// </summary>
@@ -548,7 +548,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Boolean.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Boolean.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return Convert.ToBoolean((int)(BigInteger)v.Value); return Convert.ToBoolean((int)(BigInteger)v.Value);
@@ -571,7 +571,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int64.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Int64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (long)(BigInteger)v.Value; return (long)(BigInteger)v.Value;
@@ -599,7 +599,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to DateTime.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to DateTime.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (v.Value is DateTimeOffset) if (v.Value is DateTimeOffset)
{ {
return ((DateTimeOffset)v.Value).DateTime; return ((DateTimeOffset)v.Value).DateTime;
@@ -609,7 +609,7 @@ namespace Newtonsoft.Json.Linq
return (v.Value != null) ? (DateTime?)Convert.ToDateTime(v.Value, CultureInfo.InvariantCulture) : null; return (v.Value != null) ? (DateTime?)Convert.ToDateTime(v.Value, CultureInfo.InvariantCulture) : null;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Performs an explicit conversion from <see cref="JToken"/> to <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>. /// Performs an explicit conversion from <see cref="JToken"/> to <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>.
/// </summary> /// </summary>
@@ -665,7 +665,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Decimal.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Decimal.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (decimal?)(BigInteger)v.Value; return (decimal?)(BigInteger)v.Value;
@@ -693,7 +693,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Double.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Double.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (double?)(BigInteger)v.Value; return (double?)(BigInteger)v.Value;
@@ -721,7 +721,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Char.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Char.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (char?)(BigInteger)v.Value; return (char?)(BigInteger)v.Value;
@@ -744,7 +744,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int32.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Int32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (int)(BigInteger)v.Value; return (int)(BigInteger)v.Value;
@@ -767,7 +767,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int16.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Int16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (short)(BigInteger)v.Value; return (short)(BigInteger)v.Value;
@@ -791,7 +791,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt16.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to UInt16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (ushort)(BigInteger)v.Value; return (ushort)(BigInteger)v.Value;
@@ -815,7 +815,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Char.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Char.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (char)(BigInteger)v.Value; return (char)(BigInteger)v.Value;
@@ -838,7 +838,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Byte.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Byte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (byte)(BigInteger)v.Value; return (byte)(BigInteger)v.Value;
@@ -862,7 +862,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to SByte.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to SByte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (sbyte)(BigInteger)v.Value; return (sbyte)(BigInteger)v.Value;
@@ -890,7 +890,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int32.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Int32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (int?)(BigInteger)v.Value; return (int?)(BigInteger)v.Value;
@@ -918,7 +918,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int16.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Int16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (short?)(BigInteger)v.Value; return (short?)(BigInteger)v.Value;
@@ -947,7 +947,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt16.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to UInt16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (ushort?)(BigInteger)v.Value; return (ushort?)(BigInteger)v.Value;
@@ -975,7 +975,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Byte.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Byte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (byte?)(BigInteger)v.Value; return (byte?)(BigInteger)v.Value;
@@ -1004,7 +1004,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to SByte.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to SByte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (sbyte?)(BigInteger)v.Value; return (sbyte?)(BigInteger)v.Value;
@@ -1027,7 +1027,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to DateTime.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to DateTime.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (v.Value is DateTimeOffset) if (v.Value is DateTimeOffset)
{ {
return ((DateTimeOffset)v.Value).DateTime; return ((DateTimeOffset)v.Value).DateTime;
@@ -1055,7 +1055,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int64.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Int64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (long?)(BigInteger)v.Value; return (long?)(BigInteger)v.Value;
@@ -1083,7 +1083,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Single.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Single.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (float?)(BigInteger)v.Value; return (float?)(BigInteger)v.Value;
@@ -1106,7 +1106,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Decimal.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Decimal.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (decimal)(BigInteger)v.Value; return (decimal)(BigInteger)v.Value;
@@ -1135,7 +1135,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt32.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to UInt32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (uint?)(BigInteger)v.Value; return (uint?)(BigInteger)v.Value;
@@ -1164,7 +1164,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt64.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to UInt64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (ulong?)(BigInteger)v.Value; return (ulong?)(BigInteger)v.Value;
@@ -1187,7 +1187,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Double.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Double.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (double)(BigInteger)v.Value; return (double)(BigInteger)v.Value;
@@ -1210,7 +1210,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Single.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to Single.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (float)(BigInteger)v.Value; return (float)(BigInteger)v.Value;
@@ -1249,7 +1249,7 @@ namespace Newtonsoft.Json.Linq
return Convert.ToBase64String(bytes); return Convert.ToBase64String(bytes);
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return ((BigInteger)v.Value).ToString(CultureInfo.InvariantCulture); return ((BigInteger)v.Value).ToString(CultureInfo.InvariantCulture);
@@ -1273,7 +1273,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt32.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to UInt32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (uint)(BigInteger)v.Value; return (uint)(BigInteger)v.Value;
@@ -1297,7 +1297,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt64.".FormatWith(CultureInfo.InvariantCulture, GetType(value))); throw new ArgumentException("Can not convert {0} to UInt64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return (ulong)(BigInteger)v.Value; return (ulong)(BigInteger)v.Value;
@@ -1329,7 +1329,7 @@ namespace Newtonsoft.Json.Linq
{ {
return Convert.FromBase64String(Convert.ToString(v.Value, CultureInfo.InvariantCulture)); return Convert.FromBase64String(Convert.ToString(v.Value, CultureInfo.InvariantCulture));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (v.Value is BigInteger) if (v.Value is BigInteger)
{ {
return ((BigInteger)v.Value).ToByteArray(); return ((BigInteger)v.Value).ToByteArray();
@@ -1467,7 +1467,7 @@ namespace Newtonsoft.Json.Linq
return (v.Value is Uri) ? (Uri)v.Value : new Uri(Convert.ToString(v.Value, CultureInfo.InvariantCulture)); return (v.Value is Uri) ? (Uri)v.Value : new Uri(Convert.ToString(v.Value, CultureInfo.InvariantCulture));
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
private static BigInteger ToBigInteger(JToken value) private static BigInteger ToBigInteger(JToken value)
{ {
JValue v = EnsureValue(value); JValue v = EnsureValue(value);
@@ -1508,7 +1508,7 @@ namespace Newtonsoft.Json.Linq
return new JValue(value); return new JValue(value);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Performs an implicit conversion from <see cref="DateTimeOffset"/> to <see cref="JToken"/>. /// Performs an implicit conversion from <see cref="DateTimeOffset"/> to <see cref="JToken"/>.
/// </summary> /// </summary>
@@ -1592,7 +1592,7 @@ namespace Newtonsoft.Json.Linq
return new JValue(value); return new JValue(value);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Performs an implicit conversion from <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/> to <see cref="JToken"/>. /// Performs an implicit conversion from <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/> to <see cref="JToken"/>.
/// </summary> /// </summary>
@@ -2028,7 +2028,7 @@ namespace Newtonsoft.Json.Linq
return (DateTime?)this; return (DateTime?)this;
case PrimitiveTypeCode.DateTime: case PrimitiveTypeCode.DateTime:
return (DateTime)this; return (DateTime)this;
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffsetNullable: case PrimitiveTypeCode.DateTimeOffsetNullable:
return (DateTimeOffset?)this; return (DateTimeOffset?)this;
case PrimitiveTypeCode.DateTimeOffset: case PrimitiveTypeCode.DateTimeOffset:
@@ -2046,7 +2046,7 @@ namespace Newtonsoft.Json.Linq
return (TimeSpan?)this; return (TimeSpan?)this;
case PrimitiveTypeCode.TimeSpan: case PrimitiveTypeCode.TimeSpan:
return (TimeSpan)this; return (TimeSpan)this;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
case PrimitiveTypeCode.BigIntegerNullable: case PrimitiveTypeCode.BigIntegerNullable:
return ToBigIntegerNullable(this); return ToBigIntegerNullable(this);
case PrimitiveTypeCode.BigInteger: case PrimitiveTypeCode.BigInteger:
@@ -2355,7 +2355,7 @@ namespace Newtonsoft.Json.Linq
return p.Evaluate(this, this, errorWhenNoMatch); return p.Evaluate(this, this, errorWhenNoMatch);
} }
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
/// <summary> /// <summary>
/// Returns the <see cref="DynamicMetaObject"/> responsible for binding operations performed on this object. /// Returns the <see cref="DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary> /// </summary>
@@ -2381,7 +2381,7 @@ namespace Newtonsoft.Json.Linq
} }
#endif #endif
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_ICLONEABLE
object ICloneable.Clone() object ICloneable.Clone()
{ {
return DeepClone(); return DeepClone();
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
+5 -5
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -25,7 +25,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
@@ -220,7 +220,7 @@ namespace Newtonsoft.Json.Linq
/// <param name="value">The <see cref="Object"/> value to write.</param> /// <param name="value">The <see cref="Object"/> value to write.</param>
public override void WriteValue(object value) public override void WriteValue(object value)
{ {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
InternalWriteValue(JsonToken.Integer); InternalWriteValue(JsonToken.Integer);
@@ -382,7 +382,7 @@ namespace Newtonsoft.Json.Linq
{ {
base.WriteValue(value); base.WriteValue(value);
string s = null; string s = null;
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_CHAR_TO_STRING_WITH_CULTURE
s = value.ToString(CultureInfo.InvariantCulture); s = value.ToString(CultureInfo.InvariantCulture);
#else #else
s = value.ToString(); s = value.ToString();
@@ -432,7 +432,7 @@ namespace Newtonsoft.Json.Linq
AddValue(value, JsonToken.Date); AddValue(value, JsonToken.Date);
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
+3 -3
View File
@@ -23,11 +23,11 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System; using System;
using System.Globalization; using System.Globalization;
#if !PORTABLE || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Threading; using System.Threading;
@@ -84,7 +84,7 @@ namespace Newtonsoft.Json.Linq
return writer.WriteValueAsync((ulong)_value, cancellationToken); return writer.WriteValueAsync((ulong)_value, cancellationToken);
} }
#if !(PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (_value is BigInteger) if (_value is BigInteger)
{ {
return writer.WriteValueAsync((BigInteger)_value, cancellationToken); return writer.WriteValueAsync((BigInteger)_value, cancellationToken);
+20 -21
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -28,13 +28,12 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Globalization; using System.Globalization;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System.Dynamic; using System.Dynamic;
using System.Linq.Expressions; using System.Linq.Expressions;
#endif #endif
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
namespace Newtonsoft.Json.Linq namespace Newtonsoft.Json.Linq
@@ -43,7 +42,7 @@ namespace Newtonsoft.Json.Linq
/// Represents a value in JSON (string, integer, date, etc). /// Represents a value in JSON (string, integer, date, etc).
/// </summary> /// </summary>
public partial class JValue : JToken, IEquatable<JValue>, IFormattable, IComparable, IComparable<JValue> public partial class JValue : JToken, IEquatable<JValue>, IFormattable, IComparable, IComparable<JValue>
#if !PORTABLE #if HAVE_ICONVERTIBLE
, IConvertible , IConvertible
#endif #endif
{ {
@@ -129,7 +128,7 @@ namespace Newtonsoft.Json.Linq
{ {
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JValue"/> class with the given value. /// Initializes a new instance of the <see cref="JValue"/> class with the given value.
/// </summary> /// </summary>
@@ -220,7 +219,7 @@ namespace Newtonsoft.Json.Linq
get { return false; } get { return false; }
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
private static int CompareBigInteger(BigInteger i1, object i2) private static int CompareBigInteger(BigInteger i1, object i2)
{ {
int result = i1.CompareTo(ConvertUtils.ToBigInteger(i2)); int result = i1.CompareTo(ConvertUtils.ToBigInteger(i2));
@@ -265,7 +264,7 @@ namespace Newtonsoft.Json.Linq
switch (valueType) switch (valueType)
{ {
case JTokenType.Integer: case JTokenType.Integer:
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (objA is BigInteger) if (objA is BigInteger)
{ {
return CompareBigInteger((BigInteger)objA, objB); return CompareBigInteger((BigInteger)objA, objB);
@@ -288,7 +287,7 @@ namespace Newtonsoft.Json.Linq
return Convert.ToInt64(objA, CultureInfo.InvariantCulture).CompareTo(Convert.ToInt64(objB, CultureInfo.InvariantCulture)); return Convert.ToInt64(objA, CultureInfo.InvariantCulture).CompareTo(Convert.ToInt64(objB, CultureInfo.InvariantCulture));
} }
case JTokenType.Float: case JTokenType.Float:
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (objA is BigInteger) if (objA is BigInteger)
{ {
return CompareBigInteger((BigInteger)objA, objB); return CompareBigInteger((BigInteger)objA, objB);
@@ -312,14 +311,14 @@ namespace Newtonsoft.Json.Linq
return b1.CompareTo(b2); return b1.CompareTo(b2);
case JTokenType.Date: case JTokenType.Date:
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (objA is DateTime) if (objA is DateTime)
{ {
#endif #endif
DateTime date1 = (DateTime)objA; DateTime date1 = (DateTime)objA;
DateTime date2; DateTime date2;
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (objB is DateTimeOffset) if (objB is DateTimeOffset)
{ {
date2 = ((DateTimeOffset)objB).DateTime; date2 = ((DateTimeOffset)objB).DateTime;
@@ -331,7 +330,7 @@ namespace Newtonsoft.Json.Linq
} }
return date1.CompareTo(date2); return date1.CompareTo(date2);
#if !NET20 #if HAVE_DATE_TIME_OFFSET
} }
else else
{ {
@@ -410,7 +409,7 @@ namespace Newtonsoft.Json.Linq
return d1.CompareTo(d2); return d1.CompareTo(d2);
} }
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_EXPRESSIONS
private static bool Operation(ExpressionType operation, object objA, object objB, out object result) private static bool Operation(ExpressionType operation, object objA, object objB, out object result)
{ {
if (objA is string || objB is string) if (objA is string || objB is string)
@@ -422,7 +421,7 @@ namespace Newtonsoft.Json.Linq
} }
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (objA is BigInteger || objB is BigInteger) if (objA is BigInteger || objB is BigInteger)
{ {
if (objA == null || objB == null) if (objA == null || objB == null)
@@ -607,7 +606,7 @@ namespace Newtonsoft.Json.Linq
{ {
return JTokenType.Null; return JTokenType.Null;
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
else if (value == DBNull.Value) else if (value == DBNull.Value)
{ {
return JTokenType.Null; return JTokenType.Null;
@@ -626,7 +625,7 @@ namespace Newtonsoft.Json.Linq
{ {
return JTokenType.Integer; return JTokenType.Integer;
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
else if (value is BigInteger) else if (value is BigInteger)
{ {
return JTokenType.Integer; return JTokenType.Integer;
@@ -640,7 +639,7 @@ namespace Newtonsoft.Json.Linq
{ {
return JTokenType.Date; return JTokenType.Date;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
return JTokenType.Date; return JTokenType.Date;
@@ -762,7 +761,7 @@ namespace Newtonsoft.Json.Linq
{ {
writer.WriteValue((ulong)_value); writer.WriteValue((ulong)_value);
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
else if (_value is BigInteger) else if (_value is BigInteger)
{ {
writer.WriteValue((BigInteger)_value); writer.WriteValue((BigInteger)_value);
@@ -798,7 +797,7 @@ namespace Newtonsoft.Json.Linq
writer.WriteValue(Convert.ToBoolean(_value, CultureInfo.InvariantCulture)); writer.WriteValue(Convert.ToBoolean(_value, CultureInfo.InvariantCulture));
return; return;
case JTokenType.Date: case JTokenType.Date:
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (_value is DateTimeOffset) if (_value is DateTimeOffset)
{ {
writer.WriteValue((DateTimeOffset)_value); writer.WriteValue((DateTimeOffset)_value);
@@ -950,7 +949,7 @@ namespace Newtonsoft.Json.Linq
} }
} }
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
/// <summary> /// <summary>
/// Returns the <see cref="DynamicMetaObject"/> responsible for binding operations performed on this object. /// Returns the <see cref="DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary> /// </summary>
@@ -1073,7 +1072,7 @@ namespace Newtonsoft.Json.Linq
return Compare(_valueType, _value, obj._value); return Compare(_valueType, _value, obj._value);
} }
#if !PORTABLE #if HAVE_ICONVERTIBLE
TypeCode IConvertible.GetTypeCode() TypeCode IConvertible.GetTypeCode()
{ {
if (_value == null) if (_value == null)
@@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -40,7 +40,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
if (errorWhenNoMatch) if (errorWhenNoMatch)
{ {
throw new JsonException("Properties {0} not valid on {1}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", Names.Select(n => "'" + n + "'") throw new JsonException("Properties {0} not valid on {1}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", Names.Select(n => "'" + n + "'")
#if NET20 || NET35 #if !HAVE_STRING_JOIN_WITH_ENUMERABLE
.ToArray() .ToArray()
#endif #endif
), t.GetType().Name)); ), t.GetType().Name));
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -208,7 +208,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
case JTokenType.Date: case JTokenType.Date:
using (StringWriter writer = StringUtils.CreateStringWriter(64)) using (StringWriter writer = StringUtils.CreateStringWriter(64))
{ {
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (value.Value is DateTimeOffset) if (value.Value is DateTimeOffset)
{ {
DateTimeUtils.WriteDateTimeOffsetString(writer, (DateTimeOffset)value.Value, DateFormatHandling.IsoDateFormat, null, CultureInfo.InvariantCulture); DateTimeUtils.WriteDateTimeOffsetString(writer, (DateTimeOffset)value.Value, DateFormatHandling.IsoDateFormat, null, CultureInfo.InvariantCulture);
@@ -42,6 +42,8 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<DefineConstants>NET20;HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_BINARY_SERIALIZATION;HAVE_CAS;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_DB_NULL_TYPE_CODE;HAVE_EMPTY_TYPES;HAVE_FULL_REFLECTION;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_MEMORY_BARRIER;
HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_REFLECTION_EMIT;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_TRACE_WRITER;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_XML_DOCUMENT</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -49,7 +51,7 @@
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\Net20\</OutputPath> <OutputPath>bin\Debug\Net20\</OutputPath>
<IntermediateOutputPath>obj\Debug\Net20\</IntermediateOutputPath> <IntermediateOutputPath>obj\Debug\Net20\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;NET20</DefineConstants> <DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Net20\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Debug\Net20\Newtonsoft.Json.xml</DocumentationFile>
@@ -63,7 +65,7 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\Net20\</OutputPath> <OutputPath>bin\Release\Net20\</OutputPath>
<IntermediateOutputPath>obj\Release\Net20\</IntermediateOutputPath> <IntermediateOutputPath>obj\Release\Net20\</IntermediateOutputPath>
<DefineConstants>TRACE;NET20</DefineConstants> <DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Net20\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Release\Net20\Newtonsoft.Json.xml</DocumentationFile>
@@ -44,6 +44,7 @@
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<DefineConstants>NET35;HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_BINARY_SERIALIZATION;HAVE_CAS;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_EMPTY_TYPES;HAVE_ENTITY_FRAMEWORK;HAVE_FULL_REFLECTION;HAVE_HASH_SET;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_LINQ;HAVE_MEMORY_BARRIER; HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_REFLECTION_EMIT;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_TIME_ZONE_INFO;HAVE_TRACE_WRITER;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_XLINQ;HAVE_XML_DOCUMENT</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -51,7 +52,7 @@
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\Net35\</OutputPath> <OutputPath>bin\Debug\Net35\</OutputPath>
<IntermediateOutputPath>obj\Debug\Net35\</IntermediateOutputPath> <IntermediateOutputPath>obj\Debug\Net35\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;NET35</DefineConstants> <DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Net35\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Debug\Net35\Newtonsoft.Json.xml</DocumentationFile>
@@ -66,7 +67,7 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\Net35\</OutputPath> <OutputPath>bin\Release\Net35\</OutputPath>
<IntermediateOutputPath>obj\Release\Net35\</IntermediateOutputPath> <IntermediateOutputPath>obj\Release\Net35\</IntermediateOutputPath>
<DefineConstants>TRACE;NET35</DefineConstants> <DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Net35\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Release\Net35\Newtonsoft.Json.xml</DocumentationFile>
@@ -44,6 +44,7 @@
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<DefineConstants>NET40;HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_BIG_INTEGER;HAVE_BINARY_SERIALIZATION;HAVE_CAS;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_CONCURRENT_COLLECTIONS;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_DYNAMIC;HAVE_EMPTY_TYPES;HAVE_ENTITY_FRAMEWORK;HAVE_EXPRESSIONS;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_REFLECTION_EMIT;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_TPL;HAVE_TRACE_WRITER;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -51,7 +52,7 @@
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\Net40\</OutputPath> <OutputPath>bin\Debug\Net40\</OutputPath>
<IntermediateOutputPath>obj\Debug\Net40\</IntermediateOutputPath> <IntermediateOutputPath>obj\Debug\Net40\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;NET40;CODE_ANALYSIS</DefineConstants> <DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Net40\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Debug\Net40\Newtonsoft.Json.xml</DocumentationFile>
@@ -66,7 +67,7 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\Net40\</OutputPath> <OutputPath>bin\Release\Net40\</OutputPath>
<IntermediateOutputPath>obj\Release\Net40\</IntermediateOutputPath> <IntermediateOutputPath>obj\Release\Net40\</IntermediateOutputPath>
<DefineConstants>TRACE;NET40;CODE_ANALYSIS</DefineConstants> <DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Net40\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Release\Net40\Newtonsoft.Json.xml</DocumentationFile>
@@ -13,6 +13,7 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<DefineConstants>PORTABLE;HAVE_ASYNC;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DYNAMIC;HAVE_EXPRESSIONS;HAVE_FSHARP_TYPES;HAVE_GUID_TRY_PARSE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_IMMUTABLE_COLLECTIONS;HAVE_ISET;HAVE_LINQ;HAVE_METHOD_IMPL_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_REFLECTION_BINDER;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_TPL;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_INOTIFY_COLLECTION_CHANGED</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -20,7 +21,7 @@
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\Portable\</OutputPath> <OutputPath>bin\Debug\Portable\</OutputPath>
<IntermediateOutputPath>obj\Debug\Portable\</IntermediateOutputPath> <IntermediateOutputPath>obj\Debug\Portable\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants> <DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis> <RunCodeAnalysis>true</RunCodeAnalysis>
@@ -31,8 +32,7 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\Portable\</OutputPath> <OutputPath>bin\Release\Portable\</OutputPath>
<IntermediateOutputPath>obj\Release\Portable\</IntermediateOutputPath> <IntermediateOutputPath>obj\Release\Portable\</IntermediateOutputPath>
<DefineConstants>TRACE;PORTABLE</DefineConstants> <DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants><ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Portable\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Release\Portable\Newtonsoft.Json.xml</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis> <RunCodeAnalysis>true</RunCodeAnalysis>
@@ -18,6 +18,7 @@
<UpgradeBackupLocation> <UpgradeBackupLocation>
</UpgradeBackupLocation> </UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion> <OldToolsVersion>4.0</OldToolsVersion>
<DefineConstants>PORTABLE40;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_IMMUTABLE_COLLECTIONS;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -25,7 +26,7 @@
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\Portable40\</OutputPath> <OutputPath>bin\Debug\Portable40\</OutputPath>
<IntermediateOutputPath>obj\Debug\Portable40\</IntermediateOutputPath> <IntermediateOutputPath>obj\Debug\Portable40\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;PORTABLE40</DefineConstants> <DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis> <RunCodeAnalysis>true</RunCodeAnalysis>
@@ -36,7 +37,7 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\Portable40\</OutputPath> <OutputPath>bin\Release\Portable40\</OutputPath>
<IntermediateOutputPath>obj\Release\Portable40\</IntermediateOutputPath> <IntermediateOutputPath>obj\Release\Portable40\</IntermediateOutputPath>
<DefineConstants>TRACE;CODE_ANALYSIS;PORTABLE40</DefineConstants> <DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Portable40\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Release\Portable40\Newtonsoft.Json.xml</DocumentationFile>
+4 -2
View File
@@ -11,6 +11,8 @@
<AssemblyName>Newtonsoft.Json</AssemblyName> <AssemblyName>Newtonsoft.Json</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<DefineConstants>HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_ASYNC;HAVE_BIG_INTEGER;HAVE_BINARY_SERIALIZATION;HAVE_CAS;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_CONCURRENT_COLLECTIONS;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_DYNAMIC;HAVE_EMPTY_TYPES;HAVE_ENTITY_FRAMEWORK;HAVE_EXPRESSIONS;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_IMMUTABLE_COLLECTIONS;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_METHOD_IMPL_ATTRIBUTE;
HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_REFLECTION_EMIT;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_TPL;HAVE_TRACE_WRITER;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -18,7 +20,7 @@
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\Net45\</OutputPath> <OutputPath>bin\Debug\Net45\</OutputPath>
<IntermediateOutputPath>obj\Debug\Net45\</IntermediateOutputPath> <IntermediateOutputPath>obj\Debug\Net45\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS</DefineConstants> <DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Net45\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Debug\Net45\Newtonsoft.Json.xml</DocumentationFile>
@@ -31,7 +33,7 @@
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\Net45\</OutputPath> <OutputPath>bin\Release\Net45\</OutputPath>
<IntermediateOutputPath>obj\Release\Net45\</IntermediateOutputPath> <IntermediateOutputPath>obj\Release\Net45\</IntermediateOutputPath>
<DefineConstants>TRACE;CODE_ANALYSIS</DefineConstants> <DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Net45\Newtonsoft.Json.xml</DocumentationFile> <DocumentationFile>bin\Release\Net45\Newtonsoft.Json.xml</DocumentationFile>
@@ -74,7 +74,7 @@ using System.Security;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
#if !(PORTABLE40 || PORTABLE) #if HAVE_COM_ATTRIBUTES
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
@@ -26,7 +26,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -36,7 +36,7 @@ namespace Newtonsoft.Json.Schema
/// JSON Schema validation has been moved to its own package. See <see href="http://www.newtonsoft.com/jsonschema">http://www.newtonsoft.com/jsonschema</see> for more details. /// JSON Schema validation has been moved to its own package. See <see href="http://www.newtonsoft.com/jsonschema">http://www.newtonsoft.com/jsonschema</see> for more details.
/// </note> /// </note>
/// </summary> /// </summary>
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
[Serializable] [Serializable]
#endif #endif
[Obsolete("JSON Schema validation has been moved to its own package. See http://www.newtonsoft.com/jsonschema for more details.")] [Obsolete("JSON Schema validation has been moved to its own package. See http://www.newtonsoft.com/jsonschema for more details.")]
@@ -88,7 +88,7 @@ namespace Newtonsoft.Json.Schema
{ {
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonSchemaException"/> class. /// Initializes a new instance of the <see cref="JsonSchemaException"/> class.
/// </summary> /// </summary>
@@ -30,7 +30,7 @@ using System.Collections.Generic;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -193,7 +193,7 @@ namespace Newtonsoft.Json.Schema
return containerAttribute.Description; return containerAttribute.Description;
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
DescriptionAttribute descriptionAttribute = ReflectionUtils.GetAttribute<DescriptionAttribute>(type); DescriptionAttribute descriptionAttribute = ReflectionUtils.GetAttribute<DescriptionAttribute>(type);
return descriptionAttribute?.Description; return descriptionAttribute?.Description;
#else #else
@@ -354,14 +354,14 @@ namespace Newtonsoft.Json.Schema
} }
} }
break; break;
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
case JsonContractType.Serializable: case JsonContractType.Serializable:
CurrentSchema.Type = AddNullType(JsonSchemaType.Object, valueRequired); CurrentSchema.Type = AddNullType(JsonSchemaType.Object, valueRequired);
CurrentSchema.Id = GetTypeId(type, false); CurrentSchema.Id = GetTypeId(type, false);
GenerateISerializableContract(type, (JsonISerializableContract)contract); GenerateISerializableContract(type, (JsonISerializableContract)contract);
break; break;
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
case JsonContractType.Dynamic: case JsonContractType.Dynamic:
#endif #endif
case JsonContractType.Linq: case JsonContractType.Linq:
@@ -419,7 +419,7 @@ namespace Newtonsoft.Json.Schema
} }
} }
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
private void GenerateISerializableContract(Type type, JsonISerializableContract contract) private void GenerateISerializableContract(Type type, JsonISerializableContract contract)
{ {
CurrentSchema.AllowAdditionalProperties = true; CurrentSchema.AllowAdditionalProperties = true;
@@ -468,7 +468,7 @@ namespace Newtonsoft.Json.Schema
case PrimitiveTypeCode.Empty: case PrimitiveTypeCode.Empty:
case PrimitiveTypeCode.Object: case PrimitiveTypeCode.Object:
return schemaType | JsonSchemaType.String; return schemaType | JsonSchemaType.String;
#if !(DOTNET || PORTABLE) #if HAVE_DB_NULL_TYPE_CODE
case PrimitiveTypeCode.DBNull: case PrimitiveTypeCode.DBNull:
return schemaType | JsonSchemaType.Null; return schemaType | JsonSchemaType.Null;
#endif #endif
@@ -484,7 +484,7 @@ namespace Newtonsoft.Json.Schema
case PrimitiveTypeCode.UInt32: case PrimitiveTypeCode.UInt32:
case PrimitiveTypeCode.Int64: case PrimitiveTypeCode.Int64:
case PrimitiveTypeCode.UInt64: case PrimitiveTypeCode.UInt64:
#if !(PORTABLE || NET35 || NET20) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
case PrimitiveTypeCode.BigInteger: case PrimitiveTypeCode.BigInteger:
#endif #endif
return schemaType | JsonSchemaType.Integer; return schemaType | JsonSchemaType.Integer;
@@ -494,7 +494,7 @@ namespace Newtonsoft.Json.Schema
return schemaType | JsonSchemaType.Float; return schemaType | JsonSchemaType.Float;
// convert to string? // convert to string?
case PrimitiveTypeCode.DateTime: case PrimitiveTypeCode.DateTime:
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffset: case PrimitiveTypeCode.DateTimeOffset:
#endif #endif
return schemaType | JsonSchemaType.String; return schemaType | JsonSchemaType.String;
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
+2 -2
View File
@@ -26,7 +26,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -76,7 +76,7 @@ namespace Newtonsoft.Json.Schema
public static string GetId(IEnumerable<JsonSchema> schemata) public static string GetId(IEnumerable<JsonSchema> schemata)
{ {
return string.Join("-", schemata.Select(s => s.InternalId).OrderBy(id => id, StringComparer.Ordinal) return string.Join("-", schemata.Select(s => s.InternalId).OrderBy(id => id, StringComparer.Ordinal)
#if NET20 || NET35 #if !HAVE_STRING_JOIN_WITH_ENUMERABLE
.ToArray() .ToArray()
#endif #endif
); );
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -28,7 +28,7 @@ using System.Collections.Generic;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -26,25 +26,25 @@
using System; using System;
using System.Collections; using System.Collections;
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema;
#if !(NET35 || NET20 || PORTABLE || PORTABLE40) #if HAVE_CONCURRENT_COLLECTIONS
using System.Collections.Concurrent; using System.Collections.Concurrent;
#endif #endif
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System.Dynamic; using System.Dynamic;
#endif #endif
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_CAS
using System.Security.Permissions; using System.Security.Permissions;
#endif #endif
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -107,21 +107,21 @@ namespace Newtonsoft.Json.Serialization
private static readonly JsonConverter[] BuiltInConverters = private static readonly JsonConverter[] BuiltInConverters =
{ {
#if !(NET20 || DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ENTITY_FRAMEWORK
new EntityKeyMemberConverter(), new EntityKeyMemberConverter(),
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
new ExpandoObjectConverter(), new ExpandoObjectConverter(),
#endif #endif
#if !(PORTABLE40) #if (HAVE_XML_DOCUMENT || HAVE_XLINQ)
new XmlNodeConverter(), new XmlNodeConverter(),
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
new BinaryConverter(), new BinaryConverter(),
new DataSetConverter(), new DataSetConverter(),
new DataTableConverter(), new DataTableConverter(),
#endif #endif
#if !(NET35 || NET20) #if HAVE_FSHARP_TYPES
new DiscriminatedUnionConverter(), new DiscriminatedUnionConverter(),
#endif #endif
new KeyValuePairConverter(), new KeyValuePairConverter(),
@@ -166,7 +166,7 @@ namespace Newtonsoft.Json.Serialization
/// </value> /// </value>
public bool SerializeCompilerGeneratedMembers { get; set; } public bool SerializeCompilerGeneratedMembers { get; set; }
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Gets or sets a value indicating whether to ignore the <see cref="ISerializable"/> interface when serializing and deserializing types. /// Gets or sets a value indicating whether to ignore the <see cref="ISerializable"/> interface when serializing and deserializing types.
/// </summary> /// </summary>
@@ -195,7 +195,7 @@ namespace Newtonsoft.Json.Serialization
/// </summary> /// </summary>
public DefaultContractResolver() public DefaultContractResolver()
{ {
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
IgnoreSerializableAttribute = true; IgnoreSerializableAttribute = true;
#endif #endif
@@ -277,7 +277,7 @@ namespace Newtonsoft.Json.Serialization
protected virtual List<MemberInfo> GetSerializableMembers(Type objectType) protected virtual List<MemberInfo> GetSerializableMembers(Type objectType)
{ {
bool ignoreSerializableAttribute; bool ignoreSerializableAttribute;
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
ignoreSerializableAttribute = IgnoreSerializableAttribute; ignoreSerializableAttribute = IgnoreSerializableAttribute;
#else #else
ignoreSerializableAttribute = true; ignoreSerializableAttribute = true;
@@ -292,7 +292,7 @@ namespace Newtonsoft.Json.Serialization
if (memberSerialization != MemberSerialization.Fields) if (memberSerialization != MemberSerialization.Fields)
{ {
#if !NET20 #if HAVE_DATA_CONTRACTS
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(objectType); DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(objectType);
#endif #endif
@@ -323,7 +323,7 @@ namespace Newtonsoft.Json.Serialization
{ {
serializableMembers.Add(member); serializableMembers.Add(member);
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
else if (dataContractAttribute != null && JsonTypeReflector.GetAttribute<DataMemberAttribute>(member) != null) else if (dataContractAttribute != null && JsonTypeReflector.GetAttribute<DataMemberAttribute>(member) != null)
{ {
serializableMembers.Add(member); serializableMembers.Add(member);
@@ -337,7 +337,7 @@ namespace Newtonsoft.Json.Serialization
} }
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
Type match; Type match;
// don't include EntityKey on entities objects... this is a bit hacky // don't include EntityKey on entities objects... this is a bit hacky
if (objectType.AssignableToTypeName("System.Data.Objects.DataClasses.EntityObject", out match)) if (objectType.AssignableToTypeName("System.Data.Objects.DataClasses.EntityObject", out match))
@@ -362,7 +362,7 @@ namespace Newtonsoft.Json.Serialization
return serializableMembers; return serializableMembers;
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
private bool ShouldSerializeEntityMember(MemberInfo memberInfo) private bool ShouldSerializeEntityMember(MemberInfo memberInfo)
{ {
PropertyInfo propertyInfo = memberInfo as PropertyInfo; PropertyInfo propertyInfo = memberInfo as PropertyInfo;
@@ -389,7 +389,7 @@ namespace Newtonsoft.Json.Serialization
InitializeContract(contract); InitializeContract(contract);
bool ignoreSerializableAttribute; bool ignoreSerializableAttribute;
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
ignoreSerializableAttribute = IgnoreSerializableAttribute; ignoreSerializableAttribute = IgnoreSerializableAttribute;
#else #else
ignoreSerializableAttribute = true; ignoreSerializableAttribute = true;
@@ -432,7 +432,7 @@ namespace Newtonsoft.Json.Serialization
} }
else if (contract.MemberSerialization == MemberSerialization.Fields) else if (contract.MemberSerialization == MemberSerialization.Fields)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_CAS
// mimic DataContractSerializer behaviour when populating fields by overriding default creator to create an uninitialized object // mimic DataContractSerializer behaviour when populating fields by overriding default creator to create an uninitialized object
// note that this is only possible when the application is fully trusted so fall back to using the default constructor (if available) in partial trust // note that this is only possible when the application is fully trusted so fall back to using the default constructor (if available) in partial trust
if (JsonTypeReflector.FullyTrusted) if (JsonTypeReflector.FullyTrusted)
@@ -775,7 +775,7 @@ namespace Newtonsoft.Json.Serialization
{ {
contract.IsReference = containerAttribute._isReference; contract.IsReference = containerAttribute._isReference;
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
else else
{ {
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(contract.NonNullableUnderlyingType); DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(contract.NonNullableUnderlyingType);
@@ -908,14 +908,14 @@ namespace Newtonsoft.Json.Serialization
private static bool ShouldSkipDeserialized(Type t) private static bool ShouldSkipDeserialized(Type t)
{ {
#if !(NET35 || NET20 || PORTABLE || PORTABLE40) #if HAVE_CONCURRENT_COLLECTIONS
// ConcurrentDictionary throws an error in its OnDeserialized so ignore - http://json.codeplex.com/discussions/257093 // ConcurrentDictionary throws an error in its OnDeserialized so ignore - http://json.codeplex.com/discussions/257093
if (t.IsGenericType() && t.GetGenericTypeDefinition() == typeof(ConcurrentDictionary<,>)) if (t.IsGenericType() && t.GetGenericTypeDefinition() == typeof(ConcurrentDictionary<,>))
{ {
return true; return true;
} }
#endif #endif
#if !(NET35 || NET20) #if HAVE_FSHARP_TYPES
if (t.Name == FSharpUtils.FSharpSetTypeName || t.Name == FSharpUtils.FSharpMapTypeName) if (t.Name == FSharpUtils.FSharpSetTypeName || t.Name == FSharpUtils.FSharpMapTypeName)
{ {
return true; return true;
@@ -927,7 +927,7 @@ namespace Newtonsoft.Json.Serialization
private static bool ShouldSkipSerializing(Type t) private static bool ShouldSkipSerializing(Type t)
{ {
#if !(NET35 || NET20) #if HAVE_FSHARP_TYPES
if (t.Name == FSharpUtils.FSharpSetTypeName || t.Name == FSharpUtils.FSharpMapTypeName) if (t.Name == FSharpUtils.FSharpSetTypeName || t.Name == FSharpUtils.FSharpMapTypeName)
{ {
return true; return true;
@@ -1072,7 +1072,7 @@ namespace Newtonsoft.Json.Serialization
return contract; return contract;
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
/// <summary> /// <summary>
/// Creates a <see cref="JsonISerializableContract"/> for the given type. /// Creates a <see cref="JsonISerializableContract"/> for the given type.
/// </summary> /// </summary>
@@ -1095,7 +1095,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
/// <summary> /// <summary>
/// Creates a <see cref="JsonDynamicContract"/> for the given type. /// Creates a <see cref="JsonDynamicContract"/> for the given type.
/// </summary> /// </summary>
@@ -1186,21 +1186,21 @@ namespace Newtonsoft.Json.Serialization
return CreateStringContract(objectType); return CreateStringContract(objectType);
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
if (!IgnoreSerializableInterface && typeof(ISerializable).IsAssignableFrom(t)) if (!IgnoreSerializableInterface && typeof(ISerializable).IsAssignableFrom(t))
{ {
return CreateISerializableContract(objectType); return CreateISerializableContract(objectType);
} }
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t)) if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t))
{ {
return CreateDynamicContract(objectType); return CreateDynamicContract(objectType);
} }
#endif #endif
#if !PORTABLE #if HAVE_ICONVERTIBLE
// tested last because it is not possible to automatically deserialize custom IConvertible types // tested last because it is not possible to automatically deserialize custom IConvertible types
if (IsIConvertible(t)) if (IsIConvertible(t))
{ {
@@ -1218,7 +1218,7 @@ namespace Newtonsoft.Json.Serialization
return (typeCode != PrimitiveTypeCode.Empty && typeCode != PrimitiveTypeCode.Object); return (typeCode != PrimitiveTypeCode.Empty && typeCode != PrimitiveTypeCode.Object);
} }
#if !PORTABLE #if HAVE_ICONVERTIBLE
internal static bool IsIConvertible(Type t) internal static bool IsIConvertible(Type t)
{ {
if (typeof(IConvertible).IsAssignableFrom(t) if (typeof(IConvertible).IsAssignableFrom(t)
@@ -1233,7 +1233,7 @@ namespace Newtonsoft.Json.Serialization
internal static bool CanConvertToString(Type type) internal static bool CanConvertToString(Type type)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
TypeConverter converter = ConvertUtils.GetConverter(type); TypeConverter converter = ConvertUtils.GetConverter(type);
// use the objectType's TypeConverter if it has one and can convert to a string // use the objectType's TypeConverter if it has one and can convert to a string
@@ -1417,7 +1417,7 @@ namespace Newtonsoft.Json.Serialization
private void SetPropertySettingsFromAttributes(JsonProperty property, object attributeProvider, string name, Type declaringType, MemberSerialization memberSerialization, out bool allowNonPublicAccess) private void SetPropertySettingsFromAttributes(JsonProperty property, object attributeProvider, string name, Type declaringType, MemberSerialization memberSerialization, out bool allowNonPublicAccess)
{ {
#if !NET20 #if HAVE_DATA_CONTRACTS
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(declaringType); DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(declaringType);
MemberInfo memberInfo = attributeProvider as MemberInfo; MemberInfo memberInfo = attributeProvider as MemberInfo;
@@ -1443,7 +1443,7 @@ namespace Newtonsoft.Json.Serialization
mappedName = propertyAttribute.PropertyName; mappedName = propertyAttribute.PropertyName;
hasSpecifiedName = true; hasSpecifiedName = true;
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
else if (dataMemberAttribute?.Name != null) else if (dataMemberAttribute?.Name != null)
{ {
mappedName = dataMemberAttribute.Name; mappedName = dataMemberAttribute.Name;
@@ -1512,7 +1512,7 @@ namespace Newtonsoft.Json.Serialization
property.ItemConverter = null; property.ItemConverter = null;
property.ItemReferenceLoopHandling = null; property.ItemReferenceLoopHandling = null;
property.ItemTypeNameHandling = null; property.ItemTypeNameHandling = null;
#if !NET20 #if HAVE_DATA_CONTRACTS
if (dataMemberAttribute != null) if (dataMemberAttribute != null)
{ {
property._required = (dataMemberAttribute.IsRequired) ? Required.AllowNull : Required.Default; property._required = (dataMemberAttribute.IsRequired) ? Required.AllowNull : Required.Default;
@@ -1535,7 +1535,7 @@ namespace Newtonsoft.Json.Serialization
JsonTypeReflector.GetAttribute<JsonIgnoreAttribute>(attributeProvider) != null JsonTypeReflector.GetAttribute<JsonIgnoreAttribute>(attributeProvider) != null
// automatically ignore extension data dictionary property if it is public // automatically ignore extension data dictionary property if it is public
|| JsonTypeReflector.GetAttribute<JsonExtensionDataAttribute>(attributeProvider) != null || JsonTypeReflector.GetAttribute<JsonExtensionDataAttribute>(attributeProvider) != null
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_NON_SERIALIZED_ATTRIBUTE
|| JsonTypeReflector.GetAttribute<NonSerializedAttribute>(attributeProvider) != null || JsonTypeReflector.GetAttribute<NonSerializedAttribute>(attributeProvider) != null
#endif #endif
; ;
@@ -1544,7 +1544,7 @@ namespace Newtonsoft.Json.Serialization
{ {
bool hasIgnoreDataMemberAttribute = false; bool hasIgnoreDataMemberAttribute = false;
#if !(NET20 || NET35) #if HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE
hasIgnoreDataMemberAttribute = (JsonTypeReflector.GetAttribute<IgnoreDataMemberAttribute>(attributeProvider) != null); hasIgnoreDataMemberAttribute = (JsonTypeReflector.GetAttribute<IgnoreDataMemberAttribute>(attributeProvider) != null);
#endif #endif
@@ -70,7 +70,7 @@ namespace Newtonsoft.Json.Serialization
assembly = Assembly.Load(assemblyName); assembly = Assembly.Load(assemblyName);
#endif #endif
#if !(PORTABLE40 || PORTABLE || DOTNET) #if HAVE_APP_DOMAIN
if (assembly == null) if (assembly == null)
{ {
// will find assemblies loaded with Assembly.LoadFile outside of the main directory // will find assemblies loaded with Assembly.LoadFile outside of the main directory
@@ -194,12 +194,12 @@ namespace Newtonsoft.Json.Serialization
/// <param name="assemblyName">Specifies the <see cref="Assembly"/> name of the serialized object.</param> /// <param name="assemblyName">Specifies the <see cref="Assembly"/> name of the serialized object.</param>
/// <param name="typeName">Specifies the <see cref="System.Type"/> name of the serialized object.</param> /// <param name="typeName">Specifies the <see cref="System.Type"/> name of the serialized object.</param>
public public
#if !(NET35 || NET20) #if HAVE_SERIALIZATION_BINDER_BIND_TO_NAME
override override
#endif #endif
void BindToName(Type serializedType, out string assemblyName, out string typeName) void BindToName(Type serializedType, out string assemblyName, out string typeName)
{ {
#if (DOTNET || PORTABLE) #if !HAVE_FULL_REFLECTION
assemblyName = serializedType.GetTypeInfo().Assembly.FullName; assemblyName = serializedType.GetTypeInfo().Assembly.FullName;
typeName = serializedType.FullName; typeName = serializedType.FullName;
#else #else
@@ -1,4 +1,4 @@
#if !(PORTABLE40 || PORTABLE || DOTNET) #if HAVE_TRACE_WRITER
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using DiagnosticsTrace = System.Diagnostics.Trace; using DiagnosticsTrace = System.Diagnostics.Trace;
@@ -23,10 +23,10 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(PORTABLE40 || PORTABLE || DOTNET) #if HAVE_BINARY_SERIALIZATION
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#endif #endif
using System.Text; using System.Text;
@@ -24,9 +24,10 @@
#endregion #endregion
#if !(NET20 || NET35) #if !(NET20 || NET35)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#endif #endif
using System.Text; using System.Text;
@@ -31,7 +31,7 @@ using System.Globalization;
using System.Reflection; using System.Reflection;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Collections; using System.Collections;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -167,7 +167,7 @@ namespace Newtonsoft.Json.Serialization
CreatedType = typeof(List<>).MakeGenericType(CollectionItemType); CreatedType = typeof(List<>).MakeGenericType(CollectionItemType);
} }
#if !(NET20 || NET35) #if HAVE_ISET
if (ReflectionUtils.IsGenericDefinition(underlyingType, typeof(ISet<>))) if (ReflectionUtils.IsGenericDefinition(underlyingType, typeof(ISet<>)))
{ {
CreatedType = typeof(HashSet<>).MakeGenericType(CollectionItemType); CreatedType = typeof(HashSet<>).MakeGenericType(CollectionItemType);
@@ -178,7 +178,7 @@ namespace Newtonsoft.Json.Serialization
canDeserialize = true; canDeserialize = true;
ShouldCreateWrapper = true; ShouldCreateWrapper = true;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyCollection<>), out tempCollectionType)) else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyCollection<>), out tempCollectionType))
{ {
CollectionItemType = tempCollectionType.GetGenericArguments()[0]; CollectionItemType = tempCollectionType.GetGenericArguments()[0];
@@ -206,7 +206,7 @@ namespace Newtonsoft.Json.Serialization
_parameterizedConstructor = CollectionUtils.ResolveEnumerableCollectionConstructor(underlyingType, CollectionItemType); _parameterizedConstructor = CollectionUtils.ResolveEnumerableCollectionConstructor(underlyingType, CollectionItemType);
#if !(NET35 || NET20) #if HAVE_FSHARP_TYPES
if (!HasParameterizedCreatorInternal && underlyingType.Name == FSharpUtils.FSharpListTypeName) if (!HasParameterizedCreatorInternal && underlyingType.Name == FSharpUtils.FSharpListTypeName)
{ {
FSharpUtils.EnsureInitialized(underlyingType.Assembly()); FSharpUtils.EnsureInitialized(underlyingType.Assembly());
@@ -253,7 +253,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !(NET20 || NET35 || NET40) #if HAVE_IMMUTABLE_COLLECTIONS
Type immutableCreatedType; Type immutableCreatedType;
ObjectConstructor<object> immutableParameterizedCreator; ObjectConstructor<object> immutableParameterizedCreator;
if (ImmutableCollectionsUtils.TryBuildImmutableForArrayContract(underlyingType, CollectionItemType, out immutableCreatedType, out immutableParameterizedCreator)) if (ImmutableCollectionsUtils.TryBuildImmutableForArrayContract(underlyingType, CollectionItemType, out immutableCreatedType, out immutableParameterizedCreator))
@@ -28,7 +28,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Collections; using System.Collections;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -30,7 +30,7 @@ using System.Reflection;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Collections; using System.Collections;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#endif #endif
@@ -142,11 +142,11 @@ namespace Newtonsoft.Json.Serialization
CreatedType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType); CreatedType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
IsReadOnlyOrFixedSize = ReflectionUtils.InheritsGenericDefinition(underlyingType, typeof(ReadOnlyDictionary<,>)); IsReadOnlyOrFixedSize = ReflectionUtils.InheritsGenericDefinition(underlyingType, typeof(ReadOnlyDictionary<,>));
#endif #endif
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyDictionary<,>), out _genericCollectionDefinitionType)) else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyDictionary<,>), out _genericCollectionDefinitionType))
{ {
keyType = _genericCollectionDefinitionType.GetGenericArguments()[0]; keyType = _genericCollectionDefinitionType.GetGenericArguments()[0];
@@ -177,7 +177,7 @@ namespace Newtonsoft.Json.Serialization
typeof(KeyValuePair<,>).MakeGenericType(keyType, valueType), typeof(KeyValuePair<,>).MakeGenericType(keyType, valueType),
typeof(IDictionary<,>).MakeGenericType(keyType, valueType)); typeof(IDictionary<,>).MakeGenericType(keyType, valueType));
#if !(NET35 || NET20) #if HAVE_FSHARP_TYPES
if (!HasParameterizedCreatorInternal && underlyingType.Name == FSharpUtils.FSharpMapTypeName) if (!HasParameterizedCreatorInternal && underlyingType.Name == FSharpUtils.FSharpMapTypeName)
{ {
FSharpUtils.EnsureInitialized(underlyingType.Assembly()); FSharpUtils.EnsureInitialized(underlyingType.Assembly());
@@ -205,7 +205,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !(NET20 || NET35 || NET40) #if HAVE_IMMUTABLE_COLLECTIONS
Type immutableCreatedType; Type immutableCreatedType;
ObjectConstructor<object> immutableParameterizedCreator; ObjectConstructor<object> immutableParameterizedCreator;
if (ImmutableCollectionsUtils.TryBuildImmutableForDictionaryContract(underlyingType, DictionaryKeyType, DictionaryValueType, out immutableCreatedType, out immutableParameterizedCreator)) if (ImmutableCollectionsUtils.TryBuildImmutableForDictionaryContract(underlyingType, DictionaryKeyType, DictionaryValueType, out immutableCreatedType, out immutableParameterizedCreator))
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
using System; using System;
using System.Globalization; using System.Globalization;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@@ -214,8 +214,8 @@ namespace Newtonsoft.Json.Serialization
Properties = new JsonPropertyCollection(UnderlyingType); Properties = new JsonPropertyCollection(UnderlyingType);
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
#if !(NET20 || NET35) #if HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE
[SecuritySafeCritical] [SecuritySafeCritical]
#endif #endif
internal object GetUninitializedObject() internal object GetUninitializedObject()
@@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Serialization
[typeof(bool)] = ReadType.ReadAsBoolean, [typeof(bool)] = ReadType.ReadAsBoolean,
[typeof(string)] = ReadType.ReadAsString, [typeof(string)] = ReadType.ReadAsString,
[typeof(DateTime)] = ReadType.ReadAsDateTime, [typeof(DateTime)] = ReadType.ReadAsDateTime,
#if !NET20 #if HAVE_DATE_TIME_OFFSET
[typeof(DateTimeOffset)] = ReadType.ReadAsDateTimeOffset, [typeof(DateTimeOffset)] = ReadType.ReadAsDateTimeOffset,
#endif #endif
[typeof(float)] = ReadType.ReadAsDouble, [typeof(float)] = ReadType.ReadAsDouble,
@@ -27,7 +27,7 @@ using System;
using System.Reflection; using System.Reflection;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#endif #endif
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -27,20 +27,20 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System.ComponentModel; using System.ComponentModel;
using System.Dynamic; using System.Dynamic;
#endif #endif
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
#if !(PORTABLE || PORTABLE40 || NET35 || NET20) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -319,7 +319,7 @@ namespace Newtonsoft.Json.Serialization
return EnsureType(reader, constructorName, CultureInfo.InvariantCulture, contract, objectType); return EnsureType(reader, constructorName, CultureInfo.InvariantCulture, contract, objectType);
case JsonToken.Null: case JsonToken.Null:
case JsonToken.Undefined: case JsonToken.Undefined:
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
if (objectType == typeof(DBNull)) if (objectType == typeof(DBNull))
{ {
return DBNull.Value; return DBNull.Value;
@@ -351,10 +351,10 @@ namespace Newtonsoft.Json.Serialization
{ {
case JsonContractType.Object: case JsonContractType.Object:
case JsonContractType.Dictionary: case JsonContractType.Dictionary:
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_BINARY_SERIALIZATION
case JsonContractType.Serializable: case JsonContractType.Serializable:
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
case JsonContractType.Dynamic: case JsonContractType.Dynamic:
#endif #endif
return @"JSON object (e.g. {""name"":""value""})"; return @"JSON object (e.g. {""name"":""value""})";
@@ -563,12 +563,12 @@ namespace Newtonsoft.Json.Serialization
return targetDictionary; return targetDictionary;
} }
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
case JsonContractType.Dynamic: case JsonContractType.Dynamic:
JsonDynamicContract dynamicContract = (JsonDynamicContract)contract; JsonDynamicContract dynamicContract = (JsonDynamicContract)contract;
return CreateDynamic(reader, dynamicContract, member, id); return CreateDynamic(reader, dynamicContract, member, id);
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
case JsonContractType.Serializable: case JsonContractType.Serializable:
JsonISerializableContract serializableContract = (JsonISerializableContract)contract; JsonISerializableContract serializableContract = (JsonISerializableContract)contract;
return CreateISerializable(reader, serializableContract, member, id); return CreateISerializable(reader, serializableContract, member, id);
@@ -801,7 +801,7 @@ namespace Newtonsoft.Json.Serialization
} }
if (objectType != null if (objectType != null
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
&& objectType != typeof(IDynamicMetaObjectProvider) && objectType != typeof(IDynamicMetaObjectProvider)
#endif #endif
&& !objectType.IsAssignableFrom(specifiedType)) && !objectType.IsAssignableFrom(specifiedType))
@@ -924,7 +924,7 @@ namespace Newtonsoft.Json.Serialization
private bool HasNoDefinedType(JsonContract contract) private bool HasNoDefinedType(JsonContract contract)
{ {
return (contract == null || contract.UnderlyingType == typeof(object) || contract.ContractType == JsonContractType.Linq return (contract == null || contract.UnderlyingType == typeof(object) || contract.ContractType == JsonContractType.Linq
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
|| contract.UnderlyingType == typeof(IDynamicMetaObjectProvider) || contract.UnderlyingType == typeof(IDynamicMetaObjectProvider)
#endif #endif
); );
@@ -966,7 +966,7 @@ namespace Newtonsoft.Json.Serialization
} }
} }
#if !(PORTABLE || PORTABLE40 || NET35 || NET20) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
return ConvertUtils.FromBigInteger((BigInteger)value, contract.NonNullableUnderlyingType); return ConvertUtils.FromBigInteger((BigInteger)value, contract.NonNullableUnderlyingType);
@@ -1356,7 +1356,7 @@ namespace Newtonsoft.Json.Serialization
} }
break; break;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffset: case PrimitiveTypeCode.DateTimeOffset:
case PrimitiveTypeCode.DateTimeOffsetNullable: case PrimitiveTypeCode.DateTimeOffsetNullable:
{ {
@@ -1676,7 +1676,7 @@ namespace Newtonsoft.Json.Serialization
return underlyingList; return underlyingList;
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
private object CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty member, string id) private object CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty member, string id)
{ {
Type objectType = contract.UnderlyingType; Type objectType = contract.UnderlyingType;
@@ -1766,7 +1766,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, JsonProperty member, string id) private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, JsonProperty member, string id)
{ {
IDynamicMetaObjectProvider newObject; IDynamicMetaObjectProvider newObject;
@@ -1900,7 +1900,7 @@ namespace Newtonsoft.Json.Serialization
if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info) if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)
{ {
string parameters = string.Join(", ", contract.CreatorParameters.Select(p => p.PropertyName) string parameters = string.Join(", ", contract.CreatorParameters.Select(p => p.PropertyName)
#if NET20 || NET35 #if !HAVE_STRING_JOIN_WITH_ENUMERABLE
.ToArray() .ToArray()
#endif #endif
); );
@@ -2250,7 +2250,7 @@ namespace Newtonsoft.Json.Serialization
case ReadType.ReadAsDateTime: case ReadType.ReadAsDateTime:
reader.ReadAsDateTime(); reader.ReadAsDateTime();
break; break;
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case ReadType.ReadAsDateTimeOffset: case ReadType.ReadAsDateTimeOffset:
reader.ReadAsDateTimeOffset(); reader.ReadAsDateTimeOffset();
break; break;
@@ -27,7 +27,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System.Dynamic; using System.Dynamic;
#endif #endif
using System.Diagnostics; using System.Diagnostics;
@@ -37,7 +37,7 @@ using System.Security;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -193,12 +193,12 @@ namespace Newtonsoft.Json.Serialization
JsonDictionaryContract dictionaryContract = (JsonDictionaryContract)valueContract; JsonDictionaryContract dictionaryContract = (JsonDictionaryContract)valueContract;
SerializeDictionary(writer, (value is IDictionary) ? (IDictionary)value : dictionaryContract.CreateWrapper(value), dictionaryContract, member, containerContract, containerProperty); SerializeDictionary(writer, (value is IDictionary) ? (IDictionary)value : dictionaryContract.CreateWrapper(value), dictionaryContract, member, containerContract, containerProperty);
break; break;
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
case JsonContractType.Dynamic: case JsonContractType.Dynamic:
SerializeDynamic(writer, (IDynamicMetaObjectProvider)value, (JsonDynamicContract)valueContract, member, containerContract, containerProperty); SerializeDynamic(writer, (IDynamicMetaObjectProvider)value, (JsonDynamicContract)valueContract, member, containerContract, containerProperty);
break; break;
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
case JsonContractType.Serializable: case JsonContractType.Serializable:
SerializeISerializable(writer, (ISerializable)value, (JsonISerializableContract)valueContract, member, containerContract, containerProperty); SerializeISerializable(writer, (ISerializable)value, (JsonISerializableContract)valueContract, member, containerContract, containerProperty);
break; break;
@@ -379,7 +379,7 @@ namespace Newtonsoft.Json.Serialization
internal static bool TryConvertToString(object value, Type type, out string s) internal static bool TryConvertToString(object value, Type type, out string s)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
TypeConverter converter = ConvertUtils.GetConverter(type); TypeConverter converter = ConvertUtils.GetConverter(type);
// use the objectType's TypeConverter if it has one and can convert to a string // use the objectType's TypeConverter if it has one and can convert to a string
@@ -846,8 +846,8 @@ namespace Newtonsoft.Json.Serialization
return writeMetadataObject; return writeMetadataObject;
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
#if !(NET20 || NET35) #if HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE
[SecuritySafeCritical] [SecuritySafeCritical]
#endif #endif
private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
@@ -892,7 +892,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
{ {
OnSerializing(writer, contract, value); OnSerializing(writer, contract, value);
@@ -1144,9 +1144,9 @@ namespace Newtonsoft.Json.Serialization
DateTimeUtils.WriteDateTimeString(sw, dt, writer.DateFormatHandling, writer.DateFormatString, writer.Culture); DateTimeUtils.WriteDateTimeString(sw, dt, writer.DateFormatHandling, writer.DateFormatString, writer.Culture);
return sw.ToString(); return sw.ToString();
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffset: case PrimitiveTypeCode.DateTimeOffset:
case PrimitiveTypeCode.DateTimeOffsetNullable: case PrimitiveTypeCode.DateTimeOffsetNullable:
{ {
escape = false; escape = false;
StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
@@ -29,11 +29,11 @@ using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Security; using System.Security;
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_CAS
using System.Security.Permissions; using System.Security.Permissions;
#endif #endif
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -69,7 +69,7 @@ namespace Newtonsoft.Json.Serialization
return CachedAttributeGetter<T>.GetAttribute(attributeProvider); return CachedAttributeGetter<T>.GetAttribute(attributeProvider);
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
public static DataContractAttribute GetDataContractAttribute(Type type) public static DataContractAttribute GetDataContractAttribute(Type type)
{ {
// DataContractAttribute does not have inheritance // DataContractAttribute does not have inheritance
@@ -133,7 +133,7 @@ namespace Newtonsoft.Json.Serialization
return objectAttribute.MemberSerialization; return objectAttribute.MemberSerialization;
} }
#if !NET20 #if HAVE_DATA_CONTRACTS
DataContractAttribute dataContractAttribute = GetDataContractAttribute(objectType); DataContractAttribute dataContractAttribute = GetDataContractAttribute(objectType);
if (dataContractAttribute != null) if (dataContractAttribute != null)
{ {
@@ -141,7 +141,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_BINARY_SERIALIZATION
if (!ignoreSerializableAttribute) if (!ignoreSerializableAttribute)
{ {
SerializableAttribute serializableAttribute = GetCachedAttribute<SerializableAttribute>(objectType); SerializableAttribute serializableAttribute = GetCachedAttribute<SerializableAttribute>(objectType);
@@ -245,7 +245,7 @@ namespace Newtonsoft.Json.Serialization
}; };
} }
#if !(PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
public static TypeConverter GetTypeConverter(Type type) public static TypeConverter GetTypeConverter(Type type)
{ {
return TypeDescriptor.GetConverter(type); return TypeDescriptor.GetConverter(type);
@@ -397,14 +397,14 @@ namespace Newtonsoft.Json.Serialization
public static bool DynamicCodeGeneration public static bool DynamicCodeGeneration
{ {
#if !(NET20 || NET35 || PORTABLE) #if HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE
[SecuritySafeCritical] [SecuritySafeCritical]
#endif #endif
get get
{ {
if (_dynamicCodeGeneration == null) if (_dynamicCodeGeneration == null)
{ {
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_CAS
try try
{ {
new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand(); new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand();
@@ -44,7 +44,7 @@ namespace Newtonsoft.Json.Serialization
public void BindToName(Type serializedType, out string assemblyName, out string typeName) public void BindToName(Type serializedType, out string assemblyName, out string typeName)
{ {
#if !(NET35 || NET20) #if HAVE_SERIALIZATION_BINDER_BIND_TO_NAME
SerializationBinder.BindToName(serializedType, out assemblyName, out typeName); SerializationBinder.BindToName(serializedType, out assemblyName, out typeName);
#else #else
assemblyName = null; assemblyName = null;
@@ -85,7 +85,7 @@ namespace Newtonsoft.Json.Serialization
return value; return value;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
public override DateTimeOffset? ReadAsDateTimeOffset() public override DateTimeOffset? ReadAsDateTimeOffset()
{ {
DateTimeOffset? value = _innerReader.ReadAsDateTimeOffset(); DateTimeOffset? value = _innerReader.ReadAsDateTimeOffset();
@@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Text; using System.Text;
@@ -156,7 +156,7 @@ namespace Newtonsoft.Json.Serialization
} }
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
public override void WriteValue(DateTimeOffset value) public override void WriteValue(DateTimeOffset value)
{ {
_textWriter.WriteValue(value); _textWriter.WriteValue(value);
@@ -177,7 +177,6 @@ namespace Newtonsoft.Json.Serialization
base.WriteUndefined(); base.WriteUndefined();
} }
} }
#endif #endif
public override void WriteValue(double value) public override void WriteValue(double value)
@@ -301,7 +300,7 @@ namespace Newtonsoft.Json.Serialization
public override void WriteValue(object value) public override void WriteValue(object value)
{ {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (value is BigInteger) if (value is BigInteger)
{ {
_textWriter.WriteValue(value); _textWriter.WriteValue(value);
+1 -1
View File
@@ -1,5 +1,5 @@
 
#if (DOTNET || PORTABLE40 || PORTABLE) #if !HAVE_TRACE_WRITER
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
namespace Newtonsoft.Json namespace Newtonsoft.Json
+1 -1
View File
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -25,7 +25,7 @@
using System; using System;
using System.IO; using System.IO;
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
#endif #endif
@@ -156,7 +156,7 @@ namespace Newtonsoft.Json.Utilities
_writer.Write(chars, index, count); _writer.Write(chars, index, count);
} }
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_ASYNC
public async Task EncodeAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken) public async Task EncodeAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken)
{ {
@@ -30,13 +30,13 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Collections; using System.Collections;
using System.Diagnostics; using System.Diagnostics;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
using System.Globalization; using System.Globalization;
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_METHOD_IMPL_ATTRIBUTE
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
#endif #endif
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@@ -84,7 +84,7 @@ namespace Newtonsoft.Json.Utilities
} }
} }
#if (NET20 || NET35 || PORTABLE40) #if !HAVE_COVARIANT_GENERICS
public static void AddRange<T>(this IList<T> initial, IEnumerable collection) public static void AddRange<T>(this IList<T> initial, IEnumerable collection)
{ {
ValidationUtils.ArgumentNotNull(initial, nameof(initial)); ValidationUtils.ArgumentNotNull(initial, nameof(initial));
@@ -106,7 +106,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return true; return true;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
if (ReflectionUtils.ImplementsGenericDefinition(type, typeof(IReadOnlyDictionary<,>))) if (ReflectionUtils.ImplementsGenericDefinition(type, typeof(IReadOnlyDictionary<,>)))
{ {
return true; return true;
@@ -357,7 +357,7 @@ namespace Newtonsoft.Json.Utilities
// pretty much guaranteed to be inlined, giving us fast access of that cached // pretty much guaranteed to be inlined, giving us fast access of that cached
// array. With 4.5 and up we use AggressiveInlining just to be sure, so it's // array. With 4.5 and up we use AggressiveInlining just to be sure, so it's
// effectively the same as calling Array.Empty<T> even when not available. // effectively the same as calling Array.Empty<T> even when not available.
#if !(NET20 || NET35 || NET40 || PORTABLE40) #if HAVE_METHOD_IMPL_ATTRIBUTE
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif #endif
public static T[] ArrayEmpty<T>() public static T[] ArrayEmpty<T>()
@@ -28,7 +28,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Globalization; using System.Globalization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
+21 -21
View File
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -27,17 +27,17 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.ComponentModel; using System.ComponentModel;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
using System.Numerics; using System.Numerics;
#endif #endif
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System.Reflection; using System.Reflection;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
using System.Data.SqlTypes; using System.Data.SqlTypes;
#endif #endif
@@ -135,7 +135,7 @@ namespace Newtonsoft.Json.Utilities
{ typeof(double?), PrimitiveTypeCode.DoubleNullable }, { typeof(double?), PrimitiveTypeCode.DoubleNullable },
{ typeof(DateTime), PrimitiveTypeCode.DateTime }, { typeof(DateTime), PrimitiveTypeCode.DateTime },
{ typeof(DateTime?), PrimitiveTypeCode.DateTimeNullable }, { typeof(DateTime?), PrimitiveTypeCode.DateTimeNullable },
#if !NET20 #if HAVE_DATE_TIME_OFFSET
{ typeof(DateTimeOffset), PrimitiveTypeCode.DateTimeOffset }, { typeof(DateTimeOffset), PrimitiveTypeCode.DateTimeOffset },
{ typeof(DateTimeOffset?), PrimitiveTypeCode.DateTimeOffsetNullable }, { typeof(DateTimeOffset?), PrimitiveTypeCode.DateTimeOffsetNullable },
#endif #endif
@@ -145,19 +145,19 @@ namespace Newtonsoft.Json.Utilities
{ typeof(Guid?), PrimitiveTypeCode.GuidNullable }, { typeof(Guid?), PrimitiveTypeCode.GuidNullable },
{ typeof(TimeSpan), PrimitiveTypeCode.TimeSpan }, { typeof(TimeSpan), PrimitiveTypeCode.TimeSpan },
{ typeof(TimeSpan?), PrimitiveTypeCode.TimeSpanNullable }, { typeof(TimeSpan?), PrimitiveTypeCode.TimeSpanNullable },
#if !(PORTABLE || PORTABLE40 || NET35 || NET20) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
{ typeof(BigInteger), PrimitiveTypeCode.BigInteger }, { typeof(BigInteger), PrimitiveTypeCode.BigInteger },
{ typeof(BigInteger?), PrimitiveTypeCode.BigIntegerNullable }, { typeof(BigInteger?), PrimitiveTypeCode.BigIntegerNullable },
#endif #endif
{ typeof(Uri), PrimitiveTypeCode.Uri }, { typeof(Uri), PrimitiveTypeCode.Uri },
{ typeof(string), PrimitiveTypeCode.String }, { typeof(string), PrimitiveTypeCode.String },
{ typeof(byte[]), PrimitiveTypeCode.Bytes }, { typeof(byte[]), PrimitiveTypeCode.Bytes },
#if !(PORTABLE || PORTABLE40 || DOTNET) #if HAVE_ADO_NET
{ typeof(DBNull), PrimitiveTypeCode.DBNull } { typeof(DBNull), PrimitiveTypeCode.DBNull }
#endif #endif
}; };
#if !PORTABLE #if HAVE_ICONVERTIBLE
private static readonly TypeInformation[] PrimitiveTypeCodes = private static readonly TypeInformation[] PrimitiveTypeCodes =
{ {
// need all of these. lookup against the index with TypeCode value // need all of these. lookup against the index with TypeCode value
@@ -220,7 +220,7 @@ namespace Newtonsoft.Json.Utilities
return PrimitiveTypeCode.Object; return PrimitiveTypeCode.Object;
} }
#if !PORTABLE #if HAVE_ICONVERTIBLE
public static TypeInformation GetTypeInformation(IConvertible convertable) public static TypeInformation GetTypeInformation(IConvertible convertable)
{ {
TypeInformation typeInformation = PrimitiveTypeCodes[(int)convertable.GetTypeCode()]; TypeInformation typeInformation = PrimitiveTypeCodes[(int)convertable.GetTypeCode()];
@@ -230,7 +230,7 @@ namespace Newtonsoft.Json.Utilities
public static bool IsConvertible(Type t) public static bool IsConvertible(Type t)
{ {
#if !PORTABLE #if HAVE_ICONVERTIBLE
return typeof(IConvertible).IsAssignableFrom(t); return typeof(IConvertible).IsAssignableFrom(t);
#else #else
return ( return (
@@ -241,7 +241,7 @@ namespace Newtonsoft.Json.Utilities
public static TimeSpan ParseTimeSpan(string input) public static TimeSpan ParseTimeSpan(string input)
{ {
#if !(NET35 || NET20) #if HAVE_TIME_SPAN_PARSE_WITH_CULTURE
return TimeSpan.Parse(input, CultureInfo.InvariantCulture); return TimeSpan.Parse(input, CultureInfo.InvariantCulture);
#else #else
return TimeSpan.Parse(input); return TimeSpan.Parse(input);
@@ -311,7 +311,7 @@ namespace Newtonsoft.Json.Utilities
return o => call(null, o); return o => call(null, o);
} }
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
internal static BigInteger ToBigInteger(object value) internal static BigInteger ToBigInteger(object value)
{ {
if (value is BigInteger) if (value is BigInteger)
@@ -484,7 +484,7 @@ namespace Newtonsoft.Json.Utilities
return ConvertResult.Success; return ConvertResult.Success;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
if (initialValue is DateTime && targetType == typeof(DateTimeOffset)) if (initialValue is DateTime && targetType == typeof(DateTimeOffset))
{ {
value = new DateTimeOffset((DateTime)initialValue); value = new DateTimeOffset((DateTime)initialValue);
@@ -546,7 +546,7 @@ namespace Newtonsoft.Json.Utilities
} }
} }
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1 #if HAVE_BIG_INTEGER
if (targetType == typeof(BigInteger)) if (targetType == typeof(BigInteger))
{ {
value = ToBigInteger(initialValue); value = ToBigInteger(initialValue);
@@ -559,7 +559,7 @@ namespace Newtonsoft.Json.Utilities
} }
#endif #endif
#if !(PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
// see if source or target types have a TypeConverter that converts between the two // see if source or target types have a TypeConverter that converts between the two
TypeConverter toConverter = GetConverter(initialType); TypeConverter toConverter = GetConverter(initialType);
@@ -577,7 +577,7 @@ namespace Newtonsoft.Json.Utilities
return ConvertResult.Success; return ConvertResult.Success;
} }
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
// handle DBNull and INullable // handle DBNull and INullable
if (initialValue == DBNull.Value) if (initialValue == DBNull.Value)
{ {
@@ -592,7 +592,7 @@ namespace Newtonsoft.Json.Utilities
return ConvertResult.CannotConvertNull; return ConvertResult.CannotConvertNull;
} }
#endif #endif
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
INullable nullable = initialValue as INullable; INullable nullable = initialValue as INullable;
if (nullable != null) if (nullable != null)
{ {
@@ -675,7 +675,7 @@ namespace Newtonsoft.Json.Utilities
throw new ArgumentException("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType?.ToString() ?? "{null}", targetType)); throw new ArgumentException("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType?.ToString() ?? "{null}", targetType));
} }
#if !(DOTNET || PORTABLE40 || PORTABLE) #if HAVE_ADO_NET
public static object ToValue(INullable nullableValue) public static object ToValue(INullable nullableValue)
{ {
if (nullableValue == null) if (nullableValue == null)
@@ -707,7 +707,7 @@ namespace Newtonsoft.Json.Utilities
} }
#endif #endif
#if !(PORTABLE40 || PORTABLE) #if HAVE_COMPONENT_MODEL
internal static TypeConverter GetConverter(Type t) internal static TypeConverter GetConverter(Type t)
{ {
return JsonTypeReflector.GetTypeConverter(t); return JsonTypeReflector.GetTypeConverter(t);
@@ -716,7 +716,7 @@ namespace Newtonsoft.Json.Utilities
public static bool VersionTryParse(string input, out Version result) public static bool VersionTryParse(string input, out Version result)
{ {
#if !(NET20 || NET35) #if HAVE_VERSION_TRY_PARSE
return Version.TryParse(input, out result); return Version.TryParse(input, out result);
#else #else
// improve failure performance with regex? // improve failure performance with regex?
@@ -1367,7 +1367,7 @@ namespace Newtonsoft.Json.Utilities
public static bool TryConvertGuid(string s, out Guid g) public static bool TryConvertGuid(string s, out Guid g)
{ {
// GUID has to have format 00000000-0000-0000-0000-000000000000 // GUID has to have format 00000000-0000-0000-0000-000000000000
#if NET20 || NET35 #if !HAVE_GUID_TRY_PARSE
if (s == null) if (s == null)
{ {
throw new ArgumentNullException("s"); throw new ArgumentNullException("s");
@@ -51,7 +51,7 @@ namespace Newtonsoft.Json.Utilities
public static TimeSpan GetUtcOffset(this DateTime d) public static TimeSpan GetUtcOffset(this DateTime d)
{ {
#if NET20 #if !HAVE_TIME_ZONE_INFO
return TimeZone.CurrentTimeZone.GetUtcOffset(d); return TimeZone.CurrentTimeZone.GetUtcOffset(d);
#else #else
return TimeZoneInfo.Local.GetUtcOffset(d); return TimeZoneInfo.Local.GetUtcOffset(d);
@@ -276,7 +276,7 @@ namespace Newtonsoft.Json.Utilities
return true; return true;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
internal static bool TryParseDateTimeOffsetIso(StringReference text, out DateTimeOffset dt) internal static bool TryParseDateTimeOffsetIso(StringReference text, out DateTimeOffset dt)
{ {
DateTimeParser dateTimeParser = new DateTimeParser(); DateTimeParser dateTimeParser = new DateTimeParser();
@@ -413,7 +413,7 @@ namespace Newtonsoft.Json.Utilities
return false; return false;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
internal static bool TryParseDateTimeOffset(StringReference s, string dateFormatString, CultureInfo culture, out DateTimeOffset dt) internal static bool TryParseDateTimeOffset(StringReference s, string dateFormatString, CultureInfo culture, out DateTimeOffset dt)
{ {
if (s.Length > 0) if (s.Length > 0)
@@ -564,7 +564,7 @@ namespace Newtonsoft.Json.Utilities
return false; return false;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
private static bool TryParseDateTimeOffsetMicrosoft(StringReference text, out DateTimeOffset dt) private static bool TryParseDateTimeOffsetMicrosoft(StringReference text, out DateTimeOffset dt)
{ {
long ticks; long ticks;
@@ -764,7 +764,7 @@ namespace Newtonsoft.Json.Utilities
return start; return start;
} }
#if !NET20 #if HAVE_DATE_TIME_OFFSET
internal static void WriteDateTimeOffsetString(TextWriter writer, DateTimeOffset value, DateFormatHandling format, string formatString, CultureInfo culture) internal static void WriteDateTimeOffsetString(TextWriter writer, DateTimeOffset value, DateFormatHandling format, string formatString, CultureInfo culture)
{ {
if (string.IsNullOrEmpty(formatString)) if (string.IsNullOrEmpty(formatString))
@@ -27,7 +27,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Threading; using System.Threading;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -46,7 +46,7 @@ namespace Newtonsoft.Json.Utilities
{ {
private readonly IDictionary _dictionary; private readonly IDictionary _dictionary;
private readonly IDictionary<TKey, TValue> _genericDictionary; private readonly IDictionary<TKey, TValue> _genericDictionary;
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
private readonly IReadOnlyDictionary<TKey, TValue> _readOnlyDictionary; private readonly IReadOnlyDictionary<TKey, TValue> _readOnlyDictionary;
#endif #endif
private object _syncRoot; private object _syncRoot;
@@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Utilities
_genericDictionary = dictionary; _genericDictionary = dictionary;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
public DictionaryWrapper(IReadOnlyDictionary<TKey, TValue> dictionary) public DictionaryWrapper(IReadOnlyDictionary<TKey, TValue> dictionary)
{ {
ValidationUtils.ArgumentNotNull(dictionary, nameof(dictionary)); ValidationUtils.ArgumentNotNull(dictionary, nameof(dictionary));
@@ -96,7 +96,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.Contains(key); return _dictionary.Contains(key);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.ContainsKey(key); return _readOnlyDictionary.ContainsKey(key);
@@ -116,7 +116,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.Keys.Cast<TKey>().ToList(); return _dictionary.Keys.Cast<TKey>().ToList();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.Keys.ToList(); return _readOnlyDictionary.Keys.ToList();
@@ -143,7 +143,7 @@ namespace Newtonsoft.Json.Utilities
return false; return false;
} }
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -170,7 +170,7 @@ namespace Newtonsoft.Json.Utilities
return true; return true;
} }
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -190,7 +190,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.Values.Cast<TValue>().ToList(); return _dictionary.Values.Cast<TValue>().ToList();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.Values.ToList(); return _readOnlyDictionary.Values.ToList();
@@ -211,7 +211,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return (TValue)_dictionary[key]; return (TValue)_dictionary[key];
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary[key]; return _readOnlyDictionary[key];
@@ -228,7 +228,7 @@ namespace Newtonsoft.Json.Utilities
{ {
_dictionary[key] = value; _dictionary[key] = value;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -247,7 +247,7 @@ namespace Newtonsoft.Json.Utilities
{ {
((IList)_dictionary).Add(item); ((IList)_dictionary).Add(item);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -265,7 +265,7 @@ namespace Newtonsoft.Json.Utilities
{ {
_dictionary.Clear(); _dictionary.Clear();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -283,7 +283,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return ((IList)_dictionary).Contains(item); return ((IList)_dictionary).Contains(item);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.Contains(item); return _readOnlyDictionary.Contains(item);
@@ -314,7 +314,7 @@ namespace Newtonsoft.Json.Utilities
(e as IDisposable)?.Dispose(); (e as IDisposable)?.Dispose();
} }
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -334,7 +334,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.Count; return _dictionary.Count;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.Count; return _readOnlyDictionary.Count;
@@ -355,7 +355,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.IsReadOnly; return _dictionary.IsReadOnly;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return true; return true;
@@ -391,7 +391,7 @@ namespace Newtonsoft.Json.Utilities
return true; return true;
} }
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -409,7 +409,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator(); return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.GetEnumerator(); return _readOnlyDictionary.GetEnumerator();
@@ -432,7 +432,7 @@ namespace Newtonsoft.Json.Utilities
{ {
_dictionary.Add(key, value); _dictionary.Add(key, value);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -452,7 +452,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary[key]; return _dictionary[key];
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary[(TKey)key]; return _readOnlyDictionary[(TKey)key];
@@ -469,7 +469,7 @@ namespace Newtonsoft.Json.Utilities
{ {
_dictionary[key] = value; _dictionary[key] = value;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -529,7 +529,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary.GetEnumerator(); return _dictionary.GetEnumerator();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return new DictionaryEnumerator<TKey, TValue>(_readOnlyDictionary.GetEnumerator()); return new DictionaryEnumerator<TKey, TValue>(_readOnlyDictionary.GetEnumerator());
@@ -547,7 +547,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _genericDictionary.ContainsKey((TKey)key); return _genericDictionary.ContainsKey((TKey)key);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.ContainsKey((TKey)key); return _readOnlyDictionary.ContainsKey((TKey)key);
@@ -567,7 +567,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return false; return false;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return true; return true;
@@ -588,7 +588,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _genericDictionary.Keys.ToList(); return _genericDictionary.Keys.ToList();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.Keys.ToList(); return _readOnlyDictionary.Keys.ToList();
@@ -607,7 +607,7 @@ namespace Newtonsoft.Json.Utilities
{ {
_dictionary.Remove(key); _dictionary.Remove(key);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -627,7 +627,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _genericDictionary.Values.ToList(); return _genericDictionary.Values.ToList();
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary.Values.ToList(); return _readOnlyDictionary.Values.ToList();
@@ -646,7 +646,7 @@ namespace Newtonsoft.Json.Utilities
{ {
_dictionary.CopyTo(array, index); _dictionary.CopyTo(array, index);
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
@@ -694,7 +694,7 @@ namespace Newtonsoft.Json.Utilities
{ {
return _dictionary; return _dictionary;
} }
#if !(NET40 || NET35 || NET20 || PORTABLE40) #if HAVE_READ_ONLY_COLLECTIONS
else if (_readOnlyDictionary != null) else if (_readOnlyDictionary != null)
{ {
return _readOnlyDictionary; return _readOnlyDictionary;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
@@ -23,10 +23,10 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(DOTNET || PORTABLE || PORTABLE40) #if HAVE_REFLECTION_EMIT
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#endif #endif
using System.Reflection; using System.Reflection;
@@ -23,13 +23,13 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(NET35 || NET20 || PORTABLE40) #if HAVE_DYNAMIC
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
#if !(PORTABLE) #if !HAVE_REFLECTION_BINDER
using System.Reflection; using System.Reflection;
#else #else
using Microsoft.CSharp.RuntimeBinder; using Microsoft.CSharp.RuntimeBinder;
@@ -45,7 +45,7 @@ namespace Newtonsoft.Json.Utilities
{ {
internal static class BinderWrapper internal static class BinderWrapper
{ {
#if !(PORTABLE) #if !HAVE_REFLECTION_BINDER
public const string CSharpAssemblyName = "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; public const string CSharpAssemblyName = "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
private const string BinderTypeName = "Microsoft.CSharp.RuntimeBinder.Binder, " + CSharpAssemblyName; private const string BinderTypeName = "Microsoft.CSharp.RuntimeBinder.Binder, " + CSharpAssemblyName;
@@ -114,7 +114,7 @@ namespace Newtonsoft.Json.Utilities
public static CallSiteBinder GetMember(string name, Type context) public static CallSiteBinder GetMember(string name, Type context)
{ {
#if !(PORTABLE) #if !HAVE_REFLECTION_BINDER
Init(); Init();
return (CallSiteBinder)_getMemberCall(null, 0, name, context, _getCSharpArgumentInfoArray); return (CallSiteBinder)_getMemberCall(null, 0, name, context, _getCSharpArgumentInfoArray);
#else #else
@@ -125,7 +125,7 @@ namespace Newtonsoft.Json.Utilities
public static CallSiteBinder SetMember(string name, Type context) public static CallSiteBinder SetMember(string name, Type context)
{ {
#if !(PORTABLE) #if !HAVE_REFLECTION_BINDER
Init(); Init();
return (CallSiteBinder)_setMemberCall(null, 0, name, context, _setCSharpArgumentInfoArray); return (CallSiteBinder)_setMemberCall(null, 0, name, context, _setCSharpArgumentInfoArray);
#else #else
+2 -2
View File
@@ -27,7 +27,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#if NET20 #if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
@@ -51,7 +51,7 @@ namespace Newtonsoft.Json.Utilities
string n1 = f.Name; string n1 = f.Name;
string n2; string n2;
#if !NET20 #if HAVE_DATA_CONTRACTS
n2 = f.GetCustomAttributes(typeof(EnumMemberAttribute), true) n2 = f.GetCustomAttributes(typeof(EnumMemberAttribute), true)
.Cast<EnumMemberAttribute>() .Cast<EnumMemberAttribute>()
.Select(a => a.Value) .Select(a => a.Value)

Some files were not shown because too many files have changed in this diff Show More