[dotnet, csharp] Run tests for supported platforms .NET 6, .NET Framework 4.6.2 (#12378)
What's changed?
- Update some nuget packages (for test projects)
- Run unit tests for supported platforms: .NET 6 + .NET Framework 4.6.2
Notes:
.NET Framework 4.6.1 is out of support, .NET Framework 4.6.2 is the older version that is still supported
https://devblogs.microsoft.com/dotnet/net-framework-4-5-2-4-6-4-6-1-will-reach-end-of-support-on-april-26-2022/
.NET 5 is out of support
https://devblogs.microsoft.com/dotnet/dotnet-5-end-of-support-update/
.NET Core 3.1 is out of support
https://devblogs.microsoft.com/dotnet/net-core-3-1-will-reach-end-of-support-on-december-13-2022/
Visual studio 2012 is out of support
https://devblogs.microsoft.com/visualstudio/support-ends-for-older-versions-of-visual-studio-feb2022
Closes #12378
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12378 from Romfos:main 227661e02c
PiperOrigin-RevId: 523196896
pull/12437/head
parent
5a679dfb29
commit
09f094c811
|
@ -65,7 +65,7 @@ jobs:
|
||||||
/bin/bash -c '
|
/bin/bash -c '
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT=true
|
DOTNET_CLI_TELEMETRY_OPTOUT=true
|
||||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
|
||||||
dotnet publish -c Release -f net60 /workspace/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj'
|
dotnet publish -c Release -f net6.0 /workspace/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj'
|
||||||
|
|
||||||
- name: Use an actual aarch64 docker image to run protobuf C# tests with an emulator
|
- name: Use an actual aarch64 docker image to run protobuf C# tests with an emulator
|
||||||
# "dotnet vstest" allows running tests from a pre-built project.
|
# "dotnet vstest" allows running tests from a pre-built project.
|
||||||
|
@ -83,4 +83,4 @@ jobs:
|
||||||
/bin/bash -c '
|
/bin/bash -c '
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT=true
|
DOTNET_CLI_TELEMETRY_OPTOUT=true
|
||||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
|
||||||
dotnet vstest /workspace/csharp/src/Google.Protobuf.Test/bin/Release/net60/publish/Google.Protobuf.Test.dll'
|
dotnet vstest /workspace/csharp/src/Google.Protobuf.Test/bin/Release/net6.0/publish/Google.Protobuf.Test.dll'
|
||||||
|
|
|
@ -38,8 +38,8 @@ dotnet restore
|
||||||
dotnet build -c %configuration% || goto error
|
dotnet build -c %configuration% || goto error
|
||||||
|
|
||||||
echo Testing C#
|
echo Testing C#
|
||||||
dotnet test -c %configuration% -f netcoreapp3.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
|
dotnet test -c %configuration% -f net6.0 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
|
||||||
dotnet test -c %configuration% -f net451 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
|
dotnet test -c %configuration% -f net462 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
|
||||||
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
# See also code generation logic under /src/google/protobuf/compiler/csharp.
|
# See also code generation logic under /src/google/protobuf/compiler/csharp.
|
||||||
|
|
||||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||||
load("//:protobuf.bzl", "internal_csharp_proto_library")
|
|
||||||
load("//build_defs:internal_shell.bzl", "inline_sh_test")
|
load("//build_defs:internal_shell.bzl", "inline_sh_test")
|
||||||
load("//conformance:defs.bzl", "conformance_test")
|
load("//conformance:defs.bzl", "conformance_test")
|
||||||
|
|
||||||
|
@ -24,21 +23,24 @@ conformance_test(
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "srcs",
|
name = "srcs",
|
||||||
srcs = glob([
|
srcs = glob(
|
||||||
"keys/*",
|
[
|
||||||
"protos/*",
|
"keys/*",
|
||||||
"src/**/*.cs*", # .cs and .csproj
|
"protos/*",
|
||||||
], exclude = [
|
"src/**/*.cs*", # .cs and .csproj
|
||||||
# Exclude generated files.
|
],
|
||||||
"src/*/obj/**/*"
|
exclude = [
|
||||||
]) + [
|
# Exclude generated files.
|
||||||
|
"src/*/obj/**/*",
|
||||||
|
],
|
||||||
|
) + [
|
||||||
"src/Directory.Build.props",
|
"src/Directory.Build.props",
|
||||||
"src/Google.Protobuf.Test/testprotos.pb",
|
"src/Google.Protobuf.Test/testprotos.pb",
|
||||||
"src/Google.Protobuf.sln",
|
"src/Google.Protobuf.sln",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
|
"//conformance:__subpackages__",
|
||||||
"//csharp:__subpackages__",
|
"//csharp:__subpackages__",
|
||||||
"//conformance:__subpackages__"
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,8 +65,8 @@ filegroup(
|
||||||
inline_sh_test(
|
inline_sh_test(
|
||||||
name = "tests",
|
name = "tests",
|
||||||
srcs = [
|
srcs = [
|
||||||
":srcs",
|
|
||||||
"src/Google.Protobuf.sln",
|
"src/Google.Protobuf.sln",
|
||||||
|
":srcs",
|
||||||
"//conformance:conformance_csharp_proto",
|
"//conformance:conformance_csharp_proto",
|
||||||
"//csharp/src/Google.Protobuf.Conformance:srcs",
|
"//csharp/src/Google.Protobuf.Conformance:srcs",
|
||||||
],
|
],
|
||||||
|
@ -73,7 +75,7 @@ inline_sh_test(
|
||||||
pushd `dirname $(location src/Google.Protobuf.sln)`/..
|
pushd `dirname $(location src/Google.Protobuf.sln)`/..
|
||||||
dotnet restore src/Google.Protobuf.sln
|
dotnet restore src/Google.Protobuf.sln
|
||||||
dotnet build -c Release src/Google.Protobuf.sln
|
dotnet build -c Release src/Google.Protobuf.sln
|
||||||
dotnet test -c Release -f netcoreapp3.1 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
dotnet test -c Release -f net6.0 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
||||||
popd
|
popd
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
@ -85,7 +87,6 @@ inline_sh_test(
|
||||||
pkg_files(
|
pkg_files(
|
||||||
name = "dist_files",
|
name = "dist_files",
|
||||||
srcs = [
|
srcs = [
|
||||||
":srcs",
|
|
||||||
".editorconfig",
|
".editorconfig",
|
||||||
".gitignore",
|
".gitignore",
|
||||||
"BUILD.bazel",
|
"BUILD.bazel",
|
||||||
|
@ -101,6 +102,7 @@ pkg_files(
|
||||||
"buildall.sh",
|
"buildall.sh",
|
||||||
"generate_protos.sh",
|
"generate_protos.sh",
|
||||||
"install_dotnet_sdk.ps1",
|
"install_dotnet_sdk.ps1",
|
||||||
|
":srcs",
|
||||||
"//csharp/src/Google.Protobuf.Conformance:dist_files",
|
"//csharp/src/Google.Protobuf.Conformance:dist_files",
|
||||||
],
|
],
|
||||||
strip_prefix = strip_prefix.from_root(""),
|
strip_prefix = strip_prefix.from_root(""),
|
||||||
|
@ -108,7 +110,7 @@ pkg_files(
|
||||||
)
|
)
|
||||||
|
|
||||||
sh_binary(
|
sh_binary(
|
||||||
name = "release",
|
name = "release",
|
||||||
srcs = ["build_release.sh"],
|
srcs = ["build_release.sh"],
|
||||||
args = ["$(location build_release.sh)"],
|
args = ["$(location build_release.sh)"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,8 +10,8 @@ dotnet restore $SRC/Google.Protobuf.sln
|
||||||
dotnet build -c $CONFIG $SRC/Google.Protobuf.sln
|
dotnet build -c $CONFIG $SRC/Google.Protobuf.sln
|
||||||
|
|
||||||
echo Running tests.
|
echo Running tests.
|
||||||
# Only test netcoreapp3.1, which uses the .NET Core runtime.
|
# Only test net6.0, which uses the .NET runtime.
|
||||||
# If we want to test the .NET 4.5 version separately, we could
|
# If we want to test the .NET 4.5 version separately, we could
|
||||||
# run Mono explicitly. However, we don't have any differences between
|
# run Mono explicitly. However, we don't have any differences between
|
||||||
# the .NET 4.5 and netstandard2.1 assemblies.
|
# the .NET 4.5 and netstandard2.1 assemblies.
|
||||||
dotnet test -c $CONFIG -f netcoreapp3.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
dotnet test -c $CONFIG -f net6.0 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworks>net451;netcoreapp3.1</TargetFrameworks>
|
<TargetFrameworks>net462;net6.0</TargetFrameworks>
|
||||||
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
|
@ -18,9 +18,9 @@
|
||||||
<PackageReference Include="NUnitLite" Version="3.6.1" />
|
<PackageReference Include="NUnitLite" Version="3.6.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
|
<!-- Needed for the netfx build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -22,7 +22,7 @@ function run_test() {
|
||||||
dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
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/Google.Protobuf.csproj
|
||||||
dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
||||||
dotnet run -c Release -f netcoreapp3.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
dotnet run -c Release -f net6.0 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
||||||
}
|
}
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<StartupObject>Google.Protobuf.Examples.AddressBook.Program</StartupObject>
|
<StartupObject>Google.Protobuf.Examples.AddressBook.Program</StartupObject>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
load("//:protobuf.bzl", "internal_csharp_proto_library")
|
|
||||||
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
|
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
|
||||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||||
|
|
||||||
|
@ -38,8 +37,8 @@ CONFORMANCE_DEPS = [
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "srcs",
|
name = "srcs",
|
||||||
srcs = [
|
srcs = [
|
||||||
"Program.cs",
|
|
||||||
"Google.Protobuf.Conformance.csproj",
|
"Google.Protobuf.Conformance.csproj",
|
||||||
|
"Program.cs",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//csharp:__subpackages__",
|
"//csharp:__subpackages__",
|
||||||
|
@ -54,15 +53,15 @@ genrule(
|
||||||
"//conformance:conformance_csharp_proto",
|
"//conformance:conformance_csharp_proto",
|
||||||
"//csharp:srcs",
|
"//csharp:srcs",
|
||||||
],
|
],
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
tools = [":build_conformance_test"],
|
|
||||||
outs = CONFORMANCE_DEPS + ["Google.Protobuf.Conformance.dll"],
|
outs = CONFORMANCE_DEPS + ["Google.Protobuf.Conformance.dll"],
|
||||||
cmd = """
|
cmd = """
|
||||||
SRCDIR=$$(dirname $(location :Program.cs))
|
SRCDIR=$$(dirname $(location :Program.cs))
|
||||||
cp $(location //conformance:conformance_csharp_proto) $$SRCDIR
|
cp $(location //conformance:conformance_csharp_proto) $$SRCDIR
|
||||||
DOTNET_CLI_HOME=/tmp ./$(location :build_conformance_test)
|
DOTNET_CLI_HOME=/tmp ./$(location :build_conformance_test)
|
||||||
cp -r $$SRCDIR/bin/Release/netcoreapp3.1/* $(RULEDIR)
|
cp -r $$SRCDIR/bin/Release/net6.0/* $(RULEDIR)
|
||||||
""",
|
""",
|
||||||
|
tools = [":build_conformance_test"],
|
||||||
|
visibility = ["//visibility:private"],
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
@ -93,4 +92,3 @@ pkg_files(
|
||||||
strip_prefix = strip_prefix.from_root(""),
|
strip_prefix = strip_prefix.from_root(""),
|
||||||
visibility = ["//csharp:__pkg__"],
|
visibility = ["//csharp:__pkg__"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
and without the internal visibility from the test project (all of which have caused issues in the past).
|
and without the internal visibility from the test project (all of which have caused issues in the past).
|
||||||
-->
|
-->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net462;netstandard1.1;netstandard2.0</TargetFrameworks>
|
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
|
<!-- Needed for the netfx build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net462;netcoreapp3.1;net60</TargetFrameworks>
|
<TargetFrameworks>net462;net6.0</TargetFrameworks>
|
||||||
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
|
@ -14,12 +14,12 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.2.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
|
<!-- Needed for the netfx build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region Copyright notice and license
|
#region Copyright notice and license
|
||||||
// Protocol Buffers - Google's data interchange format
|
// Protocol Buffers - Google's data interchange format
|
||||||
// Copyright 2008 Google Inc. All rights reserved.
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
// https://developers.google.com/protocol-buffers/
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
@ -50,10 +50,12 @@ namespace Google.Protobuf
|
||||||
[SecuritySafeCritical]
|
[SecuritySafeCritical]
|
||||||
internal static class WritingPrimitives
|
internal static class WritingPrimitives
|
||||||
{
|
{
|
||||||
#if NET5_0
|
#if NET5_0_OR_GREATER
|
||||||
internal static Encoding Utf8Encoding => Encoding.UTF8; // allows JIT to devirtualize
|
internal static Encoding Utf8Encoding => Encoding.UTF8; // allows JIT to devirtualize
|
||||||
#else
|
#else
|
||||||
internal static readonly Encoding Utf8Encoding = Encoding.UTF8; // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
|
internal static readonly Encoding Utf8Encoding =
|
||||||
|
Encoding.UTF8; // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a
|
||||||
|
// difference.)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#region Writing of values (not including tags)
|
#region Writing of values (not including tags)
|
||||||
|
@ -753,4 +755,4 @@ namespace Google.Protobuf
|
||||||
return (ulong)((n << 1) ^ (n >> 63));
|
return (ulong)((n << 1) ^ (n >> 63));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue