THRIFT-5479 Add net 6 support
Client: netstd
Patch: Jens Geyer
diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj
index 1f87751..cf01951 100644
--- a/tutorial/netstd/Client/Client.csproj
+++ b/tutorial/netstd/Client/Client.csproj
@@ -19,7 +19,7 @@
   -->
 
   <PropertyGroup>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <LangVersion>9.0</LangVersion>
     <AssemblyName>Client</AssemblyName>
     <PackageId>Client</PackageId>
@@ -32,7 +32,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
   </ItemGroup>
 
   <ItemGroup>
diff --git a/tutorial/netstd/Client/Program.cs b/tutorial/netstd/Client/Program.cs
index 9c47450..f1c5236 100644
--- a/tutorial/netstd/Client/Program.cs
+++ b/tutorial/netstd/Client/Program.cs
@@ -39,10 +39,25 @@
 
 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<T> CreateLogger<T>() => LogFactory.CreateLogger<T>();
+    }
+
     public class Program
     {
-        private static readonly ServiceCollection ServiceCollection = new();
-        private static ILogger Logger;
+        private static readonly ILogger Logger = LoggingHelper.CreateLogger<Program>();
         private static readonly TConfiguration Configuration = null;  // new TConfiguration() if  needed
 
         private static void DisplayHelp()
@@ -86,47 +101,35 @@
         {
             args ??= Array.Empty<string>();
 
-            ServiceCollection.AddLogging(logging => ConfigureLogging(logging));
-            using (var serviceProvider = ServiceCollection.BuildServiceProvider())
+            if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase)))
             {
-                Logger = serviceProvider.GetService<ILoggerFactory>().CreateLogger(nameof(Client));
+                DisplayHelp();
+                return;
+            }
 
-                if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase)))
-                {
-                    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 @@
         {
             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 @@
                 }
                 catch (Exception ex)
                 {
-                    Logger.LogError(ex.ToString());
+                    Logger.LogError("{ex}",ex);
                 }
                 finally
                 {
@@ -319,7 +322,7 @@
             }
             catch (TApplicationException x)
             {
-                Logger.LogError(x.ToString());
+                Logger.LogError("{x}",x);
             }
         }
 
@@ -329,12 +332,12 @@
 
             // 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 @@
 
             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 @@
 
             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 989f6db..a288745 100644
--- a/tutorial/netstd/Interfaces/Interfaces.csproj
+++ b/tutorial/netstd/Interfaces/Interfaces.csproj
@@ -19,7 +19,7 @@
   -->
 
   <PropertyGroup>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <AssemblyName>Interfaces</AssemblyName>
     <PackageId>Interfaces</PackageId>
     <Version>0.16.0.0</Version>
@@ -34,7 +34,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="System.ServiceModel.Primitives" Version="4.8.1" />
+    <PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0" />
   </ItemGroup>
 
   <Target Name="PreBuild" BeforeTargets="_GenerateRestoreProjectSpec;Restore;Compile">
diff --git a/tutorial/netstd/Server/Program.cs b/tutorial/netstd/Server/Program.cs
index 80205d5..d9c9dbf 100644
--- a/tutorial/netstd/Server/Program.cs
+++ b/tutorial/netstd/Server/Program.cs
@@ -38,52 +38,54 @@
 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<T> CreateLogger<T>() => LogFactory.CreateLogger<T>();
+    }
+
     public class Program
     {
-        private static readonly ServiceCollection ServiceCollection = new();
-        private static ILogger Logger;
+        private static readonly ILogger Logger = LoggingHelper.CreateLogger<Program>();
         private static readonly TConfiguration Configuration = null;  // new TConfiguration() if  needed
 
         public static void Main(string[] args)
         {
             args ??= Array.Empty<string>();
 
-            ServiceCollection.AddLogging(logging => ConfigureLogging(logging));
-            using (var serviceProvider = ServiceCollection.BuildServiceProvider())
+            if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase)))
             {
-                Logger = serviceProvider.GetService<ILoggerFactory>().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();
-
-                    Logger.LogInformation("Press any key to stop...");
-
-                    Console.ReadLine();
-                    source.Cancel();
-                }
-
-                Logger.LogInformation("Server stopped");
+                DisplayHelp();
+                return;
             }
+
+            using (var source = new CancellationTokenSource())
+            {
+                RunAsync(args, source.Token).GetAwaiter().GetResult();
+
+                Logger.LogInformation("Press any key to stop...");
+
+                Console.ReadLine();
+                source.Cancel();
+            }
+
+            Logger.LogInformation("Server stopped");
         }
 
-        private static void ConfigureLogging(ILoggingBuilder logging)
-        {
-            logging.SetMinimumLevel(LogLevel.Trace);
-            logging.AddConsole();
-            logging.AddDebug();
-        }
 
         private static void DisplayHelp()
         {
@@ -226,15 +228,12 @@
             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<ILoggerFactory>();
+                    "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 @@
                     outputTransportFactory: transportFactory,
                     inputProtocolFactory: protocolFactory,
                     outputProtocolFactory: protocolFactory,
-                    logger: loggerFactory.CreateLogger<TSimpleAsyncServer>());
+                    logger: LoggingHelper.CreateLogger<TSimpleAsyncServer >());
 
                 Logger.LogInformation("Starting the server...");
 
@@ -251,7 +250,7 @@
             }
             catch (Exception x)
             {
-                Logger.LogInformation(x.ToString());
+                Logger.LogInformation("{x}",x);
             }
         }
 
@@ -327,7 +326,7 @@
                     .UseUrls("http://localhost:9090")
                     .UseContentRoot(Directory.GetCurrentDirectory())
                     .UseStartup<Startup>()
-                    .ConfigureLogging((ctx,logging) => ConfigureLogging(logging))
+                    .ConfigureLogging((ctx,logging) => LoggingHelper.ConfigureLogging(logging))
                     .Build();
 
                 Logger.LogTrace("test");
@@ -379,7 +378,7 @@
             public async Task<SharedStruct> 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 @@
 
             public async Task<int> 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<int> 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 @@
         {
             public async Task<SharedStruct> 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 e5e54a5..6bee63f 100644
--- a/tutorial/netstd/Server/Server.csproj
+++ b/tutorial/netstd/Server/Server.csproj
@@ -19,7 +19,7 @@
   -->
 
   <PropertyGroup>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <LangVersion>9.0</LangVersion>
     <AssemblyName>Server</AssemblyName>
     <PackageId>Server</PackageId>
@@ -40,6 +40,6 @@
     <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
     <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
     <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
-    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
   </ItemGroup>
 </Project>