Fix CA1862

This commit is contained in:
RoosterDragon
2024-11-13 19:02:20 +00:00
committed by Pavel Penev
parent ed90322a0b
commit 332ab244a7
5 changed files with 12 additions and 3 deletions

View File

@@ -913,6 +913,9 @@ dotnet_diagnostic.CA1858.severity = warning
# Avoid using 'Enumerable.Any()' extension method. # Avoid using 'Enumerable.Any()' extension method.
dotnet_diagnostic.CA1860.severity = warning dotnet_diagnostic.CA1860.severity = warning
# Use the 'StringComparison' method overloads to perform case-insensitive string comparisons.
dotnet_diagnostic.CA1862.severity = warning
# Use 'CompositeFormat'. # Use 'CompositeFormat'.
dotnet_diagnostic.CA1863.severity = suggestion # TODO: Change to warning once using .NET 7 or later. dotnet_diagnostic.CA1863.severity = suggestion # TODO: Change to warning once using .NET 7 or later.

View File

@@ -130,7 +130,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
Console.WriteLine("\t\tIntoActor: " + undeploysInto); Console.WriteLine("\t\tIntoActor: " + undeploysInto);
} }
if (artIni.Sections.Any(s => s.Name == building.ToLowerInvariant())) var buildingLower = building.ToLowerInvariant();
if (artIni.Sections.Any(s => s.Name == buildingLower))
{ {
var artSection = artIni.GetSection(building); var artSection = artIni.GetSection(building);

View File

@@ -138,7 +138,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
Console.WriteLine("\t\tUseTilesetCode: false"); Console.WriteLine("\t\tUseTilesetCode: false");
} }
if (file.Sections.Any(s => s.Name == sequence.ToLowerInvariant())) var sequenceLower = sequence.ToLowerInvariant();
if (file.Sections.Any(s => s.Name == sequenceLower))
{ {
var sequenceSection = file.GetSection(sequence); var sequenceSection = file.GetSection(sequence);
var guard = sequenceSection.GetValue("Guard", string.Empty); var guard = sequenceSection.GetValue("Guard", string.Empty);

View File

@@ -150,7 +150,9 @@ namespace OpenRA.Mods.Common.Activities
var positionable = (IPositionable)movement; var positionable = (IPositionable)movement;
var mobile = positionable as Mobile; var mobile = positionable as Mobile;
minefield.RemoveAll(c => self.World.ActorMap.GetActorsAt(c) minefield.RemoveAll(c => self.World.ActorMap.GetActorsAt(c)
.Any(a => a.Info.Name == minelayer.Info.Mine.ToLowerInvariant() && a.CanBeViewedByPlayer(self.Owner)) || .Any(a =>
string.Equals(a.Info.Name, minelayer.Info.Mine, System.StringComparison.OrdinalIgnoreCase)
&& a.CanBeViewedByPlayer(self.Owner)) ||
((!positionable.CanEnterCell(c, null, BlockedByActor.Immovable) || (mobile != null && !mobile.CanStayInCell(c))) ((!positionable.CanEnterCell(c, null, BlockedByActor.Immovable) || (mobile != null && !mobile.CanStayInCell(c)))
&& self.Owner.Shroud.IsVisible(c))); && self.Owner.Shroud.IsVisible(c)));
} }

View File

@@ -336,7 +336,9 @@ namespace OpenRA.Mods.Common.UpdateRules
public static bool IsAlreadyExtracted(string key) public static bool IsAlreadyExtracted(string key)
{ {
#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
if (key == key.ToLowerInvariant() && key.Any(c => c == '-') && key.All(c => c != ' ')) if (key == key.ToLowerInvariant() && key.Any(c => c == '-') && key.All(c => c != ' '))
#pragma warning restore CA1862
{ {
Console.WriteLine($"Skipping {key} because it is already extracted."); Console.WriteLine($"Skipping {key} because it is already extracted.");
return true; return true;