Fix CA1310, CA1311
This commit is contained in:
committed by
Matthias Mailänder
parent
d83e579dfe
commit
285443f10f
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Commands
|
||||
|
||||
public bool OnChat(string playername, string message)
|
||||
{
|
||||
if (message.StartsWith("/"))
|
||||
if (message.StartsWith('/'))
|
||||
{
|
||||
var name = message[1..].Split(' ')[0].ToLowerInvariant();
|
||||
var command = Commands.FirstOrDefault(x => x.Key == name);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Installer
|
||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||
{
|
||||
// Yaml path must be specified relative to a named directory (e.g. ^SupportDir)
|
||||
if (!actionYaml.Value.StartsWith("^"))
|
||||
if (!actionYaml.Value.StartsWith('^'))
|
||||
return;
|
||||
|
||||
var sourcePath = Platform.ResolvePath(actionYaml.Value);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||
{
|
||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
|
||||
using (var source = File.OpenRead(sourcePath))
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Installer
|
||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||
{
|
||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
|
||||
var volumeNode = actionYaml.Nodes.FirstOrDefault(n => n.Key == "Volumes");
|
||||
if (volumeNode == null)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||
{
|
||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
|
||||
using (var source = File.OpenRead(sourcePath))
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||
{
|
||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
|
||||
using (var source = File.OpenRead(sourcePath))
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted,
|
||||
Action<string> updateMessage)
|
||||
{
|
||||
var zipPath = actionYaml.Value.StartsWith("^")
|
||||
var zipPath = actionYaml.Value.StartsWith('^')
|
||||
? Platform.ResolvePath(actionYaml.Value)
|
||||
: FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
if (sequenceReference.Prefix)
|
||||
{
|
||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
||||
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence)))
|
||||
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
|
||||
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
||||
}
|
||||
else if (!sequences.HasSequence(i, sequence))
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
if (sequenceReference.Prefix)
|
||||
{
|
||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
||||
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence)))
|
||||
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
|
||||
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
|
||||
}
|
||||
else if (!sequences.HasSequence(image, sequence))
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
static string NormalizeName(string key)
|
||||
{
|
||||
var name = key.Split('@')[0];
|
||||
if (name.StartsWith("-", StringComparison.Ordinal))
|
||||
if (name.StartsWith('-'))
|
||||
return name[1..];
|
||||
|
||||
return name;
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var t in actor.Value.Nodes)
|
||||
{
|
||||
// Removals can never define children or values.
|
||||
if (t.Key.StartsWith("-", StringComparison.Ordinal))
|
||||
if (t.Key.StartsWith('-'))
|
||||
{
|
||||
if (t.Value.Nodes.Length > 0)
|
||||
emitError($"{t.Location} `{t.Key}` defines child nodes, which are not valid for removals.");
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
static string NormalizeName(string key)
|
||||
{
|
||||
var name = key.Split('@')[0];
|
||||
if (name.StartsWith("-", StringComparison.Ordinal))
|
||||
if (name.StartsWith('-'))
|
||||
return name[1..];
|
||||
|
||||
return name;
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var field in weapon.Value.Nodes)
|
||||
{
|
||||
// Removals can never define children or values
|
||||
if (field.Key.StartsWith("-", StringComparison.Ordinal))
|
||||
if (field.Key.StartsWith('-'))
|
||||
{
|
||||
if (field.Value.Nodes.Length > 0)
|
||||
emitError($"{field.Location} `{field.Key}` defines child nodes, which is not valid for removals.");
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
||||
if (bi != null)
|
||||
foreach (var prereq in bi.Prerequisites)
|
||||
if (!prereq.StartsWith("~disabled") && !providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
|
||||
if (!prereq.StartsWith("~disabled", StringComparison.Ordinal) && !providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
|
||||
emitError($"Buildable actor `{actorInfo.Key}` has prereq `{prereq}` not provided by anything.");
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
lock (server.LobbyInfo)
|
||||
{
|
||||
// Kick command is always valid for the host
|
||||
if (command.StartsWith("kick "))
|
||||
if (command.StartsWith("kick ", StringComparison.Ordinal))
|
||||
return true;
|
||||
|
||||
if (server.State == ServerState.GameStarted)
|
||||
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, Translation.Arguments("command", command));
|
||||
return false;
|
||||
}
|
||||
else if (client.State == Session.ClientState.Ready && !(command.StartsWith("state") || command == "startgame"))
|
||||
else if (client.State == Session.ClientState.Ready && !(command.StartsWith("state", StringComparison.Ordinal) || command == "startgame"))
|
||||
{
|
||||
server.SendLocalizedMessageTo(conn, StateUnchangedReady);
|
||||
return false;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
List<float2> frameOffsets;
|
||||
|
||||
// Prefer manual defined regions over auto sliced regions.
|
||||
if (png.EmbeddedData.Any(meta => meta.Key.StartsWith("Frame[")))
|
||||
if (png.EmbeddedData.Any(meta => meta.Key.StartsWith("Frame[", StringComparison.Ordinal)))
|
||||
RegionsFromFrames(png, out frameRegions, out frameOffsets);
|
||||
else
|
||||
RegionsFromSlices(png, out frameRegions, out frameOffsets);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -110,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var pref in prefixes)
|
||||
if (name.StartsWith(pref))
|
||||
if (name.StartsWith(pref, StringComparison.Ordinal))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -116,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString.StartsWith("Dev"))
|
||||
if (order.OrderString.StartsWith("Dev", StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
OrderCount++;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
@@ -66,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool HasPrerequisites(IEnumerable<string> prerequisites)
|
||||
{
|
||||
var ownedPrereqs = GatherOwnedPrerequisites(Owner);
|
||||
return prerequisites.All(p => !(p.Replace("~", "").StartsWith("!", StringComparison.Ordinal)
|
||||
return prerequisites.All(p => !(p.Replace("~", "").StartsWith('!')
|
||||
^ !ownedPrereqs.ContainsKey(p.Replace("!", "").Replace("~", ""))));
|
||||
}
|
||||
|
||||
@@ -142,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var prereq in prerequisites)
|
||||
{
|
||||
var withoutTilde = prereq.Replace("~", "");
|
||||
if (withoutTilde.StartsWith("!", StringComparison.Ordinal) ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
||||
if (withoutTilde.StartsWith('!') ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,10 +153,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var prereq in prerequisites)
|
||||
{
|
||||
if (!prereq.StartsWith("~", StringComparison.Ordinal))
|
||||
if (!prereq.StartsWith('~'))
|
||||
continue;
|
||||
var withoutTilde = prereq.Replace("~", "");
|
||||
if (withoutTilde.StartsWith("!", StringComparison.Ordinal) ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
||||
if (withoutTilde.StartsWith('!') ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void SyncMultiplayerCount()
|
||||
{
|
||||
var newCount = previews.Count(p => p.Info.Name == "mpspawn");
|
||||
var mp = Players.Players.Where(p => p.Key.StartsWith("Multi")).ToList();
|
||||
var mp = Players.Players.Where(p => p.Key.StartsWith("Multi", StringComparison.Ordinal)).ToList();
|
||||
foreach (var kv in mp)
|
||||
{
|
||||
var name = kv.Key;
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
defaultTilesetFilenamesNode = defaultsNode.LastChildMatching("TilesetFilenames") ?? defaultTilesetFilenamesNode;
|
||||
}
|
||||
|
||||
if ((defaultFilenameNode == null || defaultTilesetFilenamesNode == null) && !imageNode.Key.StartsWith("^"))
|
||||
if ((defaultFilenameNode == null || defaultTilesetFilenamesNode == null) && !imageNode.Key.StartsWith('^'))
|
||||
{
|
||||
var duplicateCount = new Dictionary<string, int>();
|
||||
var duplicateTilesetCount = new Dictionary<string, int>();
|
||||
@@ -372,7 +372,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
|
||||
// Replace removals with masking
|
||||
foreach (var node in sequenceNode.Value.Nodes)
|
||||
if (node.Key?.StartsWith("-") ?? false)
|
||||
if (node.Key?.StartsWith('-') ?? false)
|
||||
node.Key = node.Key[1..];
|
||||
|
||||
var combineNode = sequenceNode.LastChildMatching("Combine");
|
||||
@@ -389,7 +389,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
}
|
||||
|
||||
var filename = string.IsNullOrEmpty(resolvedSequenceNode.Value.Value) ? imageName : resolvedSequenceNode.Value.Value;
|
||||
if (filename.StartsWith("^"))
|
||||
if (filename.StartsWith('^'))
|
||||
return;
|
||||
|
||||
if (useTilesetExtension || useTilesetCode)
|
||||
|
||||
@@ -46,7 +46,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var interfaceMembers = interfaceType.GetMembers();
|
||||
foreach (var interfaceMember in interfaceMembers)
|
||||
{
|
||||
if (interfaceMember.Name.StartsWith("get_") || interfaceMember.Name.StartsWith("set_") || interfaceMember.Name.StartsWith("add_") || interfaceMember.Name.StartsWith("remove_"))
|
||||
if (interfaceMember.Name.StartsWith("get_", StringComparison.Ordinal) ||
|
||||
interfaceMember.Name.StartsWith("set_", StringComparison.Ordinal) ||
|
||||
interfaceMember.Name.StartsWith("add_", StringComparison.Ordinal) ||
|
||||
interfaceMember.Name.StartsWith("remove_", StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
var interfaceMethod = interfaceMember as MethodInfo;
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
|
||||
var value = field.GetValue(section.Value);
|
||||
if (value != null && !value.ToString().StartsWith("System."))
|
||||
if (value != null && !value.ToString().StartsWith("System.", StringComparison.Ordinal))
|
||||
{
|
||||
Console.WriteLine($"**Default Value:** {value}");
|
||||
Console.WriteLine();
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
.Select(type => new
|
||||
{
|
||||
type.Namespace,
|
||||
Name = type.Name.EndsWith("Info") ? type.Name[..^4] : type.Name,
|
||||
Name = type.Name.EndsWith("Info", StringComparison.Ordinal) ? type.Name[..^4] : type.Name,
|
||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||
RequiresTraits = RequiredTraitTypes(type)
|
||||
.Select(y => y.Name),
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
.Select(a =>
|
||||
{
|
||||
var name = a.AttributeType.Name;
|
||||
name = name.EndsWith("Attribute") ? name[..^9] : name;
|
||||
name = name.EndsWith("Attribute", StringComparison.Ordinal) ? name[..^9] : name;
|
||||
|
||||
return new
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
.Select(type => new
|
||||
{
|
||||
type.Namespace,
|
||||
Name = type.Name.EndsWith("Info") ? type.Name[..^4] : type.Name,
|
||||
Name = type.Name.EndsWith("Info", StringComparison.Ordinal) ? type.Name[..^4] : type.Name,
|
||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||
InheritedTypes = type.BaseTypes()
|
||||
.Select(y => y.Name)
|
||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
.Select(a =>
|
||||
{
|
||||
var name = a.AttributeType.Name;
|
||||
name = name.EndsWith("Attribute") ? name[..^9] : name;
|
||||
name = name.EndsWith("Attribute", StringComparison.Ordinal) ? name[..^9] : name;
|
||||
|
||||
return new
|
||||
{
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (buildable != null)
|
||||
{
|
||||
var prerequisites = buildable.Prerequisites.Select(a => ActorName(modData.DefaultRules, a))
|
||||
.Where(s => !s.StartsWith("~", StringComparison.Ordinal) && !s.StartsWith("!", StringComparison.Ordinal));
|
||||
.Where(s => !s.StartsWith('~') && !s.StartsWith('!'));
|
||||
if (prerequisites.Any())
|
||||
text += $"Requires {prerequisites.JoinWith(", ")}\n\n";
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Commands;
|
||||
@@ -143,7 +142,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var team = teamChat && !disableTeamChat;
|
||||
if (chatText.Text != "")
|
||||
{
|
||||
if (!chatText.Text.StartsWith("/", StringComparison.Ordinal))
|
||||
if (!chatText.Text.StartsWith('/'))
|
||||
{
|
||||
// This should never happen, but avoid a crash if it does somehow (chat will just stay open)
|
||||
if (!isObserver && orderManager.LocalClient == null && world.LocalPlayer == null)
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var prereqs = buildable.Prerequisites.Select(a => ActorName(mapRules, a))
|
||||
.Where(s => !s.StartsWith("~", StringComparison.Ordinal) && !s.StartsWith("!", StringComparison.Ordinal));
|
||||
.Where(s => !s.StartsWith('~') && !s.StartsWith('!'));
|
||||
|
||||
var requiresSize = int2.Zero;
|
||||
if (prereqs.Any())
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var toComplete = "";
|
||||
if (text.StartsWith("/") && Commands != null)
|
||||
if (text.StartsWith('/') && Commands != null)
|
||||
{
|
||||
prefix = "/";
|
||||
suffix = "";
|
||||
|
||||
Reference in New Issue
Block a user