diff --git a/Makefile.am b/Makefile.am
index ae86b8f05d..a83f9aaf41 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ csharp_EXTRA_DIST= \
csharp/CHANGES.txt \
csharp/Google.Protobuf.Tools.targets \
csharp/Google.Protobuf.Tools.nuspec \
+ csharp/NuGet.Config \
csharp/README.md \
csharp/build_packages.bat \
csharp/build_tools.sh \
diff --git a/appveyor.bat b/appveyor.bat
index 7a35ceb4d6..005fb11f89 100644
--- a/appveyor.bat
+++ b/appveyor.bat
@@ -38,7 +38,7 @@ dotnet restore
dotnet build -c %configuration% || goto error
echo Testing C#
-dotnet test -c %configuration% -f netcoreapp2.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
+dotnet test -c %configuration% -f netcoreapp3.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
dotnet test -c %configuration% -f net451 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
goto :EOF
diff --git a/conformance/Makefile.am b/conformance/Makefile.am
index ac6f9e1b2b..940c0a2668 100644
--- a/conformance/Makefile.am
+++ b/conformance/Makefile.am
@@ -316,7 +316,7 @@ conformance-java-lite: javac_middleman_lite
conformance-csharp: $(other_language_protoc_outputs)
@echo "Writing shortcut script conformance-csharp..."
@echo '#! /bin/sh' > conformance-csharp
- @echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp2.1/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
+ @echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp3.1/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
@chmod +x conformance-csharp
conformance-php:
diff --git a/csharp/NuGet.Config b/csharp/NuGet.Config
new file mode 100644
index 0000000000..b04b00689f
--- /dev/null
+++ b/csharp/NuGet.Config
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csharp/buildall.sh b/csharp/buildall.sh
index 43b5ac3ffb..ab1a6c425a 100755
--- a/csharp/buildall.sh
+++ b/csharp/buildall.sh
@@ -10,8 +10,8 @@ dotnet restore $SRC/Google.Protobuf.sln
dotnet build -c $CONFIG $SRC/Google.Protobuf.sln
echo Running tests.
-# Only test netcoreapp2.1, which uses the .NET Core runtime.
+# Only test netcoreapp3.1, which uses the .NET Core runtime.
# If we want to test the .NET 4.5 version separately, we could
# run Mono explicitly. However, we don't have any differences between
# the .NET 4.5 and netstandard2.1 assemblies.
-dotnet test -c $CONFIG -f netcoreapp2.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
+dotnet test -c $CONFIG -f netcoreapp3.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
index cbb6fee5f7..0ecdf37abb 100644
--- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
@@ -2,7 +2,7 @@
Exe
- net451;netcoreapp2.1
+ net451;netcoreapp3.1
../../keys/Google.Protobuf.snk
true
False
diff --git a/csharp/compatibility_tests/v3.0.0/test.sh b/csharp/compatibility_tests/v3.0.0/test.sh
index f893d64aba..459c079879 100755
--- a/csharp/compatibility_tests/v3.0.0/test.sh
+++ b/csharp/compatibility_tests/v3.0.0/test.sh
@@ -22,7 +22,7 @@ function run_test() {
dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
- dotnet run -c Release -f netcoreapp2.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
+ dotnet run -c Release -f netcoreapp3.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
}
set -ex
diff --git a/csharp/install_dotnet_sdk.ps1 b/csharp/install_dotnet_sdk.ps1
index c78655cc02..f9dc0d9d7a 100755
--- a/csharp/install_dotnet_sdk.ps1
+++ b/csharp/install_dotnet_sdk.ps1
@@ -16,5 +16,5 @@ Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath
# The SDK versions to install should be kept in sync with versions
# installed by kokoro/linux/dockerfile/test/csharp/Dockerfile
-&$InstallScriptPath -Version 2.1.802
-&$InstallScriptPath -Version 5.0.102
+&$InstallScriptPath -Version 3.1.415
+&$InstallScriptPath -Version 6.0.100
diff --git a/csharp/src/AddressBook/AddressBook.csproj b/csharp/src/AddressBook/AddressBook.csproj
index f3268c0acf..9a527874ce 100644
--- a/csharp/src/AddressBook/AddressBook.csproj
+++ b/csharp/src/AddressBook/AddressBook.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
Exe
Google.Protobuf.Examples.AddressBook.Program
False
diff --git a/csharp/src/Google.Protobuf.Benchmarks/Program.cs b/csharp/src/Google.Protobuf.Benchmarks/Program.cs
index 1f77a26135..037752f6b7 100644
--- a/csharp/src/Google.Protobuf.Benchmarks/Program.cs
+++ b/csharp/src/Google.Protobuf.Benchmarks/Program.cs
@@ -36,7 +36,7 @@ namespace Google.Protobuf.Benchmarks
{
class Program
{
- // typical usage: dotnet run -c Release -f netcoreapp2.1
+ // typical usage: dotnet run -c Release -f netcoreapp3.1
// (this can profile both .net core and .net framework; for some reason
// if you start from "-f net461", it goes horribly wrong)
public static void Main(string[] args)
diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj
index ec8fb91389..6277e6898a 100644
--- a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj
+++ b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
Exe
False
diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj
index fee35be991..b2c4272628 100644
--- a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj
+++ b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
Exe
False
diff --git a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
index 61453e5ab2..ff8f5cc6b1 100644
--- a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
@@ -840,7 +840,7 @@ namespace Google.Protobuf.Collections
var list2 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.PayloadFlipped };
var list3 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.SignallingFlipped };
- // All SampleNaNs have the same hashcode under certain targets (e.g. netcoreapp2.1)
+ // All SampleNaNs have the same hashcode under certain targets (e.g. netcoreapp3.1)
EqualityTester.AssertInequality(list1, list2, checkHashcode: false);
EqualityTester.AssertEquality(list1, list3);
Assert.True(list1.Contains(SampleNaNs.SignallingFlipped));
diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
index cdfa98e098..2665cc3d35 100644
--- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
+++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
@@ -1,7 +1,7 @@
- net451;netcoreapp2.1;net50
+ net451;netcoreapp3.1;net60
../../keys/Google.Protobuf.snk
true
False
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
index 69c9eb6e99..e170fcc5a0 100644
--- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -551,13 +551,9 @@ namespace Google.Protobuf
}
[Test]
- // Skip these test cases in .NET 5 because floating point parsing supports bigger values.
- // These big values won't throw an error in the test.
-#if !NET5_0
[TestCase("1.7977e308")]
[TestCase("-1.7977e308")]
[TestCase("1e309")]
-#endif
[TestCase("1,0")]
[TestCase("1.0.0")]
[TestCase("+1")]
diff --git a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs
index 0cbc0a4ff8..df43effd4f 100644
--- a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs
@@ -199,12 +199,8 @@ namespace Google.Protobuf
[TestCase("1e-")]
[TestCase("--")]
[TestCase("--1")]
- // Skip these test cases in .NET 5 because floating point parsing supports bigger values.
- // These big values won't throw an error in the test.
-#if !NET5_0
[TestCase("-1.7977e308")]
[TestCase("1.7977e308")]
-#endif
public void InvalidNumberValue(string json)
{
AssertThrowsAfter(json);
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index ad6f57999b..7e9e33a302 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -1,4 +1,4 @@
-
+
C# runtime library for Protocol Buffers - Google's data interchange format.
@@ -43,7 +43,7 @@
-
+
diff --git a/csharp/src/Google.Protobuf/JsonTokenizer.cs b/csharp/src/Google.Protobuf/JsonTokenizer.cs
index 4725e7cc51..13a12c05dd 100644
--- a/csharp/src/Google.Protobuf/JsonTokenizer.cs
+++ b/csharp/src/Google.Protobuf/JsonTokenizer.cs
@@ -471,9 +471,18 @@ namespace Google.Protobuf
// TODO: What exception should we throw if the value can't be represented as a double?
try
{
- return double.Parse(builder.ToString(),
+ double result = double.Parse(builder.ToString(),
NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent,
CultureInfo.InvariantCulture);
+
+ // .NET Core 3.0 and later returns infinity if the number is too large or small to be represented.
+ // For compatibility with other Protobuf implementations the tokenizer should still throw.
+ if (double.IsInfinity(result))
+ {
+ throw reader.CreateException("Numeric value out of range: " + builder);
+ }
+
+ return result;
}
catch (OverflowException)
{
diff --git a/global.json b/global.json
index d29e29a3ea..ade0252834 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "5.0.102",
+ "version": "6.0.100",
"rollForward": "latestMinor"
}
}
diff --git a/kokoro/linux/aarch64/test_csharp_aarch64.sh b/kokoro/linux/aarch64/test_csharp_aarch64.sh
index 450bb1e04d..6cbd2438b3 100755
--- a/kokoro/linux/aarch64/test_csharp_aarch64.sh
+++ b/kokoro/linux/aarch64/test_csharp_aarch64.sh
@@ -15,7 +15,7 @@ fi
# First, build protobuf C# tests under x86_64 docker image
# Tests are built "dotnet publish" because we want all the dependencies to the copied to the destination directory
# (we want to avoid references to ~/.nuget that won't be available in the subsequent docker run)
-CSHARP_BUILD_COMMAND="dotnet publish -c Release -f net50 csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj"
+CSHARP_BUILD_COMMAND="dotnet publish -c Release -f net60 csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj"
docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -e "DOTNET_CLI_TELEMETRY_OPTOUT=true" -e "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work mcr.microsoft.com/dotnet/sdk:5.0.202-buster-slim bash -c "$CSHARP_BUILD_COMMAND"
# Use an actual aarch64 docker image to run protobuf C# tests with an emulator. "dotnet vstest" allows
@@ -25,5 +25,5 @@ docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-
# running under current user's UID and GID. To be able to do that, we need to provide a home directory for the user
# otherwise the UID would be homeless under the docker container and pip install wouldn't work. For simplicity,
# we just run map the user's home to a throwaway temporary directory
-CSHARP_TEST_COMMAND="dotnet vstest csharp/src/Google.Protobuf.Test/bin/Release/net50/publish/Google.Protobuf.Test.dll"
+CSHARP_TEST_COMMAND="dotnet vstest csharp/src/Google.Protobuf.Test/bin/Release/net60/publish/Google.Protobuf.Test.dll"
docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -e "DOTNET_CLI_TELEMETRY_OPTOUT=true" -e "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work mcr.microsoft.com/dotnet/sdk:5.0.202-buster-slim-arm64v8 bash -c "$CSHARP_TEST_COMMAND"
diff --git a/kokoro/linux/dockerfile/test/csharp/Dockerfile b/kokoro/linux/dockerfile/test/csharp/Dockerfile
index 37edbfda99..c07fcbcef1 100644
--- a/kokoro/linux/dockerfile/test/csharp/Dockerfile
+++ b/kokoro/linux/dockerfile/test/csharp/Dockerfile
@@ -32,8 +32,8 @@ RUN apt-get update && apt-get install -y libunwind8 libicu63 && apt-get clean
# Install dotnet SDK via install script
RUN wget -q https://dot.net/v1/dotnet-install.sh && \
chmod u+x dotnet-install.sh && \
- ./dotnet-install.sh --version 2.1.802 && \
- ./dotnet-install.sh --version 5.0.102 && \
+ ./dotnet-install.sh --version 3.1.415 && \
+ ./dotnet-install.sh --version 6.0.100 && \
ln -s /root/.dotnet/dotnet /usr/local/bin
RUN wget -q www.nuget.org/NuGet.exe -O /usr/local/bin/nuget.exe