From 4c7b9fd38ad614dbf37c37e45569790b44868458 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 4 Dec 2021 22:48:37 +0100 Subject: THRIFT-5479 Add net 6 support 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/ubuntu-bionic/Dockerfile | 8 +- build/docker/ubuntu-disco/Dockerfile | 8 +- build/docker/ubuntu-xenial/Dockerfile | 8 +- debian/control | 4 +- doc/install/debian.md | 2 +- .../Thrift.Benchmarks/Thrift.Benchmarks.csproj | 8 +- .../Thrift.IntegrationTests.csproj | 15 ++-- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 23 +++--- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 14 ++-- lib/netstd/Thrift/Collections/THashSet.cs | 2 +- lib/netstd/Thrift/Thrift.csproj | 14 ++-- .../Transport/Server/TNamedPipeServerTransport.cs | 2 +- test/netstd/Client/Client.csproj | 6 +- test/netstd/Server/Server.csproj | 6 +- tutorial/netstd/Client/Client.csproj | 4 +- tutorial/netstd/Client/Program.cs | 87 +++++++++++----------- tutorial/netstd/Interfaces/Interfaces.csproj | 4 +- tutorial/netstd/Server/Program.cs | 85 +++++++++++---------- tutorial/netstd/Server/Server.csproj | 4 +- 22 files changed, 167 insertions(+), 155 deletions(-) diff --git a/build/docker/README.md b/build/docker/README.md index 127de8e1e..87d58bc27 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 | 11.0.3 | | | 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 | 5.0 | 5.0 | | +| netstd | 6.0 | 6.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 541223ca4..628b6268e 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-5.0 \ -# dotnet-runtime-5.0 \ -# aspnetcore-runtime-5.0 \ -# dotnet-apphost-pack-5.0 +# dotnet-sdk-6.0 \ +# dotnet-runtime-6.0 \ +# aspnetcore-runtime-6.0 \ +# dotnet-apphost-pack-6.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 282429ad7..80682657b 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-5.0 \ - dotnet-runtime-5.0 \ - aspnetcore-runtime-5.0 \ - dotnet-apphost-pack-5.0 + dotnet-sdk-6.0 \ + dotnet-runtime-6.0 \ + aspnetcore-runtime-6.0 \ + dotnet-apphost-pack-6.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index bd82225ea..ac51207ed 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/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-5.0 \ - dotnet-runtime-5.0 \ - aspnetcore-runtime-5.0 \ - dotnet-apphost-pack-5.0 + dotnet-sdk-6.0 \ + dotnet-runtime-6.0 \ + aspnetcore-runtime-6.0 \ + dotnet-apphost-pack-6.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/ubuntu-disco/Dockerfile b/build/docker/ubuntu-disco/Dockerfile index 6b35915f2..9d6996d3f 100644 --- a/build/docker/ubuntu-disco/Dockerfile +++ b/build/docker/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-5.0 \ - dotnet-runtime-5.0 \ - aspnetcore-runtime-5.0 \ - dotnet-apphost-pack-5.0 + dotnet-sdk-6.0 \ + dotnet-runtime-6.0 \ + aspnetcore-runtime-6.0 \ + dotnet-apphost-pack-6.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/ubuntu-xenial/Dockerfile b/build/docker/ubuntu-xenial/Dockerfile index 1d78a28b2..9a89b7007 100644 --- a/build/docker/ubuntu-xenial/Dockerfile +++ b/build/docker/ubuntu-xenial/Dockerfile @@ -113,10 +113,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-5.0 \ - dotnet-runtime-5.0 \ - aspnetcore-runtime-5.0 \ - dotnet-apphost-pack-5.0 + dotnet-sdk-6.0 \ + dotnet-runtime-6.0 \ + aspnetcore-runtime-6.0 \ + dotnet-apphost-pack-6.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/debian/control b/debian/control index f69f73b34..0910a94a7 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: thrift Section: devel Priority: extra -Build-Depends: dotnet-runtime-5.0, dotnet-sdk-5.0, debhelper (>= 9), build-essential, python-dev, ant, +Build-Depends: dotnet-runtime-6.0, dotnet-sdk-6.0, debhelper (>= 9), build-essential, python-dev, ant, erlang-base, ruby-dev | ruby1.9.1-dev, ruby-bundler ,autoconf, automake, pkg-config, libtool, bison, flex, libboost-dev | libboost1.56-dev | libboost1.63-all-dev, python-all, python-setuptools, python-all-dev, python-all-dbg, @@ -129,7 +129,7 @@ Description: Java bindings for Thrift Package: libthrift-netstd Architecture: all Section: netstd -Depends: dotnet-runtime-5.0, ${misc:Depends} +Depends: dotnet-runtime-6.0, ${misc:Depends} Description: NET Standard bindings for Thrift Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to diff --git a/doc/install/debian.md b/doc/install/debian.md index 92d68e9ce..f1edce5c8 100644 --- a/doc/install/debian.md +++ b/doc/install/debian.md @@ -33,7 +33,7 @@ If you would like to build Apache Thrift libraries for other programming languag * Erlang * erlang-base erlang-eunit erlang-dev rebar * NetStd - * apt-transport-https dotnet-sdk-5.0 aspnetcore-runtime-5.0 + * apt-transport-https dotnet-sdk-6.0 aspnetcore-runtime-6.0 * Thrift Compiler for Windows * mingw-w64 mingw-w64-x86-64-dev nsis * Rust diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index d55074f39..633850e0a 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -20,17 +20,21 @@ Exe - net5.0 + net6.0 false true - + + + + + diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index b47017e96..6d473e44f 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -19,7 +19,7 @@ --> - net5.0 + net6.0 Thrift.IntegrationTests Thrift.IntegrationTests 0.16.0.0 @@ -33,11 +33,11 @@ - - - - - + + + + + @@ -45,5 +45,8 @@ + + + \ 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 126635d41..15112747f 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.16.0 Thrift version $(ThriftVersion) - net5.0 + net6.0 $(ThriftVersion).0 Thrift.PublicInterfaces.Compile.Tests Thrift.PublicInterfaces.Compile.Tests @@ -36,7 +36,11 @@ - + + + + + @@ -55,22 +59,13 @@ - + - - + + diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index f1dc73155..18fce0177 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -19,15 +19,15 @@ --> - net5.0 + net6.0 0.16.0.0 - - - - + + + + @@ -39,4 +39,8 @@ + + + + \ No newline at end of file diff --git a/lib/netstd/Thrift/Collections/THashSet.cs b/lib/netstd/Thrift/Collections/THashSet.cs index 25fcf10bc..1c060e5a7 100644 --- a/lib/netstd/Thrift/Collections/THashSet.cs +++ b/lib/netstd/Thrift/Collections/THashSet.cs @@ -32,7 +32,7 @@ namespace Thrift.Collections public THashSet(int capacity) { - #if NET5_0 + #if NET5_0_OR_GREATER Items = new HashSet(capacity); #elif NETFRAMEWORK || NETSTANDARD Items = new HashSet(/*capacity not supported*/); diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 2454ffd3e..16e64a172 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -19,7 +19,7 @@ --> - netstandard2.1;netstandard2.0;net5.0 + netstandard2.1;netstandard2.0;net5.0;net6.0 Thrift ApacheThrift true @@ -56,18 +56,22 @@ - - - + + + - + + + + + $(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension) diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs index 35a037da7..e985a298a 100644 --- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs @@ -329,7 +329,7 @@ namespace Thrift.Transport.Server var nBytes = Math.Min(15 * 4096, length); // 16 would exceed the limit while (nBytes > 0) { -#if NET5_0 +#if NET5_0_OR_GREATER await PipeStream.WriteAsync(buffer.AsMemory(offset, nBytes), cancellationToken); #else await PipeStream.WriteAsync(buffer, offset, nBytes, cancellationToken); diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index a33143613..c7d53493e 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -19,7 +19,7 @@ --> - net5.0 + net6.0 9.0 Client Client @@ -34,9 +34,9 @@ - + - + diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index f5ddc0f72..7d5eb1742 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -19,7 +19,7 @@ --> - net5.0 + net6.0 9.0 Server Server @@ -36,9 +36,9 @@ - + - + diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index 1f877517e..cf01951be 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -19,7 +19,7 @@ --> - net5.0 + net6.0 9.0 Client Client @@ -32,7 +32,7 @@ - + diff --git a/tutorial/netstd/Client/Program.cs b/tutorial/netstd/Client/Program.cs index 9c47450e7..f1c5236e1 100644 --- a/tutorial/netstd/Client/Program.cs +++ b/tutorial/netstd/Client/Program.cs @@ -39,10 +39,25 @@ using shared; namespace Client { + public static class LoggingHelper + { + public static ILoggerFactory LogFactory { get; } = LoggerFactory.Create(builder => { + ConfigureLogging(builder); + }); + + public static void ConfigureLogging(ILoggingBuilder logging) + { + logging.SetMinimumLevel(LogLevel.Trace); + logging.AddConsole(); + logging.AddDebug(); + } + + public static ILogger CreateLogger() => LogFactory.CreateLogger(); + } + public class Program { - private static readonly ServiceCollection ServiceCollection = new(); - private static ILogger Logger; + private static readonly ILogger Logger = LoggingHelper.CreateLogger(); private static readonly TConfiguration Configuration = null; // new TConfiguration() if needed private static void DisplayHelp() @@ -86,47 +101,35 @@ Sample: { args ??= Array.Empty(); - ServiceCollection.AddLogging(logging => ConfigureLogging(logging)); - using (var serviceProvider = ServiceCollection.BuildServiceProvider()) + if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase))) { - Logger = serviceProvider.GetService().CreateLogger(nameof(Client)); - - if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase))) - { - DisplayHelp(); - return; - } + DisplayHelp(); + return; + } - Logger.LogInformation("Starting client..."); + Logger.LogInformation("Starting client..."); - using (var source = new CancellationTokenSource()) - { - RunAsync(args, source.Token).GetAwaiter().GetResult(); - } + using (var source = new CancellationTokenSource()) + { + RunAsync(args, source.Token).GetAwaiter().GetResult(); } } - private static void ConfigureLogging(ILoggingBuilder logging) - { - logging.SetMinimumLevel(LogLevel.Trace); - logging.AddConsole(); - logging.AddDebug(); - } - + private static async Task RunAsync(string[] args, CancellationToken cancellationToken) { var numClients = GetNumberOfClients(args); - Logger.LogInformation($"Selected # of clients: {numClients}"); + Logger.LogInformation("Selected # of clients: {numClients}", numClients); var transport = GetTransport(args); - Logger.LogInformation($"Selected client transport: {transport}"); + Logger.LogInformation("Selected client transport: {transport}", transport); var protocol = MakeProtocol( args, MakeTransport(args)); - Logger.LogInformation($"Selected client protocol: {GetProtocol(args)}"); + Logger.LogInformation("Selected client protocol: {GetProtocol(args)}", GetProtocol(args)); var mplex = GetMultiplex(args); - Logger.LogInformation("Multiplex " + (mplex ? "yes" : "no")); + Logger.LogInformation("Multiplex {mplex}", mplex); var tasks = new Task[numClients]; for (int i = 0; i < numClients; i++) @@ -240,7 +243,7 @@ Sample: { var numClients = args.FirstOrDefault(x => x.StartsWith("-mc"))?.Split(':')?[1]; - Logger.LogInformation($"Selected # of clients: {numClients}"); + Logger.LogInformation("Selected # of clients: {numClients}", numClients); if (int.TryParse(numClients, out int c) && (0 < c) && (c <= 100)) return c; @@ -310,7 +313,7 @@ Sample: } catch (Exception ex) { - Logger.LogError(ex.ToString()); + Logger.LogError("{ex}",ex); } finally { @@ -319,7 +322,7 @@ Sample: } catch (TApplicationException x) { - Logger.LogError(x.ToString()); + Logger.LogError("{x}",x); } } @@ -329,12 +332,12 @@ Sample: // Async version - Logger.LogInformation($"{client.ClientId} Ping()"); + Logger.LogInformation("{client.ClientId} Ping()", client.ClientId); await client.ping(cancellationToken); - Logger.LogInformation($"{client.ClientId} Add(1,1)"); + Logger.LogInformation("{client.ClientId} Add(1,1)", client.ClientId); var sum = await client.add(1, 1, cancellationToken); - Logger.LogInformation($"{client.ClientId} Add(1,1)={sum}"); + Logger.LogInformation("{client.ClientId} Add(1,1)={sum}", client.ClientId, sum); var work = new Work { @@ -345,13 +348,13 @@ Sample: try { - Logger.LogInformation($"{client.ClientId} Calculate(1)"); + Logger.LogInformation("{client.ClientId} Calculate(1)", client.ClientId); await client.calculate(1, work, cancellationToken); - Logger.LogInformation($"{client.ClientId} Whoa we can divide by 0"); + Logger.LogInformation("{client.ClientId} Whoa we can divide by 0", client.ClientId); } catch (InvalidOperation io) { - Logger.LogInformation($"{client.ClientId} Invalid operation: " + io); + Logger.LogInformation("{client.ClientId} Invalid operation: {io}", client.ClientId, io); } work.Op = Operation.SUBTRACT; @@ -360,20 +363,20 @@ Sample: try { - Logger.LogInformation($"{client.ClientId} Calculate(1)"); + Logger.LogInformation("{client.ClientId} Calculate(1)", client.ClientId); var diff = await client.calculate(1, work, cancellationToken); - Logger.LogInformation($"{client.ClientId} 15-10={diff}"); + Logger.LogInformation("{client.ClientId} 15-10={diff}", client.ClientId, diff); } catch (InvalidOperation io) { - Logger.LogInformation($"{client.ClientId} Invalid operation: " + io); + Logger.LogInformation("{client.ClientId} Invalid operation: {io}", client.ClientId, io); } - Logger.LogInformation($"{client.ClientId} GetStruct(1)"); + Logger.LogInformation("{client.ClientId} GetStruct(1)", client.ClientId); var log = await client.getStruct(1, cancellationToken); - Logger.LogInformation($"{client.ClientId} Check log: {log.Value}"); + Logger.LogInformation("{client.ClientId} Check log: {log.Value}", client.ClientId, log.Value); - Logger.LogInformation($"{client.ClientId} Zip() with delay 100mc on server side"); + Logger.LogInformation("{client.ClientId} Zip() with delay 100mc on server side", client.ClientId); await client.zip(cancellationToken); } diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 989f6db40..a28874585 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -19,7 +19,7 @@ --> - net5.0 + net6.0 Interfaces Interfaces 0.16.0.0 @@ -34,7 +34,7 @@ - + diff --git a/tutorial/netstd/Server/Program.cs b/tutorial/netstd/Server/Program.cs index 80205d54f..d9c9dbf12 100644 --- a/tutorial/netstd/Server/Program.cs +++ b/tutorial/netstd/Server/Program.cs @@ -38,53 +38,55 @@ using shared; using Thrift.Processor; using System.Diagnostics; -#pragma warning disable IDE0063 // using #pragma warning disable IDE0057 // substr namespace Server { + public static class LoggingHelper + { + public static ILoggerFactory LogFactory { get; } = LoggerFactory.Create(builder => { + ConfigureLogging(builder); + }); + + public static void ConfigureLogging(ILoggingBuilder logging) + { + logging.SetMinimumLevel(LogLevel.Trace); + logging.AddConsole(); + logging.AddDebug(); + } + + public static ILogger CreateLogger() => LogFactory.CreateLogger(); + } + public class Program { - private static readonly ServiceCollection ServiceCollection = new(); - private static ILogger Logger; + private static readonly ILogger Logger = LoggingHelper.CreateLogger(); private static readonly TConfiguration Configuration = null; // new TConfiguration() if needed public static void Main(string[] args) { args ??= Array.Empty(); - ServiceCollection.AddLogging(logging => ConfigureLogging(logging)); - using (var serviceProvider = ServiceCollection.BuildServiceProvider()) + if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase))) { - Logger = serviceProvider.GetService().CreateLogger(nameof(Server)); - - if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase))) - { - DisplayHelp(); - return; - } - - using (var source = new CancellationTokenSource()) - { - RunAsync(args, source.Token).GetAwaiter().GetResult(); + DisplayHelp(); + return; + } - Logger.LogInformation("Press any key to stop..."); + using (var source = new CancellationTokenSource()) + { + RunAsync(args, source.Token).GetAwaiter().GetResult(); - Console.ReadLine(); - source.Cancel(); - } + Logger.LogInformation("Press any key to stop..."); - Logger.LogInformation("Server stopped"); + Console.ReadLine(); + source.Cancel(); } - } - private static void ConfigureLogging(ILoggingBuilder logging) - { - logging.SetMinimumLevel(LogLevel.Trace); - logging.AddConsole(); - logging.AddDebug(); + Logger.LogInformation("Server stopped"); } + private static void DisplayHelp() { Logger.LogInformation(@" @@ -226,15 +228,12 @@ Sample: try { Logger.LogInformation( - string.Format( - "TSimpleAsyncServer with \n{0} transport\n{1} buffering\nmultiplex = {2}\n{3} protocol", - transport, - buffering, - multiplex ? "yes" : "no", - protocol - )); - - var loggerFactory = ServiceCollection.BuildServiceProvider().GetService(); + "TSimpleAsyncServer with \n{transport} transport\n{buffering} buffering\nmultiplex = {multiplex}\n{protocol} protocol", + transport, + buffering, + multiplex ? "yes" : "no", + protocol + ); var server = new TSimpleAsyncServer( itProcessorFactory: new TSingletonProcessorFactory(processor), @@ -243,7 +242,7 @@ Sample: outputTransportFactory: transportFactory, inputProtocolFactory: protocolFactory, outputProtocolFactory: protocolFactory, - logger: loggerFactory.CreateLogger()); + logger: LoggingHelper.CreateLogger()); Logger.LogInformation("Starting the server..."); @@ -251,7 +250,7 @@ Sample: } catch (Exception x) { - Logger.LogInformation(x.ToString()); + Logger.LogInformation("{x}",x); } } @@ -327,7 +326,7 @@ Sample: .UseUrls("http://localhost:9090") .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() - .ConfigureLogging((ctx,logging) => ConfigureLogging(logging)) + .ConfigureLogging((ctx,logging) => LoggingHelper.ConfigureLogging(logging)) .Build(); Logger.LogTrace("test"); @@ -379,7 +378,7 @@ Sample: public async Task getStruct(int key, CancellationToken cancellationToken) { - Logger.LogInformation("GetStruct({0})", key); + Logger.LogInformation("GetStruct({key})", key); return await Task.FromResult(_log[key]); } @@ -391,13 +390,13 @@ Sample: public async Task add(int num1, int num2, CancellationToken cancellationToken) { - Logger.LogInformation($"Add({num1},{num2})"); + Logger.LogInformation("Add({num1},{num2})", num1, num2); return await Task.FromResult(num1 + num2); } public async Task calculate(int logid, Work w, CancellationToken cancellationToken) { - Logger.LogInformation($"Calculate({logid}, [{w.Op},{w.Num1},{w.Num2}])"); + Logger.LogInformation("Calculate({logid}, [{w.Op},{w.Num1},{w.Num2}])", logid, w.Op, w.Num1, w.Num2); int val; switch (w.Op) @@ -462,7 +461,7 @@ Sample: { public async Task getStruct(int key, CancellationToken cancellationToken) { - Logger.LogInformation("GetStruct({0})", key); + Logger.LogInformation("GetStruct({key})", key); return await Task.FromResult(new SharedStruct() { Key = key, diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index e5e54a5b1..6bee63fc3 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -19,7 +19,7 @@ --> - net5.0 + net6.0 9.0 Server Server @@ -40,6 +40,6 @@ - + -- cgit v1.2.1