Fix CA1865

This commit is contained in:
RoosterDragon
2023-11-15 19:09:09 +00:00
committed by Pavel Penev
parent 9f526610dd
commit 2ea2106eca
4 changed files with 8 additions and 3 deletions

View File

@@ -861,6 +861,11 @@ dotnet_diagnostic.CA1860.severity = warning
# Prefer the 'IDictionary.TryAdd(TKey, TValue)' method. # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method.
dotnet_diagnostic.CA1864.severity = suggestion # TODO: Change to warning once using .NET 8 or later. 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. # Cache and reuse 'JsonSerializerOptions' instances.
dotnet_diagnostic.CA1869.severity = suggestion # TODO: Change to warning once using .NET 8 or later. dotnet_diagnostic.CA1869.severity = suggestion # TODO: Change to warning once using .NET 8 or later.

View File

@@ -144,7 +144,7 @@ namespace OpenRA.FileSystem
public ZipFolder(ReadOnlyZipFile parent, string path) public ZipFolder(ReadOnlyZipFile parent, string path)
{ {
if (path.EndsWith("/", StringComparison.Ordinal)) if (path.EndsWith('/'))
path = path[..^1]; path = path[..^1];
Name = path; Name = path;

View File

@@ -533,7 +533,7 @@ namespace OpenRA
{ {
// Append Removal nodes to the result. // Append Removal nodes to the result.
// Therefore: we know the remainder of the method deals with a plain node. // 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); ret.Add(node);
return; return;

View File

@@ -349,7 +349,7 @@ namespace OpenRA.Mods.Common.UpdateRules
public static void RenameKey(this MiniYamlNodeBuilder node, string newKey, bool preserveSuffix = true, bool includeRemovals = true) public static void RenameKey(this MiniYamlNodeBuilder node, string newKey, bool preserveSuffix = true, bool includeRemovals = true)
{ {
var prefix = includeRemovals && node.IsRemoval() ? "-" : ""; var prefix = includeRemovals && node.IsRemoval() ? "-" : "";
var split = node.Key.IndexOf("@", StringComparison.Ordinal); var split = node.Key.IndexOf('@');
if (preserveSuffix && split > -1) if (preserveSuffix && split > -1)
node.Key = prefix + newKey + node.Key[split..]; node.Key = prefix + newKey + node.Key[split..];
else else