From 01131274d847ff231aea7c4b86b726cdfcfa98ab Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Mon, 29 Jul 2024 18:12:43 +0900 Subject: [PATCH] Adopt to .NET 8 --- .../Controller/DFrameControllerLogger.cs | 2 +- .../DFrame.Controller.csproj | 2 +- src/DFrame.Controller/RunDFrameController.cs | 61 +++++++++---------- src/DFrame.RestSdk/DFrame.RestSdk.csproj | 2 +- .../Runtime/DFrameWorkloadCollection.cs | 2 - src/DFrame.Worker/DFrame.Worker.csproj | 2 +- src/DFrame/DFrame.csproj | 2 +- src/DFrame/DFrameApp.cs | 4 ++ 8 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/DFrame.Controller/Controller/DFrameControllerLogger.cs b/src/DFrame.Controller/Controller/DFrameControllerLogger.cs index 15bcd25..8221731 100644 --- a/src/DFrame.Controller/Controller/DFrameControllerLogger.cs +++ b/src/DFrame.Controller/Controller/DFrameControllerLogger.cs @@ -51,7 +51,7 @@ public DFrameControllerLogger(DFrameControllerLogBuffer router) this.router = router; } - public IDisposable BeginScope(TState state) + IDisposable ILogger.BeginScope(TState state) { return NilDisposable.Instance; } diff --git a/src/DFrame.Controller/DFrame.Controller.csproj b/src/DFrame.Controller/DFrame.Controller.csproj index 1b63a92..84c9e89 100644 --- a/src/DFrame.Controller/DFrame.Controller.csproj +++ b/src/DFrame.Controller/DFrame.Controller.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net8.0 Library enable DFrame diff --git a/src/DFrame.Controller/RunDFrameController.cs b/src/DFrame.Controller/RunDFrameController.cs index 93bdaa1..bb5607f 100644 --- a/src/DFrame.Controller/RunDFrameController.cs +++ b/src/DFrame.Controller/RunDFrameController.cs @@ -34,40 +34,39 @@ public static Task RunDFrameControllerAsync(this WebApplicationBuilder appBuilde static async Task RunDFrameControllerAsync(WebApplicationBuilder appBuilder, DFrameControllerOptions options, Action configureOptions) { - appBuilder.WebHost.ConfigureServices((WebHostBuilderContext ctx, IServiceCollection services) => + appBuilder.Services.AddGrpc(); + appBuilder.Services.AddMagicOnion(x => { - services.AddGrpc(); - services.AddMagicOnion(x => + // Should use same options between DFrame.Controller(this) and DFrame.Worker + x.MessageSerializer = MessagePackMagicOnionSerializerProvider.Default; + }); + appBuilder.Services.AddSingleton(); + + appBuilder.Services.AddRazorPages() + .ConfigureApplicationPartManager(manager => { - // Should use same options between DFrame.Controller(this) and DFrame.Worker - x.MessageSerializer = MessagePackMagicOnionSerializerProvider.Default; + // import libraries razor pages + var assembly = typeof(DFrameControllerWebApplicationBuilderExtensions).Assembly; + var assemblyPart = new CompiledRazorAssemblyPart(assembly); + manager.ApplicationParts.Add(assemblyPart); }); - services.AddSingleton(); - - services.AddRazorPages() - .ConfigureApplicationPartManager(manager => - { - // import libraries razor pages - var assembly = typeof(DFrameControllerWebApplicationBuilderExtensions).Assembly; - var assemblyPart = new CompiledRazorAssemblyPart(assembly); - manager.ApplicationParts.Add(assemblyPart); - }); - - services.AddServerSideBlazor(); - - // DFrame Options - services.TryAddSingleton(); - services.TryAddSingleton(); - services.AddSingleton(); - services.AddScoped(); - configureOptions(ctx, options); - services.AddSingleton(options); - - // If user sets custom provdier, use it. - services.TryAddSingleton(); - - services.AddMessagePipe(); - }); + + appBuilder.Services.AddServerSideBlazor(); + + // DFrame Options + appBuilder.Services.TryAddSingleton(); + appBuilder.Services.TryAddSingleton(); + appBuilder.Services.AddSingleton(); + appBuilder.Services.AddScoped(); +#pragma warning disable ASP0012 // Suggest using builder.Services over Host.ConfigureServices or WebHost.ConfigureServices + appBuilder.WebHost.ConfigureServices((ctx, services) => configureOptions(ctx, options)); +#pragma warning restore ASP0012 // Suggest using builder.Services over Host.ConfigureServices or WebHost.ConfigureServices + appBuilder.Services.AddSingleton(options); + + // If user sets custom provider, use it. + appBuilder.Services.TryAddSingleton(); + + appBuilder.Services.AddMessagePipe(); var app = appBuilder.Build(); diff --git a/src/DFrame.RestSdk/DFrame.RestSdk.csproj b/src/DFrame.RestSdk/DFrame.RestSdk.csproj index 2db6e69..f3f32e6 100644 --- a/src/DFrame.RestSdk/DFrame.RestSdk.csproj +++ b/src/DFrame.RestSdk/DFrame.RestSdk.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 enable enable diff --git a/src/DFrame.Unity/Assets/Plugins/DFrame/Runtime/DFrameWorkloadCollection.cs b/src/DFrame.Unity/Assets/Plugins/DFrame/Runtime/DFrameWorkloadCollection.cs index ae64991..16585ed 100644 --- a/src/DFrame.Unity/Assets/Plugins/DFrame/Runtime/DFrameWorkloadCollection.cs +++ b/src/DFrame.Unity/Assets/Plugins/DFrame/Runtime/DFrameWorkloadCollection.cs @@ -63,9 +63,7 @@ public static DFrameWorkloadCollection FromAssemblies(Assembly[] searchAssemblie public IEnumerable All => dframeTypes.Values; -#pragma warning disable CS0436 public bool TryGetWorkload(string workloadName, [NotNullWhen(true)] out DFrameWorkloadTypeInfo? workload) -#pragma warning restore CS0436 { return dframeTypes.TryGetValue(workloadName, out workload); } diff --git a/src/DFrame.Worker/DFrame.Worker.csproj b/src/DFrame.Worker/DFrame.Worker.csproj index 32ed833..02bd4c3 100644 --- a/src/DFrame.Worker/DFrame.Worker.csproj +++ b/src/DFrame.Worker/DFrame.Worker.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net8.0 disable enable diff --git a/src/DFrame/DFrame.csproj b/src/DFrame/DFrame.csproj index cb1cd08..a5220eb 100644 --- a/src/DFrame/DFrame.csproj +++ b/src/DFrame/DFrame.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net8.0 enable enable DFrame diff --git a/src/DFrame/DFrameApp.cs b/src/DFrame/DFrameApp.cs index 6e1ad1b..5452bf2 100644 --- a/src/DFrame/DFrameApp.cs +++ b/src/DFrame/DFrameApp.cs @@ -27,6 +27,10 @@ public static DFrameAppBuilder CreateBuilder(int portWeb, int portListenWorker, } } +#pragma warning disable ASP0011 // Suggest using builder.Logging instead of ConfigureLogging (https://aka.ms/aspnet/analyzers) +#pragma warning disable ASP0012 // Suggest using builder.Services instead of ConfigureServices (https://aka.ms/aspnet/analyzers) +#pragma warning disable ASP0013 // Suggest using WebApplicationBuilder.Configuration instead of ConfigureAppConfiguration (https://aka.ms/aspnet/analyzers) + public class DFrameAppBuilder { Action configureController;