From 3f22556a2ec5fbcd6fd06e21eb17a1f2e3a7ed16 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Sat, 28 Oct 2023 15:20:25 +0200 Subject: [PATCH] ci: adjust buildscript --- Server/Services/PacketDistributorService.cs | 11 +++++------ build/Build.cs | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Server/Services/PacketDistributorService.cs b/Server/Services/PacketDistributorService.cs index 65b3b51..da2d85c 100644 --- a/Server/Services/PacketDistributorService.cs +++ b/Server/Services/PacketDistributorService.cs @@ -95,10 +95,9 @@ public class PacketDistributorService : IHostedService var packetHandlersWithId = assembly.GetTypes().AsParallel().Where(t => t is { IsClass: true, IsAbstract: false } && t .GetInterfaces().Any(i => - i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>))).ToDictionary(type => - type.GetInterfaces().First(t => - t is { IsGenericType: true } && t.GetGenericTypeDefinition() == typeof(IPacketHandler<>)) - .GetGenericArguments().First().GetCustomAttribute().Code); + i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>))).ToDictionary(type => type.GetInterfaces().First(t => + t is { IsGenericType: true } && t.GetGenericTypeDefinition() == typeof(IPacketHandler<>)) + .GetGenericArguments().First().GetCustomAttribute().Code); if (packetHandlersWithId is not { Count: 0 }) { @@ -129,13 +128,13 @@ public class PacketDistributorService : IHostedService private void InvokePacketHandler(RawPacket item) { this.logger.PacketDequeued(item.Session.Id, item.OperationCode); - if (!this.deserializationMap.ContainsKey(item.OperationCode)) + if (!this.deserializationMap.TryGetValue(item.OperationCode, out var value)) { this.logger.PacketTypeNotFound(item.OperationCode); return; } - var packet = this.deserializationMap[item.OperationCode](item.MessageBody); + var packet = value(item.MessageBody); this.logger.PacketData(JsonConvert.SerializeObject(packet)); this.packetHandlersInstantiation[item.OperationCode].GetType().GetMethod(nameof(IPacketHandler.HandleAsync)) ?.Invoke(this.packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session }); diff --git a/build/Build.cs b/build/Build.cs index 1281d25..0beeef8 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -87,10 +87,9 @@ sealed class Build : NukeBuild .SetLogin(SonarToken) .SetServer(SonarHostUrl); var sonarScannerEndSettings = new SonarScannerEndSettings() - .SetProjectKey("wonderking_continuity_AYeecUUTs-PH__JrTRky") .SetLogin(SonarToken) .SetServer(SonarHostUrl); - var scannerBegin = SonarScannerTasks.SonarScannerBegin(sonarScannerSettings); + SonarScannerTasks.SonarScannerBegin(sonarScannerSettings); DotNetTasks.DotNetBuild(settings => settings.SetNoRestore(true)); SonarScannerTasks.SonarScannerEnd(sonarScannerEndSettings); });