Fix CA1304

This commit is contained in:
RoosterDragon
2023-03-12 12:09:47 +00:00
committed by Matthias Mailänder
parent 949ba589c0
commit 486a07602b
5 changed files with 15 additions and 14 deletions

View File

@@ -664,6 +664,9 @@ dotnet_diagnostic.CA1200.severity = warning
### Globalization Rules
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/globalization-warnings
# Specify 'CultureInfo'.
dotnet_diagnostic.CA1304.severity = warning
### Portability and Interoperability Rules
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/interoperability-warnings

View File

@@ -22,11 +22,6 @@ namespace OpenRA
{
public static class Exts
{
public static bool IsUppercase(this string str)
{
return string.Compare(str.ToUpperInvariant(), str, false) == 0;
}
public static T WithDefault<T>(T def, Func<T> f)
{
try { return f(); }

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
if (isBuildable && isBuilding && canAttack)
{
var name = actor.Key.ToLower();
var name = actor.Key.ToLowerInvariant();
if (!defences.Contains(name))
defences.Add(name);
}

View File

@@ -93,14 +93,14 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
if (isAircraft && isBuildable && canAttack && isKillable)
{
var name = actor.Key.ToLower();
var name = actor.Key.ToLowerInvariant();
if (!aircraft.Contains(name))
aircraft.Add(name);
}
if (isBuildable && isKillable && (isVip || (isBuilding && !isExcluded)))
{
var name = actor.Key.ToLower();
var name = actor.Key.ToLowerInvariant();
if (!vips.Contains(name))
vips.Add(name);
}

View File

@@ -390,7 +390,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var item = ScrollItemWidget.Setup(
tpl,
() => string.Compare(filter.MapName, option, true) == 0,
() => string.Equals(filter.MapName, option, StringComparison.CurrentCultureIgnoreCase),
() => { filter.MapName = option; ApplyFilter(); });
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
return item;
@@ -418,7 +418,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var item = ScrollItemWidget.Setup(
tpl,
() => string.Compare(filter.PlayerName, option, true) == 0,
() => string.Equals(filter.PlayerName, option, StringComparison.CurrentCultureIgnoreCase),
() => { filter.PlayerName = option; ApplyFilter(); });
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
return item;
@@ -450,7 +450,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var item = ScrollItemWidget.Setup(
tpl,
() => string.Compare(filter.Faction, option, true) == 0,
() => string.Equals(filter.Faction, option, StringComparison.CurrentCultureIgnoreCase),
() => { filter.Faction = option; ApplyFilter(); });
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
return item;
@@ -658,13 +658,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
// Map
if (!string.IsNullOrEmpty(filter.MapName) && string.Compare(filter.MapName, replay.GameInfo.MapTitle, true) != 0)
if (!string.IsNullOrEmpty(filter.MapName) &&
!string.Equals(filter.MapName, replay.GameInfo.MapTitle, StringComparison.CurrentCultureIgnoreCase))
return false;
// Player
if (!string.IsNullOrEmpty(filter.PlayerName))
{
var player = replay.GameInfo.Players.FirstOrDefault(p => string.Compare(filter.PlayerName, p.Name, true) == 0);
var player = replay.GameInfo.Players.FirstOrDefault(
p => string.Equals(filter.PlayerName, p.Name, StringComparison.CurrentCultureIgnoreCase));
if (player == null)
return false;
@@ -673,7 +675,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return false;
// Faction
if (!string.IsNullOrEmpty(filter.Faction) && string.Compare(filter.Faction, player.FactionName, true) != 0)
if (!string.IsNullOrEmpty(filter.Faction) &&
!string.Equals(filter.Faction, player.FactionName, StringComparison.CurrentCultureIgnoreCase))
return false;
}