Update to net50 and fix warnings (#2424)
This commit is contained in:
+10
-4
@@ -14,8 +14,9 @@
|
||||
$workingName = if ($workingName) {$workingName} else {"Working"}
|
||||
$assemblyVersion = if ($assemblyVersion) {$assemblyVersion} else {$majorVersion + '.0.0'}
|
||||
$netCliChannel = "Current"
|
||||
$netCliVersion = "3.0.100"
|
||||
$netCliVersion = "5.0.100"
|
||||
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||
$ensureNetCliSdk = $true
|
||||
|
||||
$baseDir = resolve-path ..
|
||||
$buildDir = "$baseDir\Build"
|
||||
@@ -31,8 +32,8 @@
|
||||
$nunitConsolePath = "$buildDir\Temp\NUnit.ConsoleRunner.$nunitConsoleVersion"
|
||||
|
||||
$builds = @(
|
||||
@{Framework = "netstandard2.0"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp3.0"; Enabled=$true},
|
||||
@{Framework = "netstandard1.3"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp2.2"; Enabled=$true},
|
||||
@{Framework = "netstandard2.0"; TestsFunction = "NetCliTests"; TestFramework = "net5.0"; Enabled=$true},
|
||||
@{Framework = "netstandard1.3"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp3.1"; Enabled=$true},
|
||||
@{Framework = "netstandard1.0"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp2.1"; Enabled=$true},
|
||||
@{Framework = "net45"; TestsFunction = "NUnitTests"; TestFramework = "net46"; NUnitFramework="net-4.0"; Enabled=$true},
|
||||
@{Framework = "net40"; TestsFunction = "NUnitTests"; NUnitFramework="net-4.0"; Enabled=$true},
|
||||
@@ -69,7 +70,10 @@ task Build -depends Clean {
|
||||
|
||||
mkdir "$buildDir\Temp" -Force
|
||||
|
||||
EnsureDotNetCli
|
||||
if ($ensureNetCliSdk)
|
||||
{
|
||||
EnsureDotNetCli
|
||||
}
|
||||
EnsureNuGetExists
|
||||
EnsureNuGetPackage "vswhere" $vswherePath $vswhereVersion
|
||||
EnsureNuGetPackage "NUnit.ConsoleRunner" $nunitConsolePath $nunitConsoleVersion
|
||||
@@ -170,6 +174,8 @@ function EnsureDotnetCli()
|
||||
-OutFile "$buildDir\Temp\dotnet-install.ps1"
|
||||
|
||||
exec { & $buildDir\Temp\dotnet-install.ps1 -Channel $netCliChannel -Version $netCliVersion | Out-Default }
|
||||
exec { & $buildDir\Temp\dotnet-install.ps1 -Channel $netCliChannel -Version '3.1.402' | Out-Default }
|
||||
exec { & $buildDir\Temp\dotnet-install.ps1 -Channel $netCliChannel -Version '2.1.811' | Out-Default }
|
||||
}
|
||||
|
||||
function EnsureNuGetExists()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<MicrosoftCodeAnalysisFxCopAnalyzersPackageVersion>2.9.2</MicrosoftCodeAnalysisFxCopAnalyzersPackageVersion>
|
||||
<MicrosoftCSharpPackageVersion>4.3.0</MicrosoftCSharpPackageVersion>
|
||||
<MicrosoftSourceLinkGitHubPackageVersion>1.0.0-beta2-19367-01</MicrosoftSourceLinkGitHubPackageVersion>
|
||||
<MicrosoftNetCompilersToolsetPackageVersion>3.3.1</MicrosoftNetCompilersToolsetPackageVersion>
|
||||
<MicrosoftNetCompilersToolsetPackageVersion>3.8.0</MicrosoftNetCompilersToolsetPackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>16.3.0</MicrosoftNETTestSdkPackageVersion>
|
||||
<MoqPackageVersion>4.8.1</MoqPackageVersion>
|
||||
<NunitPackageVersion>3.11.0</NunitPackageVersion>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net46;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net46;net5.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RootNamespace>Newtonsoft.Json.TestConsole</RootNamespace>
|
||||
<AssemblyName>Newtonsoft.Json.TestConsole</AssemblyName>
|
||||
|
||||
@@ -113,7 +113,9 @@ namespace Newtonsoft.Json.Tests
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
var binaryFormatter = new BinaryFormatter();
|
||||
#pragma warning disable SYSLIB0011 // Type or member is obsolete
|
||||
binaryFormatter.Serialize(memoryStream, exception);
|
||||
#pragma warning restore SYSLIB0011 // Type or member is obsolete
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace Newtonsoft.Json.Tests.JsonTextReaderTests
|
||||
Assert.AreEqual(Double.MinValue, reader.Value);
|
||||
|
||||
reader = new JsonTextReader(new StringReader("1E+309"));
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
await ExceptionAssert.ThrowsAsync<JsonReaderException>(async () => await reader.ReadAsync(), "Input string '1E+309' is not a valid number. Path '', line 1, position 6.");
|
||||
#else
|
||||
Assert.IsTrue(await reader.ReadAsync());
|
||||
@@ -209,7 +209,7 @@ namespace Newtonsoft.Json.Tests.JsonTextReaderTests
|
||||
#endif
|
||||
|
||||
reader = new JsonTextReader(new StringReader("-1E+5000"));
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
await ExceptionAssert.ThrowsAsync<JsonReaderException>(async () => await reader.ReadAsync(), "Input string '-1E+5000' is not a valid number. Path '', line 1, position 8.");
|
||||
#else
|
||||
Assert.IsTrue(await reader.ReadAsync());
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace Newtonsoft.Json.Tests.JsonTextReaderTests
|
||||
Assert.AreEqual(Double.MinValue, reader.Value);
|
||||
|
||||
reader = new JsonTextReader(new StringReader("1E+309"));
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
ExceptionAssert.Throws<JsonReaderException>(() => reader.Read(), "Input string '1E+309' is not a valid number. Path '', line 1, position 6.");
|
||||
#else
|
||||
Assert.IsTrue(reader.Read());
|
||||
@@ -229,7 +229,7 @@ namespace Newtonsoft.Json.Tests.JsonTextReaderTests
|
||||
#endif
|
||||
|
||||
reader = new JsonTextReader(new StringReader("-1E+5000"));
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
ExceptionAssert.Throws<JsonReaderException>(() => reader.Read(), "Input string '-1E+5000' is not a valid number. Path '', line 1, position 8.");
|
||||
#else
|
||||
Assert.IsTrue(reader.Read());
|
||||
|
||||
@@ -1018,7 +1018,7 @@ namespace Newtonsoft.Json.Tests
|
||||
await jsonWriter.WriteEndArrayAsync();
|
||||
}
|
||||
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
Assert.AreEqual(@"[0.0,0.0,0.1,1.0,1.000001,1E-06,4.94065645841247E-324,Infinity,-Infinity,NaN,1.7976931348623157E+308,-1.7976931348623157E+308,Infinity,-Infinity,NaN]", sb.ToString());
|
||||
#else
|
||||
Assert.AreEqual(@"[0.0,0.0,0.1,1.0,1.000001,1E-06,5E-324,Infinity,-Infinity,NaN,1.7976931348623157E+308,-1.7976931348623157E+308,Infinity,-Infinity,NaN]", sb.ToString());
|
||||
|
||||
@@ -880,7 +880,7 @@ namespace Newtonsoft.Json.Tests
|
||||
jsonWriter.WriteEndArray();
|
||||
}
|
||||
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
Assert.AreEqual(@"[0.0,0.0,0.1,1.0,1.000001,1E-06,4.94065645841247E-324,Infinity,-Infinity,NaN,1.7976931348623157E+308,-1.7976931348623157E+308,Infinity,-Infinity,NaN]", sb.ToString());
|
||||
#else
|
||||
Assert.AreEqual(@"[0.0,0.0,0.1,1.0,1.000001,1E-06,5E-324,Infinity,-Infinity,NaN,1.7976931348623157E+308,-1.7976931348623157E+308,Infinity,-Infinity,NaN]", sb.ToString());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks Condition="'$(TestFrameworks)'==''">net46;net40;net35;net20;netcoreapp3.0;netcoreapp2.2;netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(TestFrameworks)'==''">net46;net40;net35;net20;net5.0;netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(TestFrameworks)'!=''">$(TestFrameworks)</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<VersionPrefix>1.0</VersionPrefix>
|
||||
@@ -13,7 +13,7 @@
|
||||
<RootNamespace>Newtonsoft.Json.Tests</RootNamespace>
|
||||
<IsPackable>false</IsPackable>
|
||||
<!-- Workaround for https://github.com/nunit/nunit3-vs-adapter/issues/296 -->
|
||||
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp2.2' AND '$(TargetFramework)' != 'netcoreapp3.0'">Full</DebugType>
|
||||
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp3.1' AND '$(TargetFramework)' != 'net5.0'">Full</DebugType>
|
||||
<!-- Disabled because SourceLink isn't referenced to calculate paths -->
|
||||
<DeterministicSourcePaths>false</DeterministicSourcePaths>
|
||||
</PropertyGroup>
|
||||
@@ -107,7 +107,7 @@
|
||||
<DefineConstants>NET20;$(AdditionalConstants)</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
|
||||
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
|
||||
<PackageReference Include="FSharp.Core" Version="$(FSharpCorePackageVersion)" />
|
||||
<PackageReference Include="System.ObjectModel" Version="$(SystemObjectModelPackageVersion)" />
|
||||
@@ -122,13 +122,13 @@
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='net5.0'">
|
||||
<AssemblyTitle>Json.NET Tests .NET Standard 2.0</AssemblyTitle>
|
||||
<ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v2.0</ReferringTargetFrameworkForProjectReferences>
|
||||
<DefineConstants>NETSTANDARD2_0;DNXCORE50;PORTABLE;HAVE_BENCHMARKS;$(AdditionalConstants)</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.2'">
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
|
||||
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
|
||||
<PackageReference Include="FSharp.Core" Version="$(FSharpCorePackageVersion)" />
|
||||
<PackageReference Include="System.ObjectModel" Version="$(SystemObjectModelPackageVersion)" />
|
||||
@@ -143,7 +143,7 @@
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp2.2'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
|
||||
<AssemblyTitle>Json.NET Tests .NET Standard 1.3</AssemblyTitle>
|
||||
<ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v1.3</ReferringTargetFrameworkForProjectReferences>
|
||||
<DefineConstants>NETSTANDARD1_3;DNXCORE50;PORTABLE;HAVE_BENCHMARKS;$(AdditionalConstants)</DefineConstants>
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
Dictionary<float, int> dictionary = new Dictionary<float, int> { { float.MaxValue, 1 } };
|
||||
string output = JsonConvert.SerializeObject(dictionary);
|
||||
#if !NETSTANDARD2_0
|
||||
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
|
||||
Assert.AreEqual(@"{""3.40282347E+38"":1}", output);
|
||||
#else
|
||||
Assert.AreEqual(@"{""3.4028235E+38"":1}", output);
|
||||
|
||||
@@ -2258,7 +2258,7 @@ keyword such as type of business.""
|
||||
string json = JsonConvert.SerializeObject(new ConverableMembers(), Formatting.Indented);
|
||||
|
||||
string expected = null;
|
||||
#if NETSTANDARD2_0
|
||||
#if (NETSTANDARD2_0)
|
||||
expected = @"{
|
||||
""String"": ""string"",
|
||||
""Int32"": 2147483647,
|
||||
@@ -2275,7 +2275,23 @@ keyword such as type of business.""
|
||||
""Bool"": true,
|
||||
""Char"": ""\u0000""
|
||||
}";
|
||||
#elif !(PORTABLE || DNXCORE50)
|
||||
#elif NETSTANDARD1_3
|
||||
expected = @"{
|
||||
""String"": ""string"",
|
||||
""Int32"": 2147483647,
|
||||
""UInt32"": 4294967295,
|
||||
""Byte"": 255,
|
||||
""SByte"": 127,
|
||||
""Short"": 32767,
|
||||
""UShort"": 65535,
|
||||
""Long"": 9223372036854775807,
|
||||
""ULong"": 9223372036854775807,
|
||||
""Double"": 1.7976931348623157E+308,
|
||||
""Float"": 3.4028235E+38,
|
||||
""Bool"": true,
|
||||
""Char"": ""\u0000""
|
||||
}";
|
||||
#elif !(PORTABLE || DNXCORE50) || NETSTANDARD1_3
|
||||
expected = @"{
|
||||
""String"": ""string"",
|
||||
""Int32"": 2147483647,
|
||||
|
||||
@@ -715,7 +715,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The JSON to deserialize.</param>
|
||||
/// <returns>The deserialized object from the JSON string.</returns>
|
||||
[DebuggerStepThrough]
|
||||
public static T DeserializeObject<T>(string value)
|
||||
public static T? DeserializeObject<T>(string value)
|
||||
{
|
||||
return DeserializeObject<T>(value, (JsonSerializerSettings?)null);
|
||||
}
|
||||
@@ -732,7 +732,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="anonymousTypeObject">The anonymous type object.</param>
|
||||
/// <returns>The deserialized anonymous type from the JSON string.</returns>
|
||||
[DebuggerStepThrough]
|
||||
public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
|
||||
public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
|
||||
{
|
||||
return DeserializeObject<T>(value);
|
||||
}
|
||||
@@ -753,7 +753,7 @@ namespace Newtonsoft.Json
|
||||
/// </param>
|
||||
/// <returns>The deserialized anonymous type from the JSON string.</returns>
|
||||
[DebuggerStepThrough]
|
||||
public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
|
||||
public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
|
||||
{
|
||||
return DeserializeObject<T>(value, settings);
|
||||
}
|
||||
@@ -766,8 +766,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="converters">Converters to use while deserializing.</param>
|
||||
/// <returns>The deserialized object from the JSON string.</returns>
|
||||
[DebuggerStepThrough]
|
||||
[return: MaybeNull]
|
||||
public static T DeserializeObject<T>(string value, params JsonConverter[] converters)
|
||||
public static T? DeserializeObject<T>(string value, params JsonConverter[] converters)
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
return (T)DeserializeObject(value, typeof(T), converters);
|
||||
@@ -785,8 +784,7 @@ namespace Newtonsoft.Json
|
||||
/// </param>
|
||||
/// <returns>The deserialized object from the JSON string.</returns>
|
||||
[DebuggerStepThrough]
|
||||
[return: MaybeNull]
|
||||
public static T DeserializeObject<T>(string value, JsonSerializerSettings? settings)
|
||||
public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings)
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
return (T)DeserializeObject(value, typeof(T), settings);
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="serializer">The calling serializer.</param>
|
||||
public abstract void WriteJson(JsonWriter writer, [AllowNull]T value, JsonSerializer serializer);
|
||||
public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the JSON representation of the object.
|
||||
@@ -136,7 +136,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||
/// <param name="serializer">The calling serializer.</param>
|
||||
/// <returns>The object value.</returns>
|
||||
public abstract T ReadJson(JsonReader reader, Type objectType, [AllowNull]T existingValue, bool hasExistingValue, JsonSerializer serializer);
|
||||
public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance can convert the specified object type.
|
||||
|
||||
@@ -865,8 +865,7 @@ namespace Newtonsoft.Json
|
||||
/// <typeparam name="T">The type of the object to deserialize.</typeparam>
|
||||
/// <returns>The instance of <typeparamref name="T"/> being deserialized.</returns>
|
||||
[DebuggerStepThrough]
|
||||
[return: MaybeNull]
|
||||
public T Deserialize<T>(JsonReader reader)
|
||||
public T? Deserialize<T>(JsonReader reader)
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
return (T)Deserialize(reader, typeof(T));
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> that contains the values of every token in the source collection with the given key.</returns>
|
||||
public static IJEnumerable<JToken> Values(this IEnumerable<JToken> source, object? key)
|
||||
{
|
||||
return Values<JToken, JToken>(source, key).AsJEnumerable();
|
||||
return Values<JToken, JToken>(source, key)!.AsJEnumerable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -135,7 +135,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <param name="source">An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> that contains the source collection.</param>
|
||||
/// <param name="key">The token key.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> that contains the converted values of every token in the source collection with the given key.</returns>
|
||||
public static IEnumerable<U> Values<U>(this IEnumerable<JToken> source, object key)
|
||||
public static IEnumerable<U?> Values<U>(this IEnumerable<JToken> source, object key)
|
||||
{
|
||||
return Values<JToken, U>(source, key);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <typeparam name="U">The type to convert the values to.</typeparam>
|
||||
/// <param name="source">An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> that contains the source collection.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> that contains the converted values of every token in the source collection.</returns>
|
||||
public static IEnumerable<U> Values<U>(this IEnumerable<JToken> source)
|
||||
public static IEnumerable<U?> Values<U>(this IEnumerable<JToken> source)
|
||||
{
|
||||
return Values<JToken, U>(source, null);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <typeparam name="U">The type to convert the value to.</typeparam>
|
||||
/// <param name="value">A <see cref="JToken"/> cast as a <see cref="IEnumerable{T}"/> of <see cref="JToken"/>.</param>
|
||||
/// <returns>A converted value.</returns>
|
||||
public static U Value<U>(this IEnumerable<JToken> value)
|
||||
public static U? Value<U>(this IEnumerable<JToken> value)
|
||||
{
|
||||
return value.Value<JToken, U>();
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <typeparam name="U">The type to convert the value to.</typeparam>
|
||||
/// <param name="value">A <see cref="JToken"/> cast as a <see cref="IEnumerable{T}"/> of <see cref="JToken"/>.</param>
|
||||
/// <returns>A converted value.</returns>
|
||||
public static U Value<T, U>(this IEnumerable<T> value) where T : JToken
|
||||
public static U? Value<T, U>(this IEnumerable<T> value) where T : JToken
|
||||
{
|
||||
ValidationUtils.ArgumentNotNull(value, nameof(value));
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Newtonsoft.Json.Linq
|
||||
return token.Convert<JToken, U>();
|
||||
}
|
||||
|
||||
internal static IEnumerable<U> Values<T, U>(this IEnumerable<T> source, object? key) where T : JToken
|
||||
internal static IEnumerable<U?> Values<T, U>(this IEnumerable<T> source, object? key) where T : JToken
|
||||
{
|
||||
ValidationUtils.ArgumentNotNull(source, nameof(source));
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> that contains the values of every token in the source collection.</returns>
|
||||
public static IJEnumerable<JToken> Children<T>(this IEnumerable<T> source) where T : JToken
|
||||
{
|
||||
return Children<T, JToken>(source).AsJEnumerable();
|
||||
return Children<T, JToken>(source)!.AsJEnumerable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -236,14 +236,14 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <typeparam name="U">The type to convert the values to.</typeparam>
|
||||
/// <typeparam name="T">The source collection type.</typeparam>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> that contains the converted values of every token in the source collection.</returns>
|
||||
public static IEnumerable<U> Children<T, U>(this IEnumerable<T> source) where T : JToken
|
||||
public static IEnumerable<U?> Children<T, U>(this IEnumerable<T> source) where T : JToken
|
||||
{
|
||||
ValidationUtils.ArgumentNotNull(source, nameof(source));
|
||||
|
||||
return source.SelectMany(c => c.Children()).Convert<JToken, U>();
|
||||
}
|
||||
|
||||
internal static IEnumerable<U> Convert<T, U>(this IEnumerable<T> source) where T : JToken
|
||||
internal static IEnumerable<U?> Convert<T, U>(this IEnumerable<T> source) where T : JToken
|
||||
{
|
||||
ValidationUtils.ArgumentNotNull(source, nameof(source));
|
||||
|
||||
@@ -253,8 +253,7 @@ namespace Newtonsoft.Json.Linq
|
||||
}
|
||||
}
|
||||
|
||||
[return: MaybeNull]
|
||||
internal static U Convert<T, U>(this T token) where T : JToken?
|
||||
internal static U? Convert<T, U>(this T token) where T : JToken?
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <returns>
|
||||
/// A <see cref="IEnumerable{T}"/> containing the child values of this <see cref="JToken"/>, in document order.
|
||||
/// </returns>
|
||||
public override IEnumerable<T> Values<T>()
|
||||
public override IEnumerable<T?> Values<T>() where T : default
|
||||
{
|
||||
return ChildrenTokens.Convert<JToken, T>();
|
||||
}
|
||||
@@ -316,7 +316,7 @@ namespace Newtonsoft.Json.Linq
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsMultiContent([NotNull]object? content)
|
||||
internal bool IsMultiContent([NotNullWhen(true)]object? content)
|
||||
{
|
||||
return (content is IEnumerable && !(content is string) && !(content is JToken) && !(content is byte[]));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Newtonsoft.Json.Linq
|
||||
return JEnumerable<JToken>.Empty;
|
||||
}
|
||||
|
||||
return new JEnumerable<JToken>(_enumerable.Values<T, JToken>(key));
|
||||
return new JEnumerable<JToken>(_enumerable.Values<T, JToken>(key)!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <typeparam name="T">The type to convert the token to.</typeparam>
|
||||
/// <param name="key">The token key.</param>
|
||||
/// <returns>The converted token value.</returns>
|
||||
public virtual T Value<T>(object key)
|
||||
public virtual T? Value<T>(object key)
|
||||
{
|
||||
JToken? token = this[key];
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to convert the values to.</typeparam>
|
||||
/// <returns>A <see cref="IEnumerable{T}"/> containing the child values of this <see cref="JToken"/>, in document order.</returns>
|
||||
public virtual IEnumerable<T> Values<T>()
|
||||
public virtual IEnumerable<T?> Values<T>()
|
||||
{
|
||||
throw new InvalidOperationException("Cannot access child value on {0}.".FormatWith(CultureInfo.InvariantCulture, GetType()));
|
||||
}
|
||||
@@ -1929,8 +1929,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The object type that the token will be deserialized to.</typeparam>
|
||||
/// <returns>The new object created from the JSON value.</returns>
|
||||
[return: MaybeNull]
|
||||
public T ToObject<T>()
|
||||
public T? ToObject<T>()
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
return (T)ToObject(typeof(T));
|
||||
@@ -2065,8 +2064,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <typeparam name="T">The object type that the token will be deserialized to.</typeparam>
|
||||
/// <param name="jsonSerializer">The <see cref="JsonSerializer"/> that will be used when creating the object.</param>
|
||||
/// <returns>The new object created from the JSON value.</returns>
|
||||
[return: MaybeNull]
|
||||
public T ToObject<T>(JsonSerializer jsonSerializer)
|
||||
public T? ToObject<T>(JsonSerializer jsonSerializer)
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
return (T)ToObject(typeof(T), jsonSerializer);
|
||||
|
||||
@@ -841,7 +841,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <c>true</c> if the current object is equal to the <paramref name="other"/> parameter; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="other">An object to compare with this object.</param>
|
||||
public bool Equals([AllowNull] JValue other)
|
||||
public bool Equals(JValue? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net40;net35;net20;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<!-- version numbers will be updated by build -->
|
||||
<AssemblyVersion>11.0.0.0</AssemblyVersion>
|
||||
<FileVersion>11.0.1</FileVersion>
|
||||
|
||||
@@ -589,7 +589,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
throw JsonSerializationException.Create(reader, message);
|
||||
}
|
||||
|
||||
private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type? objectType, ref JsonContract? contract, JsonProperty? member, JsonContainerContract? containerContract, JsonProperty? containerMember, object? existingValue, [NotNullWhen(true)]out object? newValue, out string? id)
|
||||
private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type? objectType, ref JsonContract? contract, JsonProperty? member, JsonContainerContract? containerContract, JsonProperty? containerMember, object? existingValue, out object? newValue, out string? id)
|
||||
{
|
||||
id = null;
|
||||
newValue = null;
|
||||
|
||||
@@ -528,7 +528,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
OnSerialized(writer, contract, value);
|
||||
}
|
||||
|
||||
private bool CalculatePropertyValues(JsonWriter writer, object value, JsonContainerContract contract, JsonProperty? member, JsonProperty property, [NotNullWhen(true)]out JsonContract? memberContract, [NotNullWhen(true)]out object? memberValue)
|
||||
private bool CalculatePropertyValues(JsonWriter writer, object value, JsonContainerContract contract, JsonProperty? member, JsonProperty property, [NotNullWhen(true)]out JsonContract? memberContract, out object? memberValue)
|
||||
{
|
||||
if (!property.Ignored && property.Readable && ShouldSerialize(writer, property, value) && IsSpecified(writer, property, value))
|
||||
{
|
||||
@@ -542,14 +542,14 @@ namespace Newtonsoft.Json.Serialization
|
||||
|
||||
if (ShouldWriteProperty(memberValue, contract as JsonObjectContract, property))
|
||||
{
|
||||
if (ShouldWriteReference(memberValue, property, memberContract!, contract, member))
|
||||
if (ShouldWriteReference(memberValue, property, memberContract, contract, member))
|
||||
{
|
||||
property.WritePropertyName(writer);
|
||||
WriteReference(writer, memberValue!);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckForCircularReference(writer, memberValue, property, memberContract!, contract, member))
|
||||
if (!CheckForCircularReference(writer, memberValue, property, memberContract, contract, member))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -568,7 +568,9 @@ namespace Newtonsoft.Json.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS8762 // Parameter must have a non-null value when exiting in some condition.
|
||||
return true;
|
||||
#pragma warning restore CS8762 // Parameter must have a non-null value when exiting in some condition.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace Newtonsoft.Json.Utilities
|
||||
public static Task<T> FromCanceled<T>(this CancellationToken cancellationToken)
|
||||
{
|
||||
MiscellaneousUtils.Assert(cancellationToken.IsCancellationRequested);
|
||||
#pragma warning disable CS8653 // A default expression introduces a null value for a type parameter.
|
||||
#pragma warning disable CS8603 // Possible null reference return.
|
||||
return new Task<T>(() => default, cancellationToken);
|
||||
#pragma warning restore CS8653 // A default expression introduces a null value for a type parameter.
|
||||
#pragma warning restore CS8603 // Possible null reference return.
|
||||
}
|
||||
|
||||
// Task.Delay(0) is optimised as a cached task within the framework, and indeed
|
||||
|
||||
@@ -166,7 +166,9 @@ namespace Newtonsoft.Json.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey key, [MaybeNull]out TValue value)
|
||||
#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
|
||||
public bool TryGetValue(TKey key, out TValue? value)
|
||||
#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
|
||||
{
|
||||
if (_dictionary != null)
|
||||
{
|
||||
|
||||
@@ -629,7 +629,7 @@ namespace Newtonsoft.Json.Utilities
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool TryGetDateConstructorValue(JsonReader reader, out long? integer, out string? errorMessage)
|
||||
private static bool TryGetDateConstructorValue(JsonReader reader, out long? integer, [NotNullWhen(false)] out string? errorMessage)
|
||||
{
|
||||
integer = null;
|
||||
errorMessage = null;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "3.0.100"
|
||||
"version": "5.0.100"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -32,7 +32,7 @@ steps:
|
||||
write-host "Prerelease $nugetPrerelease" -fore white
|
||||
$assemblyVersion = if ($version.Assembly) { $version.Assembly } else { "$($version.Major).0.0.0" }
|
||||
write-host "Assembly $assemblyVersion" -fore white
|
||||
.\Build\runbuild.ps1 -properties @{"majorVersion"="$($version.Major).0"; "majorWithReleaseVersion"="$($version.Major).0.$($version.Release)"; "nugetPrerelease"=$nugetPrerelease; "assemblyVersion"=$assemblyVersion; "zipFileName"="Json$($version.Major)0r$($version.Release).zip"; "signAssemblies"=$sign; "signKeyPath"=$keyPath; "treatWarningsAsErrors"=$true; "buildNuGet"=$true}
|
||||
.\Build\runbuild.ps1 -properties @{"majorVersion"="$($version.Major).0"; "majorWithReleaseVersion"="$($version.Major).0.$($version.Release)"; "nugetPrerelease"=$nugetPrerelease; "assemblyVersion"=$assemblyVersion; "zipFileName"="Json$($version.Major)0r$($version.Release).zip"; "signAssemblies"=$sign; "signKeyPath"=$keyPath; "treatWarningsAsErrors"=$true; "buildNuGet"=$true; "ensureNetCliSdk"=$false}
|
||||
env:
|
||||
BuildId: $(Build.BuildId)
|
||||
SourceBranch: $(Build.SourceBranch)
|
||||
|
||||
Reference in New Issue
Block a user