From 51fc54f8c161ae94e4d230cddae8d9d2ee279fad Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 14 Feb 2023 23:51:16 +0100 Subject: THRIFT-5684 upgrade to net7.0: Client: netstd Patch: Jens Geyer --- build/docker/README.md | 2 +- build/docker/old/debian-stretch/Dockerfile | 8 +++---- build/docker/old/ubuntu-artful/Dockerfile | 8 +++---- build/docker/old/ubuntu-disco/Dockerfile | 8 +++---- build/docker/old/ubuntu-xenial/Dockerfile | 8 +++---- build/docker/ubuntu-bionic/Dockerfile | 8 +++---- build/docker/ubuntu-focal/Dockerfile | 8 +++---- build/docker/ubuntu-jammy/Dockerfile | 8 +++---- .../cpp/src/thrift/generate/t_netstd_generator.cc | 26 +++++++++++++--------- configure.ac | 2 +- .../Thrift.Benchmarks/Thrift.Benchmarks.csproj | 6 ++--- .../Thrift.IntegrationTests.csproj | 14 ++++++------ .../Thrift.PublicInterfaces.Compile.Tests.csproj | 6 ++--- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 14 ++++++------ lib/netstd/Thrift/Thrift.csproj | 14 ++++++------ .../Transport/Server/TNamedPipeServerTransport.cs | 19 ---------------- test/netstd/Client/Client.csproj | 6 ++--- test/netstd/Client/TestClient.cs | 2 +- test/netstd/Server/Server.csproj | 6 ++--- test/netstd/Server/TestServer.cs | 2 +- tutorial/netstd/Client/Client.csproj | 4 ++-- tutorial/netstd/Interfaces/Interfaces.csproj | 4 ++-- tutorial/netstd/Server/Program.cs | 2 +- tutorial/netstd/Server/Server.csproj | 4 ++-- 24 files changed, 88 insertions(+), 101 deletions(-) diff --git a/build/docker/README.md b/build/docker/README.md index a41f031a5..9635e6f04 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -183,7 +183,7 @@ Last updated: October 1, 2017 | java | 1.8.0\_191 | 17 | | | js | Node.js 6.17.1, V8 5.1.281.111, npm 3.10.10 | Node.js 10.18.0, V8 6.8.275.32, npm 6.13.4 | | | lua | | 5.2.4 | Lua 5.3: see THRIFT-4386 | -| netstd | 6.0 | 6.0 | | +| netstd | 7.0 | 7.0 | | | nodejs | 6.16.0 | 10.16.0 | | | ocaml | | 4.05.0 | THRIFT-4517: ocaml 4.02.3 on xenial appears broken | | perl | 5.22.1 | 5.26.1 | | diff --git a/build/docker/old/debian-stretch/Dockerfile b/build/docker/old/debian-stretch/Dockerfile index 628b6268e..25237cabf 100644 --- a/build/docker/old/debian-stretch/Dockerfile +++ b/build/docker/old/debian-stretch/Dockerfile @@ -102,10 +102,10 @@ ENV PATH /usr/lib/dart/bin:$PATH # project isn't ready for this quite yet: # RUN apt-get install -y --no-install-recommends \ # `# dotnet core dependencies` \ -# dotnet-sdk-6.0 \ -# dotnet-runtime-6.0 \ -# aspnetcore-runtime-6.0 \ -# dotnet-apphost-pack-6.0 +# dotnet-sdk-7.0 \ +# dotnet-runtime-7.0 \ +# aspnetcore-runtime-7.0 \ +# dotnet-apphost-pack-7.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-artful/Dockerfile b/build/docker/old/ubuntu-artful/Dockerfile index 80682657b..039147033 100644 --- a/build/docker/old/ubuntu-artful/Dockerfile +++ b/build/docker/old/ubuntu-artful/Dockerfile @@ -120,10 +120,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index 2e802e5ac..37377e34f 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -126,10 +126,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index 7cb58e8ce..add524ded 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -115,10 +115,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=18.3.4.11 diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index 873dad836..f0dcb9080 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -124,10 +124,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 0a8c1c763..ad01f7e9f 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -125,10 +125,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index 7d56cc5fe..d2a5f64a4 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -125,10 +125,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index 96bdc3c06..1c9700299 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -179,6 +179,12 @@ string t_netstd_generator::normalize_name(string name, bool is_arg_name) return "@" + name; } + // prevent CS8981 "The type name only contains lower-cased ascii characters" + if( name.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == std::string::npos) + { + return "@" + name; + } + // no changes necessary return name; } @@ -356,7 +362,7 @@ void t_netstd_generator::generate_consts(ostream& out, vector consts) for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { generate_netstd_doc(out, *c_iter); - if (print_const_value(out, (*c_iter)->get_name(), (*c_iter)->get_type(), (*c_iter)->get_value(), false)) + if (print_const_value(out, normalize_name((*c_iter)->get_name()), (*c_iter)->get_type(), (*c_iter)->get_value(), false)) { need_static_constructor = true; } @@ -474,7 +480,7 @@ bool t_netstd_generator::print_const_value(ostream& out, string name, t_type* ty if (type->is_base_type()) { string v2 = render_const_value(out, name, type, value); - out << normalize_name(name) << " = " << v2 << ";" << endl; + out << name << " = " << v2 << ";" << endl; need_static_construction = false; } else if (type->is_enum()) @@ -552,7 +558,7 @@ string t_netstd_generator::render_const_value(ostream& out, string name, t_type* } else { - string t = tmp("tmp"); + string t = normalize_name(tmp("tmp")); print_const_value(out, t, type, value, true, true, true); render << t; } @@ -940,7 +946,7 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc { if (field_is_required((*m_iter))) { - print_const_value(out, "this." + prop_name(*m_iter), t, (*m_iter)->get_value(), true, true); + print_const_value(out, "this." + normalize_name(prop_name(*m_iter)), t, (*m_iter)->get_value(), true, true); } else { @@ -1456,14 +1462,14 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct // Let's define the class first start_netstd_namespace(out); - out << indent() << "public abstract partial class " << tunion->get_name() << " : TUnionBase" << endl; + out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << endl; out << indent() << "{" << endl; indent_up(); out << indent() << "public abstract global::System.Threading.Tasks.Task WriteAsync(TProtocol tProtocol, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << endl << indent() << "public readonly int Isset;" << endl << indent() << "public abstract object" << nullable_suffix() <<" Data { get; }" << endl - << indent() << "protected " << tunion->get_name() << "(int isset)" << endl + << indent() << "protected " << normalize_name(tunion->get_name()) << "(int isset)" << endl << indent() << "{" << endl; indent_up(); out << indent() << "Isset = isset;" << endl; @@ -1669,13 +1675,13 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun << endl; - out << indent() << "public class " << tfield->get_name() << " : " << tunion->get_name() << endl; + out << indent() << "public class " << normalize_name(tfield->get_name()) << " : " << normalize_name(tunion->get_name()) << endl; out << indent() << "{" << endl; indent_up(); out << indent() << "private readonly " << type_name(tfield->get_type()) << " _data;" << endl << indent() << "public override object" << nullable_suffix() <<" Data { get { return _data; } }" << endl - << indent() << "public " << tfield->get_name() << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << endl + << indent() << "public " << normalize_name(tfield->get_name()) << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << endl << indent() << "{" << endl; indent_up(); out << indent() << "this._data = data;" << endl; @@ -1683,13 +1689,13 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun out << indent() << "}" << endl; if( ! suppress_deepcopy) { - out << indent() << "public new " << tfield->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << endl; + out << indent() << "public new " << normalize_name(tfield->get_name()) << " " << DEEP_COPY_METHOD_NAME << "()" << endl; out << indent() << "{" << endl; indent_up(); bool needs_typecast = false; string suffix(""); string copy_op = get_deep_copy_method_call(tfield->get_type(), true, needs_typecast, suffix); - out << indent() << "return new " << tfield->get_name() << "(_data" << copy_op << ");" << endl; + out << indent() << "return new " << normalize_name(tfield->get_name()) << "(_data" << copy_op << ");" << endl; indent_down(); out << indent() << "}" << endl << endl; } diff --git a/configure.ac b/configure.ac index 2cd902d6c..6331acd4a 100644 --- a/configure.ac +++ b/configure.ac @@ -469,7 +469,7 @@ AX_THRIFT_LIB(netstd, [.NET Core], yes) if test "$with_netstd" = "yes"; then AC_PATH_PROG([DOTNETCORE], [dotnet]) if [[ -x "$DOTNETCORE" ]] ; then - AX_PROG_DOTNETCORE_VERSION( [3.1.0], have_netstd="yes", have_netstd="no") + AX_PROG_DOTNETCORE_VERSION( [7.0.0], have_netstd="yes", have_netstd="no") fi fi AM_CONDITIONAL(WITH_DOTNET, [test "$have_netstd" = "yes"]) diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index 0e29b3b78..aed36cdcb 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -20,14 +20,14 @@ Exe - net6.0 + net7.0 false true enable - + @@ -35,7 +35,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index d661f60f1..19065c6b6 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 Thrift.IntegrationTests Thrift.IntegrationTests 0.19.0.0 @@ -34,11 +34,11 @@ - - - - - + + + + + @@ -47,7 +47,7 @@ - + \ No newline at end of file diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 20f74e646..990b24051 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -21,7 +21,7 @@ 0.19.0 Thrift version $(ThriftVersion) - net6.0 + net7.0 $(ThriftVersion).0 Thrift.PublicInterfaces.Compile.Tests Thrift.PublicInterfaces.Compile.Tests @@ -37,11 +37,11 @@ - + - + diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 8a0e25db4..bae55ea5c 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -19,17 +19,17 @@ --> - net6.0 + net7.0 0.19.0.0 enable - - - - - + + + + + @@ -42,6 +42,6 @@ - + \ No newline at end of file diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 42f193204..760ffe4a0 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -19,7 +19,7 @@ --> - netstandard2.1;netstandard2.0;net6.0 + netstandard2.1;netstandard2.0;net6.0;net7.0 Thrift ApacheThrift true @@ -57,12 +57,12 @@ - - - + + + - + @@ -70,11 +70,11 @@ - + - + diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs index 8ad62aa14..66018b085 100644 --- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs @@ -32,13 +32,6 @@ using System.Diagnostics; namespace Thrift.Transport.Server { - [Obsolete("NamedPipeClientFlags is deprecated, use NamedPipeServerFlags instead.")] - [Flags] - public enum NamedPipeClientFlags { // bad name - None = 0x00, - OnlyLocalClients = 0x01 - }; - [Flags] public enum NamedPipeServerFlags { @@ -84,18 +77,6 @@ namespace Thrift.Transport.Server _numListenPipes = (byte)numListenPipes; } - [Obsolete("NamedPipeClientFlags is deprecated, use NamedPipeServerFlags instead.")] - public TNamedPipeServerTransport(string pipeAddress, TConfiguration config, NamedPipeClientFlags flags, int numListenPipes = 1) - : base(config) - { - if ((numListenPipes < 1) || (numListenPipes > 254)) - throw new ArgumentOutOfRangeException(nameof(numListenPipes), "Value must be in the range of [1..254]"); - - _pipeAddress = pipeAddress; - _onlyLocalClients = flags.HasFlag(NamedPipeClientFlags.OnlyLocalClients); - _numListenPipes = (byte)numListenPipes; - } - public override bool IsOpen() { return true; diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 69e130159..bd7d1ee18 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Client Client @@ -35,9 +35,9 @@ - + - + diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs index 1227a38bb..183cfb430 100644 --- a/test/netstd/Client/TestClient.cs +++ b/test/netstd/Client/TestClient.cs @@ -257,7 +257,7 @@ namespace ThriftTest trans = new TTlsSocketTransport(host, port, Configuration, 0, cert, (sender, certificate, chain, errors) => true, - null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12); + null, SslProtocols.Tls12); break; case TransportChoice.Socket: diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index e6b42e247..85c1ad4b0 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Server Server @@ -37,9 +37,9 @@ - + - + diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs index 1eb50306a..fdbaa9718 100644 --- a/test/netstd/Server/TestServer.cs +++ b/test/netstd/Server/TestServer.cs @@ -606,7 +606,7 @@ namespace ThriftTest trans = new TTlsServerSocketTransport(param.port, Configuration, cert, (sender, certificate, chain, errors) => true, - null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12); + null, SslProtocols.Tls12); break; case TransportChoice.Socket: diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index 0005c369c..c21b58d12 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Client Client @@ -32,7 +32,7 @@ - + diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 353811cd2..1e1193b1d 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 Interfaces Interfaces 0.19.0.0 @@ -34,7 +34,7 @@ - + diff --git a/tutorial/netstd/Server/Program.cs b/tutorial/netstd/Server/Program.cs index 29b21d073..01e7336c5 100644 --- a/tutorial/netstd/Server/Program.cs +++ b/tutorial/netstd/Server/Program.cs @@ -191,7 +191,7 @@ Sample: TServerTransport serverTransport = transport switch { Transport.Tcp => new TServerSocketTransport(9090, Configuration), - Transport.NamedPipe => new TNamedPipeServerTransport(".test", Configuration, NamedPipeClientFlags.None), + Transport.NamedPipe => new TNamedPipeServerTransport(".test", Configuration, NamedPipeServerFlags.None, 64), Transport.TcpTls => new TTlsServerSocketTransport(9090, Configuration, GetCertificate(), ClientCertValidator, LocalCertificateSelectionCallback), _ => throw new ArgumentException("unsupported value $transport", nameof(transport)), }; diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index b333c5284..193e3c37e 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Server Server @@ -40,6 +40,6 @@ - + -- cgit v1.2.1