Fix CA1310, CA1311
This commit is contained in:
committed by
Matthias Mailänder
parent
d83e579dfe
commit
285443f10f
@@ -83,14 +83,14 @@ namespace OpenRA.FileSystem
|
||||
|
||||
public void Mount(string name, string explicitName = null)
|
||||
{
|
||||
var optional = name.StartsWith("~", StringComparison.Ordinal);
|
||||
var optional = name.StartsWith('~');
|
||||
if (optional)
|
||||
name = name[1..];
|
||||
|
||||
try
|
||||
{
|
||||
IReadOnlyPackage package;
|
||||
if (name.StartsWith("$", StringComparison.Ordinal))
|
||||
if (name.StartsWith('$'))
|
||||
{
|
||||
name = name[1..];
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace OpenRA.FileSystem
|
||||
public static string ResolveAssemblyPath(string path, Manifest manifest, InstalledMods installedMods)
|
||||
{
|
||||
var explicitSplit = path.IndexOf('|');
|
||||
if (explicitSplit > 0 && !path.StartsWith("^"))
|
||||
if (explicitSplit > 0 && !path.StartsWith('^'))
|
||||
{
|
||||
var parent = path[..explicitSplit];
|
||||
var filename = path[(explicitSplit + 1)..];
|
||||
@@ -304,7 +304,7 @@ namespace OpenRA.FileSystem
|
||||
if (parentPath == null)
|
||||
return null;
|
||||
|
||||
if (parentPath.StartsWith("$", StringComparison.Ordinal))
|
||||
if (parentPath.StartsWith('$'))
|
||||
{
|
||||
if (!installedMods.TryGetValue(parentPath[1..], out var mod))
|
||||
return null;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.FileSystem
|
||||
// in FileSystem.OpenPackage. Their internal name therefore contains the
|
||||
// full parent path too. We need to be careful to not add a second path
|
||||
// prefix to these hacked packages.
|
||||
var filePath = filename.StartsWith(Name) ? filename : Path.Combine(Name, filename);
|
||||
var filePath = filename.StartsWith(Name, StringComparison.Ordinal) ? filename : Path.Combine(Name, filename);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
using (var s = File.Create(filePath))
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.FileSystem
|
||||
// in FileSystem.OpenPackage. Their internal name therefore contains the
|
||||
// full parent path too. We need to be careful to not add a second path
|
||||
// prefix to these hacked packages.
|
||||
var filePath = filename.StartsWith(Name) ? filename : Path.Combine(Name, filename);
|
||||
var filePath = filename.StartsWith(Name, StringComparison.Ordinal) ? filename : Path.Combine(Name, filename);
|
||||
if (Directory.Exists(filePath))
|
||||
Directory.Delete(filePath, true);
|
||||
else if (File.Exists(filePath))
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.GameRules
|
||||
static object LoadWarheads(MiniYaml yaml)
|
||||
{
|
||||
var retList = new List<IWarhead>();
|
||||
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
|
||||
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead", StringComparison.Ordinal)))
|
||||
{
|
||||
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
|
||||
if (ret == null)
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Graphics
|
||||
.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s)));
|
||||
|
||||
foreach (var c in chrome)
|
||||
if (!c.Key.StartsWith("^", StringComparison.Ordinal))
|
||||
if (!c.Key.StartsWith('^'))
|
||||
LoadCollection(c.Key, c.Value);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Graphics
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
// Nodes starting with ^ are inheritable but never loaded directly
|
||||
if (node.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal))
|
||||
if (node.Key.StartsWith(ActorInfo.AbstractActorPrefix))
|
||||
continue;
|
||||
|
||||
images[node.Key] = modData.SpriteSequenceLoader.ParseSequences(modData, tileSet, SpriteCache, node);
|
||||
|
||||
@@ -275,7 +275,10 @@ namespace OpenRA
|
||||
try
|
||||
{
|
||||
foreach (var filename in contents)
|
||||
if (filename.EndsWith(".yaml") || filename.EndsWith(".bin") || filename.EndsWith(".lua") || (format >= 12 && filename == "map.png"))
|
||||
if (filename.EndsWith(".yaml", StringComparison.Ordinal) ||
|
||||
filename.EndsWith(".bin", StringComparison.Ordinal) ||
|
||||
filename.EndsWith(".lua", StringComparison.Ordinal) ||
|
||||
(format >= 12 && filename == "map.png"))
|
||||
streams.Add(package.GetStream(filename));
|
||||
|
||||
// Take the SHA1
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA
|
||||
? MapClassification.Unknown : Enum<MapClassification>.Parse(kv.Value);
|
||||
|
||||
IReadOnlyPackage package;
|
||||
var optional = name.StartsWith("~", StringComparison.Ordinal);
|
||||
var optional = name.StartsWith('~');
|
||||
if (optional)
|
||||
name = name[1..];
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA
|
||||
// HACK: If the path is inside the support directory then we may need to create it
|
||||
// Assume that the path is a directory if there is not an existing file with the same name
|
||||
var resolved = Platform.ResolvePath(name);
|
||||
if (resolved.StartsWith(Platform.SupportDir) && !File.Exists(resolved))
|
||||
if (resolved.StartsWith(Platform.SupportDir, StringComparison.Ordinal) && !File.Exists(resolved))
|
||||
Directory.CreateDirectory(resolved);
|
||||
|
||||
package = modData.ModFiles.OpenPackage(name);
|
||||
@@ -190,13 +190,13 @@ namespace OpenRA
|
||||
continue;
|
||||
|
||||
var name = kv.Key;
|
||||
var optional = name.StartsWith("~", StringComparison.Ordinal);
|
||||
var optional = name.StartsWith('~');
|
||||
if (optional)
|
||||
name = name[1..];
|
||||
|
||||
// Don't try to open the map directory in the support directory if it doesn't exist
|
||||
var resolved = Platform.ResolvePath(name);
|
||||
if (resolved.StartsWith(Platform.SupportDir) && (!Directory.Exists(resolved) || !File.Exists(resolved)))
|
||||
if (resolved.StartsWith(Platform.SupportDir, StringComparison.Ordinal) && (!Directory.Exists(resolved) || !File.Exists(resolved)))
|
||||
continue;
|
||||
|
||||
using (var package = (IReadWritePackage)modData.ModFiles.OpenPackage(name))
|
||||
|
||||
@@ -438,7 +438,7 @@ namespace OpenRA
|
||||
foreach (var r in ResolveInherits(parent, tree, inherited))
|
||||
MergeIntoResolved(r, resolved, resolvedKeys, tree, inherited);
|
||||
}
|
||||
else if (n.Key.StartsWith("-", StringComparison.Ordinal))
|
||||
else if (n.Key.StartsWith('-'))
|
||||
{
|
||||
var removed = n.Key[1..];
|
||||
if (resolved.RemoveAll(r => r.Key == removed) == 0)
|
||||
|
||||
@@ -109,14 +109,14 @@ namespace OpenRA
|
||||
var p = Process.Start(psi);
|
||||
string line;
|
||||
while ((line = p.StandardOutput.ReadLine()) != null)
|
||||
if (line.StartsWith("Operating System: "))
|
||||
if (line.StartsWith("Operating System: ", StringComparison.Ordinal))
|
||||
return line[18..] + suffix;
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (File.Exists("/etc/os-release"))
|
||||
foreach (var line in File.ReadLines("/etc/os-release"))
|
||||
if (line.StartsWith("PRETTY_NAME="))
|
||||
if (line.StartsWith("PRETTY_NAME=", StringComparison.Ordinal))
|
||||
return line[13..^1] + suffix;
|
||||
}
|
||||
else if (CurrentPlatform == PlatformType.OSX)
|
||||
@@ -134,7 +134,7 @@ namespace OpenRA
|
||||
while ((line = p.StandardOutput.ReadLine()) != null)
|
||||
{
|
||||
line = line.Trim();
|
||||
if (line.StartsWith("System Version: "))
|
||||
if (line.StartsWith("System Version: ", StringComparison.Ordinal))
|
||||
return line[16..];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace OpenRA.Scripting
|
||||
// Remove the namespace and the trailing "Info"
|
||||
return types.SelectMany(i => i.GetGenericArguments())
|
||||
.Select(g => g.Name.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault())
|
||||
.Select(s => s.EndsWith("Info") ? s.Remove(s.Length - 4, 4) : s)
|
||||
.Select(s => s.EndsWith("Info", StringComparison.Ordinal) ? s.Remove(s.Length - 4, 4) : s)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ namespace OpenRA
|
||||
{
|
||||
// Always load english strings to provide a fallback for missing translations.
|
||||
// It is important to load the english files first so the chosen language's files can override them.
|
||||
var paths = translations.Where(t => t.EndsWith("en.ftl")).ToHashSet();
|
||||
var paths = translations.Where(t => t.EndsWith("en.ftl", StringComparison.Ordinal)).ToHashSet();
|
||||
foreach (var t in translations)
|
||||
if (t.EndsWith($"{language}.ftl"))
|
||||
if (t.EndsWith($"{language}.ftl", StringComparison.Ordinal))
|
||||
paths.Add(t);
|
||||
|
||||
foreach (var path in paths)
|
||||
|
||||
Reference in New Issue
Block a user