From aeb4447363ced9f2af5467c0797edb2d6142c32e Mon Sep 17 00:00:00 2001 From: laolarou Date: Wed, 15 Nov 2023 16:17:54 -0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20NET8=20=E6=96=B0=E8=AF=AD?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjBobcat/ProjBobcat/Class/Helper/DownloadHelper.cs | 2 +- .../Class/Helper/GameResourcesResolveHelper.cs | 5 ++--- .../ProjBobcat/Class/Model/GameConfigurationManager.cs | 2 +- .../Class/Model/Version/ComparableVersion.cs | 8 ++++---- .../ProjBobcat/Class/Model/Version/Item/StringItem.cs | 6 +++--- .../DefaultComponent/DefaultResourceCompleter.cs | 2 +- .../ForgeInstaller/HighVersionForgeInstaller.cs | 2 +- .../Installer/ModPackInstaller/ModPackInstallerBase.cs | 2 +- .../Launch/DefaultLauncherAccountParser.cs | 4 ++-- .../Launch/DefaultLauncherProfileParser.cs | 2 +- .../DefaultComponent/Launch/DefaultVersionLocator.cs | 10 +++++----- .../DefaultComponent/LogAnalysis/DefaultLogAnalyzer.cs | 2 +- .../DefaultComponent/Service/ServerPingService.cs | 2 +- 13 files changed, 24 insertions(+), 25 deletions(-) diff --git a/ProjBobcat/ProjBobcat/Class/Helper/DownloadHelper.cs b/ProjBobcat/ProjBobcat/Class/Helper/DownloadHelper.cs index 78bd1194..ad770f52 100644 --- a/ProjBobcat/ProjBobcat/Class/Helper/DownloadHelper.cs +++ b/ProjBobcat/ProjBobcat/Class/Helper/DownloadHelper.cs @@ -301,7 +301,7 @@ public static async Task MultiPartDownloadTaskAsync( #region Calculate ranges - readRanges = new List(); + readRanges = []; var partSize = responseLength / downloadSettings.DownloadParts; var totalSize = responseLength; diff --git a/ProjBobcat/ProjBobcat/Class/Helper/GameResourcesResolveHelper.cs b/ProjBobcat/ProjBobcat/Class/Helper/GameResourcesResolveHelper.cs index 8eaeb2df..953ae5e8 100644 --- a/ProjBobcat/ProjBobcat/Class/Helper/GameResourcesResolveHelper.cs +++ b/ProjBobcat/ProjBobcat/Class/Helper/GameResourcesResolveHelper.cs @@ -87,12 +87,11 @@ public static async IAsyncEnumerable ResolveModListAsync(IE case JsonValueKind.Object: var val = doc.RootElement.Deserialize(GameModInfoModelContext.Default.GameModInfoModel); - if (val != null) model = new List { val }; + if (val != null) model = [val]; break; case JsonValueKind.Array: - model = doc.RootElement.Deserialize(GameModInfoModelContext.Default.ListGameModInfoModel) ?? - new List(); + model = doc.RootElement.Deserialize(GameModInfoModelContext.Default.ListGameModInfoModel) ?? []; break; } diff --git a/ProjBobcat/ProjBobcat/Class/Model/GameConfigurationManager.cs b/ProjBobcat/ProjBobcat/Class/Model/GameConfigurationManager.cs index 5e37f40b..f1413cf7 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/GameConfigurationManager.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/GameConfigurationManager.cs @@ -13,7 +13,7 @@ public class GameConfigurationManager : IEnumerable public GameConfigurationManager() { - _configuration = new Dictionary(); + _configuration = []; } public GameConfigurationManager(string path) diff --git a/ProjBobcat/ProjBobcat/Class/Model/Version/ComparableVersion.cs b/ProjBobcat/ProjBobcat/Class/Model/Version/ComparableVersion.cs index 346d3718..3cde9550 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Version/ComparableVersion.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Version/ComparableVersion.cs @@ -51,7 +51,7 @@ public class ComparableVersion : IComparable const int MaxIntItemLength = 9; const int MaxLongItemLength = 18; - readonly ListItem _items = new(); + readonly ListItem _items = []; string? _canonical; string _value = null!; @@ -104,7 +104,7 @@ void ParseVersion(string version) : ParseItem(isDigit, version[startIndex..i])); startIndex = i + 1; - list.Add(list = new ListItem()); + list.Add(list = []); stack.Push(list); break; default: @@ -116,7 +116,7 @@ void ParseVersion(string version) list.Add(new StringItem(version[startIndex..i], true)); startIndex = i; - list.Add(list = new ListItem()); + list.Add(list = []); stack.Push(list); } @@ -129,7 +129,7 @@ void ParseVersion(string version) list.Add(ParseItem(true, version[startIndex..i])); startIndex = i; - list.Add(list = new ListItem()); + list.Add(list = []); stack.Push(list); } diff --git a/ProjBobcat/ProjBobcat/Class/Model/Version/Item/StringItem.cs b/ProjBobcat/ProjBobcat/Class/Model/Version/Item/StringItem.cs index ff4ab5f0..f74d546a 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/Version/Item/StringItem.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/Version/Item/StringItem.cs @@ -6,8 +6,8 @@ namespace ProjBobcat.Class.Model.Version.Item; public class StringItem : IItem { - static readonly List Qualifiers = new() - { + static readonly List Qualifiers = + [ "alpha", "beta", "milestone", @@ -15,7 +15,7 @@ public class StringItem : IItem "snapshot", Empty, "sp" - }; + ]; static readonly Dictionary Aliases = new() { diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs b/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs index 8763661f..a594340d 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/DefaultResourceCompleter.cs @@ -23,7 +23,7 @@ public class DefaultResourceCompleter : IResourceCompleter static readonly object ChangedEventKey = new(); static readonly object CompletedEventKey = new(); - readonly ConcurrentBag _failedFiles = new(); + readonly ConcurrentBag _failedFiles = []; readonly EventHandlerList _listEventDelegates = new(); bool _disposedValue; diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ForgeInstaller/HighVersionForgeInstaller.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ForgeInstaller/HighVersionForgeInstaller.cs index 6cd89bfb..6d1bcb7b 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ForgeInstaller/HighVersionForgeInstaller.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ForgeInstaller/HighVersionForgeInstaller.cs @@ -37,7 +37,7 @@ static readonly Regex #endif - readonly ConcurrentBag _failedFiles = new(); + readonly ConcurrentBag _failedFiles = []; int _totalDownloaded, _needToDownload, _totalProcessed, _needToProcess; public string? JavaExecutablePath { get; init; } diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ModPackInstaller/ModPackInstallerBase.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ModPackInstaller/ModPackInstallerBase.cs index 1acbf60e..1de00b2d 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ModPackInstaller/ModPackInstallerBase.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Installer/ModPackInstaller/ModPackInstallerBase.cs @@ -6,7 +6,7 @@ namespace ProjBobcat.DefaultComponent.Installer.ModPackInstaller; public class ModPackInstallerBase : InstallerBase { - protected readonly ConcurrentBag FailedFiles = new(); + protected readonly ConcurrentBag FailedFiles = []; protected int TotalDownloaded, NeedToDownload; protected void WhenCompleted(object? sender, DownloadFileCompletedEventArgs e) diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs index 4795df3c..2f7a4eba 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs @@ -29,7 +29,7 @@ public DefaultLauncherAccountParser(string rootPath, Guid clientToken) { var launcherAccount = new LauncherAccountModel { - Accounts = new Dictionary(), + Accounts = [], MojangClientToken = clientToken.ToString("N") }; @@ -74,7 +74,7 @@ public bool AddNewAccount(string uuid, AccountModel account, out Guid? id) return false; } - LauncherAccount.Accounts ??= new Dictionary(); + LauncherAccount.Accounts ??= []; if (LauncherAccount.Accounts.ContainsKey(uuid)) { diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs index 6ea6b749..826c62a5 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs @@ -40,7 +40,7 @@ public DefaultLauncherProfileParser(string rootPath, Guid clientToken) Format = 1, Name = string.Empty }, - Profiles = new Dictionary() + Profiles = [] }; LauncherProfile = launcherProfile; diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultVersionLocator.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultVersionLocator.cs index 47c9e94e..db6dbea1 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultVersionLocator.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultVersionLocator.cs @@ -341,7 +341,7 @@ public override (List, List) GetNatives(IEnumerable
  • (); + inherits = []; var current = rawVersion; var first = true; @@ -370,8 +370,8 @@ public override (List, List) GetNatives(IEnumerable
  • (), - Natives = new List(), + Libraries = [], + Natives = [], Logging = rawVersion.Logging, Id = rawVersion.Id, DirName = id, @@ -484,11 +484,11 @@ public override (List, List) GetNatives(IEnumerable
  • (); + var finalJvmArgs = result.JvmArguments?.ToList() ?? []; finalJvmArgs.AddRange(jvmArgList); result.JvmArguments = finalJvmArgs; - var finalGameArgs = result.GameArguments?.ToList() ?? new List(); + var finalGameArgs = result.GameArguments?.ToList() ?? []; finalGameArgs.AddRange(gameArgList); finalGameArgs = finalGameArgs.Select(arg => arg.Split(' ')).SelectMany(a => a).Distinct().ToList(); result.GameArguments = finalGameArgs; diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/LogAnalysis/DefaultLogAnalyzer.cs b/ProjBobcat/ProjBobcat/DefaultComponent/LogAnalysis/DefaultLogAnalyzer.cs index bc880d51..c4e0a894 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/LogAnalysis/DefaultLogAnalyzer.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/LogAnalysis/DefaultLogAnalyzer.cs @@ -75,7 +75,7 @@ public IEnumerable GenerateReport() foreach (var (logFileType, lines) in GetAllLogs()) { if (!logs.ContainsKey(logFileType)) - logs[logFileType] = new List<(string, string)>(); + logs[logFileType] = []; logs[logFileType].Add(lines); } diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Service/ServerPingService.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Service/ServerPingService.cs index f585fbbe..2a10042d 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Service/ServerPingService.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Service/ServerPingService.cs @@ -65,7 +65,7 @@ public ServerPingResult Run() return null; } - _buffer = new List(); + _buffer = []; _stream = client.GetStream(); InvokeStatusChangedEvent("发送请求...", 30);