Fix CA1854
This commit is contained in:
committed by
Pavel Penev
parent
c2568ebd1f
commit
c8efc5fdd7
@@ -200,18 +200,18 @@ namespace OpenRA
|
||||
|
||||
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key)
|
||||
{
|
||||
if (!yaml.ContainsKey(key))
|
||||
if (!yaml.TryGetValue(key, out var value))
|
||||
return Array.Empty<string>();
|
||||
|
||||
return yaml[key].Nodes.Select(n => n.Key).ToArray();
|
||||
return value.Nodes.Select(n => n.Key).ToArray();
|
||||
}
|
||||
|
||||
static IReadOnlyDictionary<string, string> YamlDictionary(Dictionary<string, MiniYaml> yaml, string key)
|
||||
{
|
||||
if (!yaml.ContainsKey(key))
|
||||
if (!yaml.TryGetValue(key, out var value))
|
||||
return new Dictionary<string, string>();
|
||||
|
||||
return yaml[key].ToDictionary(my => my.Value);
|
||||
return value.ToDictionary(my => my.Value);
|
||||
}
|
||||
|
||||
public bool Contains<T>() where T : IGlobalModData
|
||||
|
||||
@@ -348,8 +348,8 @@ namespace OpenRA
|
||||
|
||||
while (this[uid].Status != MapStatus.Available)
|
||||
{
|
||||
if (mapUpdates.ContainsKey(uid))
|
||||
uid = mapUpdates[uid];
|
||||
if (mapUpdates.TryGetValue(uid, out var newUid))
|
||||
uid = newUid;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ namespace OpenRA
|
||||
for (var i = 0; i < p.Length; i++)
|
||||
{
|
||||
var key = p[i].Name;
|
||||
if (!args.ContainsKey(key)) throw new InvalidOperationException($"ObjectCreator: key `{key}' not found");
|
||||
a[i] = args[key];
|
||||
if (!args.TryGetValue(key, out var arg)) throw new InvalidOperationException($"ObjectCreator: key `{key}' not found");
|
||||
a[i] = arg;
|
||||
}
|
||||
|
||||
return ctor.Invoke(a);
|
||||
|
||||
@@ -380,17 +380,17 @@ namespace OpenRA
|
||||
|
||||
if (voicedActor != null)
|
||||
{
|
||||
if (!rules.VoicePools.Value.ContainsKey(definition))
|
||||
if (!rules.VoicePools.Value.TryGetValue(definition, out var p))
|
||||
throw new InvalidOperationException($"Can't find {definition} in voice pool.");
|
||||
|
||||
pool = rules.VoicePools.Value[definition];
|
||||
pool = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!rules.NotificationsPools.Value.ContainsKey(definition))
|
||||
if (!rules.NotificationsPools.Value.TryGetValue(definition, out var p))
|
||||
throw new InvalidOperationException($"Can't find {definition} in notification pool.");
|
||||
|
||||
pool = rules.NotificationsPools.Value[definition];
|
||||
pool = p;
|
||||
}
|
||||
|
||||
var clip = pool.GetNext();
|
||||
|
||||
@@ -257,10 +257,10 @@ namespace OpenRA.UtilityCommands
|
||||
var validChildTypes = new List<(MiniYamlNodeBuilder Node, string Type, string Value)>();
|
||||
foreach (var childNode in node.Value.Nodes)
|
||||
{
|
||||
if (translatables.ContainsKey(nodeType))
|
||||
if (translatables.TryGetValue(nodeType, out var fieldName))
|
||||
{
|
||||
var childType = childNode.Key.Split('@')[0];
|
||||
if (translatables[nodeType].Contains(childType)
|
||||
if (fieldName.Contains(childType)
|
||||
&& !string.IsNullOrEmpty(childNode.Value.Value)
|
||||
&& !IsAlreadyTranslated(childNode.Value.Value)
|
||||
&& childNode.Value.Value.Any(char.IsLetterOrDigit))
|
||||
|
||||
Reference in New Issue
Block a user