Fix CA1854

This commit is contained in:
RoosterDragon
2023-11-15 19:46:36 +00:00
committed by Pavel Penev
parent c2568ebd1f
commit c8efc5fdd7
19 changed files with 44 additions and 48 deletions

View File

@@ -285,10 +285,10 @@ namespace OpenRA.Mods.Common.Lint
var isAttribute = !string.IsNullOrEmpty(attribute);
var keyWithAtrr = isAttribute ? $"{key}.{attribute}" : key;
if (!referencedVariablesPerKey.ContainsKey(keyWithAtrr))
if (!referencedVariablesPerKey.TryGetValue(keyWithAtrr, out var referencedVariables))
return;
foreach (var referencedVariable in referencedVariablesPerKey[keyWithAtrr])
foreach (var referencedVariable in referencedVariables)
if (!variableReferences.Contains(referencedVariable))
emitError(isAttribute ?
$"Missing variable `{referencedVariable}` for attribute `{attribute}` of key `{key}` in {file}." :
@@ -302,7 +302,7 @@ namespace OpenRA.Mods.Common.Lint
variableReferences.Add(varName);
if (!referencedVariablesPerKey.ContainsKey(keyWithAtrr) || !referencedVariablesPerKey[keyWithAtrr].Contains(varName))
if (!referencedVariablesPerKey.TryGetValue(keyWithAtrr, out var referencedVariables) || !referencedVariables.Contains(varName))
emitWarning(isAttribute ?
$"Unused variable `{varName}` for attribute `{attribute}` of key `{key}` in {file}." :
$"Unused variable `{varName}` for key `{key}` in {file}.");