From 2ea2106eca8c8ece8bc9e1fe83e1ac25ff191e3d Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Wed, 15 Nov 2023 19:09:09 +0000 Subject: [PATCH] Fix CA1865 --- .editorconfig | 5 +++++ OpenRA.Game/FileSystem/ZipFile.cs | 2 +- OpenRA.Game/MiniYaml.cs | 2 +- OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4a25f15793..2a1e9b280f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -861,6 +861,11 @@ dotnet_diagnostic.CA1860.severity = warning # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method. dotnet_diagnostic.CA1864.severity = suggestion # TODO: Change to warning once using .NET 8 or later. +# Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char. +dotnet_diagnostic.CA1865.severity = suggestion # TODO: Change to warning once using .NET 8 or later. +dotnet_diagnostic.CA1866.severity = suggestion # TODO: Change to warning once using .NET 8 or later. +dotnet_diagnostic.CA1867.severity = suggestion # TODO: Change to warning once using .NET 8 or later. + # Cache and reuse 'JsonSerializerOptions' instances. dotnet_diagnostic.CA1869.severity = suggestion # TODO: Change to warning once using .NET 8 or later. diff --git a/OpenRA.Game/FileSystem/ZipFile.cs b/OpenRA.Game/FileSystem/ZipFile.cs index b6c130bf9e..9aba3cabbe 100644 --- a/OpenRA.Game/FileSystem/ZipFile.cs +++ b/OpenRA.Game/FileSystem/ZipFile.cs @@ -144,7 +144,7 @@ namespace OpenRA.FileSystem public ZipFolder(ReadOnlyZipFile parent, string path) { - if (path.EndsWith("/", StringComparison.Ordinal)) + if (path.EndsWith('/')) path = path[..^1]; Name = path; diff --git a/OpenRA.Game/MiniYaml.cs b/OpenRA.Game/MiniYaml.cs index 2425fc9679..6320e46250 100644 --- a/OpenRA.Game/MiniYaml.cs +++ b/OpenRA.Game/MiniYaml.cs @@ -533,7 +533,7 @@ namespace OpenRA { // Append Removal nodes to the result. // Therefore: we know the remainder of the method deals with a plain node. - if (node.Key.StartsWith("-", StringComparison.Ordinal)) + if (node.Key.StartsWith('-')) { ret.Add(node); return; diff --git a/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs b/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs index 86fc35db20..3592e7d153 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs @@ -349,7 +349,7 @@ namespace OpenRA.Mods.Common.UpdateRules public static void RenameKey(this MiniYamlNodeBuilder node, string newKey, bool preserveSuffix = true, bool includeRemovals = true) { var prefix = includeRemovals && node.IsRemoval() ? "-" : ""; - var split = node.Key.IndexOf("@", StringComparison.Ordinal); + var split = node.Key.IndexOf('@'); if (preserveSuffix && split > -1) node.Key = prefix + newKey + node.Key[split..]; else