From 2da96d8d522ae8ae8eda6035438957adc5f73873 Mon Sep 17 00:00:00 2001 From: faketuna Date: Sun, 24 Aug 2025 02:15:56 +0900 Subject: [PATCH] add: add ZLinq for optimized Linq operation --- .github/workflows/deploy.yml | 2 ++ MapChooserSharp/MapChooserSharp.cs | 1 + MapChooserSharp/MapChooserSharp.csproj | 5 +++++ MapChooserSharp/Modules/MapConfig/McsMapConfigProvider.cs | 1 + MapChooserSharp/Modules/MapCycle/McsMapCycleCommands.cs | 1 + .../Modules/MapCycle/McsMapCycleExtendVoteController.cs | 1 + .../MapCycle/Services/McsMapConfigExecutionService.cs | 5 +++-- MapChooserSharp/Modules/MapVote/McsMapVoteController.cs | 1 + MapChooserSharp/Modules/MapVote/McsMapVoteSoundPlayer.cs | 1 + .../Repositories/McsGroupInformationRepository.cs | 1 + .../McsDatabase/Repositories/McsMapInformationRepository.cs | 1 + .../NominationMenu/BuiltInHtml/McsBuiltInHtmlNominationUi.cs | 1 + .../McsMenu/NominationMenu/McsNominationMenuProvider.cs | 1 + .../McsMenu/VoteMenu/BuiltInHtml/McsBuiltInHtmlVoteUi.cs | 1 + .../Modules/McsMenu/VoteMenu/McsMapVoteMenuProvider.cs | 1 + .../Modules/Nomination/McsMapNominationCommands.cs | 1 + .../Modules/Nomination/McsMapNominationController.cs | 1 + .../Modules/PluginConfig/McsPluginConfigParser.cs | 1 + 18 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0c5b50b..e6f0482 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -97,6 +97,8 @@ jobs: Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\MySqlConnector.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\MySqlConnector.dll" -Force Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\Npgsql.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\Npgsql.dll" -Force Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\Npgsql.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\Npgsql.dll" -Force + Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\ZLinq.dll" -Destination "artifacts-windows-x64-with-dependencies\plugins\MapChooserSharp\ZLinq.dll" -Force + Copy-Item -Path "MapChooserSharp\bin\Release\net8.0\publish\ZLinq.dll" -Destination "artifacts-linux-x64-with-dependencies\plugins\MapChooserSharp\ZLinq.dll" -Force - name: Copy runtime artifacts run: | diff --git a/MapChooserSharp/MapChooserSharp.cs b/MapChooserSharp/MapChooserSharp.cs index 78f85b7..dfc3161 100644 --- a/MapChooserSharp/MapChooserSharp.cs +++ b/MapChooserSharp/MapChooserSharp.cs @@ -30,6 +30,7 @@ using Microsoft.Extensions.Logging; using TNCSSPluginFoundation; +[assembly: ZLinq.ZLinqDropInAttribute("MapChooserSharp", ZLinq.DropInGenerateTypes.Everything)] namespace MapChooserSharp; [MinimumApiVersion(333)] diff --git a/MapChooserSharp/MapChooserSharp.csproj b/MapChooserSharp/MapChooserSharp.csproj index 6af83e1..471f96f 100644 --- a/MapChooserSharp/MapChooserSharp.csproj +++ b/MapChooserSharp/MapChooserSharp.csproj @@ -22,6 +22,11 @@ + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + false diff --git a/MapChooserSharp/Modules/MapConfig/McsMapConfigProvider.cs b/MapChooserSharp/Modules/MapConfig/McsMapConfigProvider.cs index c98b11f..247a05b 100644 --- a/MapChooserSharp/Modules/MapConfig/McsMapConfigProvider.cs +++ b/MapChooserSharp/Modules/MapConfig/McsMapConfigProvider.cs @@ -1,5 +1,6 @@ using MapChooserSharp.API.MapConfig; using MapChooserSharp.Modules.MapConfig.Interfaces; +using ZLinq; namespace MapChooserSharp.Modules.MapConfig; diff --git a/MapChooserSharp/Modules/MapCycle/McsMapCycleCommands.cs b/MapChooserSharp/Modules/MapCycle/McsMapCycleCommands.cs index 729eed3..e7fd607 100644 --- a/MapChooserSharp/Modules/MapCycle/McsMapCycleCommands.cs +++ b/MapChooserSharp/Modules/MapCycle/McsMapCycleCommands.cs @@ -16,6 +16,7 @@ using Microsoft.Extensions.Logging; using TNCSSPluginFoundation.Models.Plugin; using TNCSSPluginFoundation.Utils.Entity; +using ZLinq; namespace MapChooserSharp.Modules.MapCycle; diff --git a/MapChooserSharp/Modules/MapCycle/McsMapCycleExtendVoteController.cs b/MapChooserSharp/Modules/MapCycle/McsMapCycleExtendVoteController.cs index d79397e..e2ceeee 100644 --- a/MapChooserSharp/Modules/MapCycle/McsMapCycleExtendVoteController.cs +++ b/MapChooserSharp/Modules/MapCycle/McsMapCycleExtendVoteController.cs @@ -11,6 +11,7 @@ using NativeVoteAPI.API; using TNCSSPluginFoundation.Models.Plugin; using TNCSSPluginFoundation.Utils.Entity; +using ZLinq; namespace MapChooserSharp.Modules.MapCycle; diff --git a/MapChooserSharp/Modules/MapCycle/Services/McsMapConfigExecutionService.cs b/MapChooserSharp/Modules/MapCycle/Services/McsMapConfigExecutionService.cs index 85732cc..57bf99b 100644 --- a/MapChooserSharp/Modules/MapCycle/Services/McsMapConfigExecutionService.cs +++ b/MapChooserSharp/Modules/MapCycle/Services/McsMapConfigExecutionService.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using TNCSSPluginFoundation.Models.Plugin; +using ZLinq; namespace MapChooserSharp.Modules.MapCycle.Services; @@ -135,7 +136,7 @@ private List FindCfgsWithFilter(IMapConfig? mapConfig, McsMapConfigExecu case McsMapConfigExecutionType.StartWithMach: if (mcsMapConfigType == McsMapConfigType.Map) { - cfgs.AddRange(_mapConfigs.Where(m => possibleConfigNames.First().StartsWith(m.Key)).Select(m => m.Value)); + cfgs.AddRange(_mapConfigs.Where(m => possibleConfigNames.First().StartsWith(m.Key)).Select(m => m.Value).ToList()); } else { @@ -146,7 +147,7 @@ private List FindCfgsWithFilter(IMapConfig? mapConfig, McsMapConfigExecu case McsMapConfigExecutionType.PartialMatch: if (mcsMapConfigType == McsMapConfigType.Map) { - cfgs.AddRange(_mapConfigs.Where(m => possibleConfigNames.First().Contains(m.Key)).Select(m => m.Value)); + cfgs.AddRange(_mapConfigs.Where(m => possibleConfigNames.First().Contains(m.Key)).Select(m => m.Value).ToList()); } else { diff --git a/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs b/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs index d26ddd8..ea14782 100644 --- a/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs +++ b/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs @@ -24,6 +24,7 @@ using Microsoft.Extensions.Logging; using TNCSSPluginFoundation.Models.Plugin; using TNCSSPluginFoundation.Utils.Entity; +using ZLinq; using Timer = CounterStrikeSharp.API.Modules.Timers.Timer; namespace MapChooserSharp.Modules.MapVote; diff --git a/MapChooserSharp/Modules/MapVote/McsMapVoteSoundPlayer.cs b/MapChooserSharp/Modules/MapVote/McsMapVoteSoundPlayer.cs index 45a5034..089cafd 100644 --- a/MapChooserSharp/Modules/MapVote/McsMapVoteSoundPlayer.cs +++ b/MapChooserSharp/Modules/MapVote/McsMapVoteSoundPlayer.cs @@ -2,6 +2,7 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Utils; using MapChooserSharp.Modules.PluginConfig.Interfaces; +using ZLinq; namespace MapChooserSharp.Modules.MapVote; diff --git a/MapChooserSharp/Modules/McsDatabase/Repositories/McsGroupInformationRepository.cs b/MapChooserSharp/Modules/McsDatabase/Repositories/McsGroupInformationRepository.cs index fff88d9..9c8a96d 100644 --- a/MapChooserSharp/Modules/McsDatabase/Repositories/McsGroupInformationRepository.cs +++ b/MapChooserSharp/Modules/McsDatabase/Repositories/McsGroupInformationRepository.cs @@ -5,6 +5,7 @@ using MapChooserSharp.Modules.McsDatabase.Repositories.SqlProviders.Interfaces; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using ZLinq; namespace MapChooserSharp.Modules.McsDatabase.Repositories; diff --git a/MapChooserSharp/Modules/McsDatabase/Repositories/McsMapInformationRepository.cs b/MapChooserSharp/Modules/McsDatabase/Repositories/McsMapInformationRepository.cs index 537c168..36b5d83 100644 --- a/MapChooserSharp/Modules/McsDatabase/Repositories/McsMapInformationRepository.cs +++ b/MapChooserSharp/Modules/McsDatabase/Repositories/McsMapInformationRepository.cs @@ -5,6 +5,7 @@ using MapChooserSharp.Modules.McsDatabase.Repositories.SqlProviders.Interfaces; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using ZLinq; namespace MapChooserSharp.Modules.McsDatabase.Repositories; diff --git a/MapChooserSharp/Modules/McsMenu/NominationMenu/BuiltInHtml/McsBuiltInHtmlNominationUi.cs b/MapChooserSharp/Modules/McsMenu/NominationMenu/BuiltInHtml/McsBuiltInHtmlNominationUi.cs index 34d88a4..b9569f6 100644 --- a/MapChooserSharp/Modules/McsMenu/NominationMenu/BuiltInHtml/McsBuiltInHtmlNominationUi.cs +++ b/MapChooserSharp/Modules/McsMenu/NominationMenu/BuiltInHtml/McsBuiltInHtmlNominationUi.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.DependencyInjection; using TNCSSPluginFoundation; using TNCSSPluginFoundation.Interfaces; +using ZLinq; namespace MapChooserSharp.Modules.McsMenu.NominationMenu.BuiltInHtml; diff --git a/MapChooserSharp/Modules/McsMenu/NominationMenu/McsNominationMenuProvider.cs b/MapChooserSharp/Modules/McsMenu/NominationMenu/McsNominationMenuProvider.cs index 589bed3..98e93a5 100644 --- a/MapChooserSharp/Modules/McsMenu/NominationMenu/McsNominationMenuProvider.cs +++ b/MapChooserSharp/Modules/McsMenu/NominationMenu/McsNominationMenuProvider.cs @@ -5,6 +5,7 @@ using MapChooserSharp.Modules.PluginConfig.Interfaces; using Microsoft.Extensions.DependencyInjection; using TNCSSPluginFoundation.Models.Plugin; +using ZLinq; namespace MapChooserSharp.Modules.McsMenu.NominationMenu; diff --git a/MapChooserSharp/Modules/McsMenu/VoteMenu/BuiltInHtml/McsBuiltInHtmlVoteUi.cs b/MapChooserSharp/Modules/McsMenu/VoteMenu/BuiltInHtml/McsBuiltInHtmlVoteUi.cs index c60dff0..a08b1a5 100644 --- a/MapChooserSharp/Modules/McsMenu/VoteMenu/BuiltInHtml/McsBuiltInHtmlVoteUi.cs +++ b/MapChooserSharp/Modules/McsMenu/VoteMenu/BuiltInHtml/McsBuiltInHtmlVoteUi.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection; using TNCSSPluginFoundation; using TNCSSPluginFoundation.Interfaces; +using ZLinq; namespace MapChooserSharp.Modules.McsMenu.VoteMenu.BuiltInHtml; diff --git a/MapChooserSharp/Modules/McsMenu/VoteMenu/McsMapVoteMenuProvider.cs b/MapChooserSharp/Modules/McsMenu/VoteMenu/McsMapVoteMenuProvider.cs index bca7327..db3357f 100644 --- a/MapChooserSharp/Modules/McsMenu/VoteMenu/McsMapVoteMenuProvider.cs +++ b/MapChooserSharp/Modules/McsMenu/VoteMenu/McsMapVoteMenuProvider.cs @@ -5,6 +5,7 @@ using MapChooserSharp.Modules.PluginConfig.Interfaces; using Microsoft.Extensions.DependencyInjection; using TNCSSPluginFoundation.Models.Plugin; +using ZLinq; namespace MapChooserSharp.Modules.McsMenu.VoteMenu; diff --git a/MapChooserSharp/Modules/Nomination/McsMapNominationCommands.cs b/MapChooserSharp/Modules/Nomination/McsMapNominationCommands.cs index 53996dd..7fefd5d 100644 --- a/MapChooserSharp/Modules/Nomination/McsMapNominationCommands.cs +++ b/MapChooserSharp/Modules/Nomination/McsMapNominationCommands.cs @@ -14,6 +14,7 @@ using MapChooserSharp.Modules.Nomination.Interfaces; using Microsoft.Extensions.DependencyInjection; using TNCSSPluginFoundation.Models.Plugin; +using ZLinq; namespace MapChooserSharp.Modules.Nomination; diff --git a/MapChooserSharp/Modules/Nomination/McsMapNominationController.cs b/MapChooserSharp/Modules/Nomination/McsMapNominationController.cs index e9e9dd5..2462581 100644 --- a/MapChooserSharp/Modules/Nomination/McsMapNominationController.cs +++ b/MapChooserSharp/Modules/Nomination/McsMapNominationController.cs @@ -22,6 +22,7 @@ using Microsoft.Extensions.Logging; using TNCSSPluginFoundation.Models.Plugin; using TNCSSPluginFoundation.Utils.Entity; +using ZLinq; namespace MapChooserSharp.Modules.Nomination; diff --git a/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs b/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs index 7ea7a64..6ae5df1 100644 --- a/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs +++ b/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs @@ -11,6 +11,7 @@ using TNCSSPluginFoundation.Models.Plugin; using Tomlyn; using Tomlyn.Model; +using ZLinq; namespace MapChooserSharp.Modules.PluginConfig;