From 0ba517436efc327d1e10120f39c0594d759ea90e Mon Sep 17 00:00:00 2001 From: chompDev <27521899+chompDev@users.noreply.github.com> Date: Fri, 18 Jul 2025 15:21:55 +0000 Subject: [PATCH] .NET Format Style Fixes --- .../Migrations/ThreeTenToThreeEleven.cs | 24 ++++----- SPTarkov.Server/Program.cs | 54 +++++++++++-------- .../Services/SptServerBackgroundService.cs | 11 +++- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Migration/Migrations/ThreeTenToThreeEleven.cs b/Libraries/SPTarkov.Server.Core/Migration/Migrations/ThreeTenToThreeEleven.cs index 4d4b1097..eafb8e55 100644 --- a/Libraries/SPTarkov.Server.Core/Migration/Migrations/ThreeTenToThreeEleven.cs +++ b/Libraries/SPTarkov.Server.Core/Migration/Migrations/ThreeTenToThreeEleven.cs @@ -85,9 +85,9 @@ namespace SPTarkov.Server.Core.Migration.Migrations ); //Directly injecting CreateProfileService causes a circular dependency which I can't be bothered to fix just for this - (serviceProvider - .GetService(typeof(CreateProfileService)) as CreateProfileService)! - .AddMissingInternalContainersToProfile(profile.CharacterData.PmcData); + ( + serviceProvider.GetService(typeof(CreateProfileService)) as CreateProfileService + )!.AddMissingInternalContainersToProfile(profile.CharacterData.PmcData); } if (profile.CharacterData.PmcData.Hideout.Customization is null) @@ -135,15 +135,15 @@ namespace SPTarkov.Server.Core.Migration.Migrations .ToList(); //Directly injecting RewardHelper causes a circular dependency which I can't be bothered to fix just for this - (serviceProvider - .GetService(typeof(RewardHelper)) as RewardHelper)! - .ApplyRewards( - filteredRewards, - CustomisationSource.ACHIEVEMENT, - profile, - profile.CharacterData.PmcData, - achievementId - ); + ( + serviceProvider.GetService(typeof(RewardHelper)) as RewardHelper + )!.ApplyRewards( + filteredRewards, + CustomisationSource.ACHIEVEMENT, + profile, + profile.CharacterData.PmcData, + achievementId + ); } } diff --git a/SPTarkov.Server/Program.cs b/SPTarkov.Server/Program.cs index 0bb1500c..3b9d4f4a 100644 --- a/SPTarkov.Server/Program.cs +++ b/SPTarkov.Server/Program.cs @@ -77,7 +77,9 @@ public static class Program ConfigureWebApp(app); // In case of exceptions we snatch a Server logger - var serverExceptionLogger = app.Services.GetService()!.CreateLogger("Server"); + var serverExceptionLogger = app + .Services.GetService()! + .CreateLogger("Server"); // We need any logger instance to use as a finalizer when the app closes var loggerFinalizer = app.Services.GetService>()!; try @@ -103,35 +105,41 @@ public static class Program new WebSocketOptions { // Every minute a heartbeat is sent to keep the connection alive. - KeepAliveInterval = TimeSpan.FromSeconds(60) + KeepAliveInterval = TimeSpan.FromSeconds(60), + } + ); + app.Use( + async (HttpContext context, RequestDelegate _) => + { + await context.RequestServices.GetService()!.HandleRequest(context); } ); - app.Use(async (HttpContext context, RequestDelegate _) => - { - await context.RequestServices.GetService()!.HandleRequest(context); - }); } private static void ConfigureKestrel(WebApplicationBuilder builder) { - builder.WebHost.ConfigureKestrel((_, options) => - { - var httpConfig = options.ApplicationServices.GetService()?.GetConfig()!; - var certHelper = options.ApplicationServices.GetService()!; - options.Listen( - IPAddress.Parse(httpConfig.Ip), - httpConfig.Port, - listenOptions => - { - listenOptions.UseHttps(opts => + builder.WebHost.ConfigureKestrel( + (_, options) => + { + var httpConfig = options + .ApplicationServices.GetService() + ?.GetConfig()!; + var certHelper = options.ApplicationServices.GetService()!; + options.Listen( + IPAddress.Parse(httpConfig.Ip), + httpConfig.Port, + listenOptions => { - opts.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; - opts.ServerCertificate = certHelper.LoadOrGenerateCertificatePfx(); - opts.ClientCertificateMode = ClientCertificateMode.NoCertificate; - }); - } - ); - }); + listenOptions.UseHttps(opts => + { + opts.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; + opts.ServerCertificate = certHelper.LoadOrGenerateCertificatePfx(); + opts.ClientCertificateMode = ClientCertificateMode.NoCertificate; + }); + } + ); + } + ); } private static WebApplicationBuilder CreateNewHostBuilder(string[]? args = null) diff --git a/SPTarkov.Server/Services/SptServerBackgroundService.cs b/SPTarkov.Server/Services/SptServerBackgroundService.cs index c5b65fe2..b5b03369 100644 --- a/SPTarkov.Server/Services/SptServerBackgroundService.cs +++ b/SPTarkov.Server/Services/SptServerBackgroundService.cs @@ -5,7 +5,11 @@ using SPTarkov.Server.Core.Utils; namespace SPTarkov.Server.Services; -public class SptServerBackgroundService(IReadOnlyList loadedMods, BundleLoader bundleLoader, App app) : BackgroundService +public class SptServerBackgroundService( + IReadOnlyList loadedMods, + BundleLoader bundleLoader, + App app +) : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { @@ -16,7 +20,10 @@ public class SptServerBackgroundService(IReadOnlyList loadedMods, Bundle if (mod.ModMetadata?.IsBundleMod == true) { // Convert to relative path - var relativeModPath = Path.GetRelativePath(Directory.GetCurrentDirectory(), mod.Directory) + var relativeModPath = Path.GetRelativePath( + Directory.GetCurrentDirectory(), + mod.Directory + ) .Replace('\\', '/'); bundleLoader.AddBundles(relativeModPath);