Skip to content

Commit a222c8b

Browse files
authored
Update to net50 and fix warnings (#2424)
1 parent 666d976 commit a222c8b

27 files changed

+86
-64
lines changed

Build/build.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
$workingName = if ($workingName) {$workingName} else {"Working"}
1515
$assemblyVersion = if ($assemblyVersion) {$assemblyVersion} else {$majorVersion + '.0.0'}
1616
$netCliChannel = "Current"
17-
$netCliVersion = "3.0.100"
17+
$netCliVersion = "5.0.100"
1818
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
19+
$ensureNetCliSdk = $true
1920

2021
$baseDir = resolve-path ..
2122
$buildDir = "$baseDir\Build"
@@ -31,8 +32,8 @@
3132
$nunitConsolePath = "$buildDir\Temp\NUnit.ConsoleRunner.$nunitConsoleVersion"
3233

3334
$builds = @(
34-
@{Framework = "netstandard2.0"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp3.0"; Enabled=$true},
35-
@{Framework = "netstandard1.3"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp2.2"; Enabled=$true},
35+
@{Framework = "netstandard2.0"; TestsFunction = "NetCliTests"; TestFramework = "net5.0"; Enabled=$true},
36+
@{Framework = "netstandard1.3"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp3.1"; Enabled=$true},
3637
@{Framework = "netstandard1.0"; TestsFunction = "NetCliTests"; TestFramework = "netcoreapp2.1"; Enabled=$true},
3738
@{Framework = "net45"; TestsFunction = "NUnitTests"; TestFramework = "net46"; NUnitFramework="net-4.0"; Enabled=$true},
3839
@{Framework = "net40"; TestsFunction = "NUnitTests"; NUnitFramework="net-4.0"; Enabled=$true},
@@ -69,7 +70,10 @@ task Build -depends Clean {
6970

7071
mkdir "$buildDir\Temp" -Force
7172

72-
EnsureDotNetCli
73+
if ($ensureNetCliSdk)
74+
{
75+
EnsureDotNetCli
76+
}
7377
EnsureNuGetExists
7478
EnsureNuGetPackage "vswhere" $vswherePath $vswhereVersion
7579
EnsureNuGetPackage "NUnit.ConsoleRunner" $nunitConsolePath $nunitConsoleVersion
@@ -170,6 +174,8 @@ function EnsureDotnetCli()
170174
-OutFile "$buildDir\Temp\dotnet-install.ps1"
171175

172176
exec { & $buildDir\Temp\dotnet-install.ps1 -Channel $netCliChannel -Version $netCliVersion | Out-Default }
177+
exec { & $buildDir\Temp\dotnet-install.ps1 -Channel $netCliChannel -Version '3.1.402' | Out-Default }
178+
exec { & $buildDir\Temp\dotnet-install.ps1 -Channel $netCliChannel -Version '2.1.811' | Out-Default }
173179
}
174180

175181
function EnsureNuGetExists()

Src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<MicrosoftCodeAnalysisFxCopAnalyzersPackageVersion>2.9.2</MicrosoftCodeAnalysisFxCopAnalyzersPackageVersion>
77
<MicrosoftCSharpPackageVersion>4.3.0</MicrosoftCSharpPackageVersion>
88
<MicrosoftSourceLinkGitHubPackageVersion>1.0.0-beta2-19367-01</MicrosoftSourceLinkGitHubPackageVersion>
9-
<MicrosoftNetCompilersToolsetPackageVersion>3.3.1</MicrosoftNetCompilersToolsetPackageVersion>
9+
<MicrosoftNetCompilersToolsetPackageVersion>3.8.0</MicrosoftNetCompilersToolsetPackageVersion>
1010
<MicrosoftNETTestSdkPackageVersion>16.3.0</MicrosoftNETTestSdkPackageVersion>
1111
<MoqPackageVersion>4.8.1</MoqPackageVersion>
1212
<NunitPackageVersion>3.11.0</NunitPackageVersion>

Src/Newtonsoft.Json.TestConsole/Newtonsoft.Json.TestConsole.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFrameworks>net46;netcoreapp3.0</TargetFrameworks>
4+
<TargetFrameworks>net46;net5.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<RootNamespace>Newtonsoft.Json.TestConsole</RootNamespace>
77
<AssemblyName>Newtonsoft.Json.TestConsole</AssemblyName>

Src/Newtonsoft.Json.Tests/ExceptionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ public void BinarySerializeException()
113113
using (var memoryStream = new MemoryStream())
114114
{
115115
var binaryFormatter = new BinaryFormatter();
116+
#pragma warning disable SYSLIB0011 // Type or member is obsolete
116117
binaryFormatter.Serialize(memoryStream, exception);
118+
#pragma warning restore SYSLIB0011 // Type or member is obsolete
117119
}
118120
}
119121
#endif

Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ParseAsyncTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public async Task ParseDoublesAsync()
200200
Assert.AreEqual(Double.MinValue, reader.Value);
201201

202202
reader = new JsonTextReader(new StringReader("1E+309"));
203-
#if !NETSTANDARD2_0
203+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
204204
await ExceptionAssert.ThrowsAsync<JsonReaderException>(async () => await reader.ReadAsync(), "Input string '1E+309' is not a valid number. Path '', line 1, position 6.");
205205
#else
206206
Assert.IsTrue(await reader.ReadAsync());
@@ -209,7 +209,7 @@ public async Task ParseDoublesAsync()
209209
#endif
210210

211211
reader = new JsonTextReader(new StringReader("-1E+5000"));
212-
#if !NETSTANDARD2_0
212+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
213213
await ExceptionAssert.ThrowsAsync<JsonReaderException>(async () => await reader.ReadAsync(), "Input string '-1E+5000' is not a valid number. Path '', line 1, position 8.");
214214
#else
215215
Assert.IsTrue(await reader.ReadAsync());

Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ParseTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void ParseDoubles()
220220
Assert.AreEqual(Double.MinValue, reader.Value);
221221

222222
reader = new JsonTextReader(new StringReader("1E+309"));
223-
#if !NETSTANDARD2_0
223+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
224224
ExceptionAssert.Throws<JsonReaderException>(() => reader.Read(), "Input string '1E+309' is not a valid number. Path '', line 1, position 6.");
225225
#else
226226
Assert.IsTrue(reader.Read());
@@ -229,7 +229,7 @@ public void ParseDoubles()
229229
#endif
230230

231231
reader = new JsonTextReader(new StringReader("-1E+5000"));
232-
#if !NETSTANDARD2_0
232+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
233233
ExceptionAssert.Throws<JsonReaderException>(() => reader.Read(), "Input string '-1E+5000' is not a valid number. Path '', line 1, position 8.");
234234
#else
235235
Assert.IsTrue(reader.Read());

Src/Newtonsoft.Json.Tests/JsonTextWriterAsyncTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ public async Task WriteFloatingPointNumberAsync()
10181018
await jsonWriter.WriteEndArrayAsync();
10191019
}
10201020

1021-
#if !NETSTANDARD2_0
1021+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
10221022
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());
10231023
#else
10241024
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());

Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ public void WriteFloatingPointNumber()
880880
jsonWriter.WriteEndArray();
881881
}
882882

883-
#if !NETSTANDARD2_0
883+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
884884
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());
885885
#else
886886
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());

Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks Condition="'$(TestFrameworks)'==''">net46;net40;net35;net20;netcoreapp3.0;netcoreapp2.2;netcoreapp2.1</TargetFrameworks>
3+
<TargetFrameworks Condition="'$(TestFrameworks)'==''">net46;net40;net35;net20;net5.0;netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
44
<TargetFrameworks Condition="'$(TestFrameworks)'!=''">$(TestFrameworks)</TargetFrameworks>
55
<LangVersion>8.0</LangVersion>
66
<VersionPrefix>1.0</VersionPrefix>
@@ -13,7 +13,7 @@
1313
<RootNamespace>Newtonsoft.Json.Tests</RootNamespace>
1414
<IsPackable>false</IsPackable>
1515
<!-- Workaround for https://github.com/nunit/nunit3-vs-adapter/issues/296 -->
16-
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp2.2' AND '$(TargetFramework)' != 'netcoreapp3.0'">Full</DebugType>
16+
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp3.1' AND '$(TargetFramework)' != 'net5.0'">Full</DebugType>
1717
<!-- Disabled because SourceLink isn't referenced to calculate paths -->
1818
<DeterministicSourcePaths>false</DeterministicSourcePaths>
1919
</PropertyGroup>
@@ -107,7 +107,7 @@
107107
<DefineConstants>NET20;$(AdditionalConstants)</DefineConstants>
108108
</PropertyGroup>
109109

110-
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
110+
<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
111111
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
112112
<PackageReference Include="FSharp.Core" Version="$(FSharpCorePackageVersion)" />
113113
<PackageReference Include="System.ObjectModel" Version="$(SystemObjectModelPackageVersion)" />
@@ -122,13 +122,13 @@
122122
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
123123
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
124124
</ItemGroup>
125-
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
125+
<PropertyGroup Condition="'$(TargetFramework)'=='net5.0'">
126126
<AssemblyTitle>Json.NET Tests .NET Standard 2.0</AssemblyTitle>
127127
<ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v2.0</ReferringTargetFrameworkForProjectReferences>
128128
<DefineConstants>NETSTANDARD2_0;DNXCORE50;PORTABLE;HAVE_BENCHMARKS;$(AdditionalConstants)</DefineConstants>
129129
</PropertyGroup>
130130

131-
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.2'">
131+
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
132132
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
133133
<PackageReference Include="FSharp.Core" Version="$(FSharpCorePackageVersion)" />
134134
<PackageReference Include="System.ObjectModel" Version="$(SystemObjectModelPackageVersion)" />
@@ -143,7 +143,7 @@
143143
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
144144
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
145145
</ItemGroup>
146-
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp2.2'">
146+
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
147147
<AssemblyTitle>Json.NET Tests .NET Standard 1.3</AssemblyTitle>
148148
<ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v1.3</ReferringTargetFrameworkForProjectReferences>
149149
<DefineConstants>NETSTANDARD1_3;DNXCORE50;PORTABLE;HAVE_BENCHMARKS;$(AdditionalConstants)</DefineConstants>

Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void FloatKey_MaxValue()
187187
{
188188
Dictionary<float, int> dictionary = new Dictionary<float, int> { { float.MaxValue, 1 } };
189189
string output = JsonConvert.SerializeObject(dictionary);
190-
#if !NETSTANDARD2_0
190+
#if !(NETSTANDARD2_0 || NETSTANDARD1_3)
191191
Assert.AreEqual(@"{""3.40282347E+38"":1}", output);
192192
#else
193193
Assert.AreEqual(@"{""3.4028235E+38"":1}", output);

0 commit comments

Comments
 (0)