Enable CA1854 and fix concompliance

"Prefer the `IDictionary.TryGetValue(TKey, out TValue)` method"
This commit is contained in:
YoshiRulz 2025-03-29 07:45:49 +10:00
parent c5d4e8b783
commit 5de736af0e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 11 additions and 11 deletions

View File

@ -93,6 +93,8 @@ dotnet_diagnostic.CA1829.severity = error
dotnet_diagnostic.CA1836.severity = error
# Avoid StringBuilder parameters for P/Invokes
dotnet_diagnostic.CA1838.severity = suggestion
# Prefer the `IDictionary.TryGetValue(TKey, out TValue)` method
dotnet_diagnostic.CA1854.severity = warning
# Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA1860.severity = error
# Use the 'StringComparison' method overloads to perform case-insensitive string comparisons

View File

@ -144,14 +144,12 @@ namespace BizHawk.Client.EmuHawk
: "Console"; // anything that wants not console can set it in the categorylabels
}
if (!buckets.ContainsKey(categoryLabel))
buckets.GetValueOrPut(categoryLabel, categoryLabel1 =>
{
var l = new List<string>();
buckets.Add(categoryLabel, l);
orderedBuckets.Add(new KeyValuePair<string, List<string>>(categoryLabel, l));
}
buckets[categoryLabel].Add(button);
List<string> l = new();
orderedBuckets.Add(new(categoryLabel1, l));
return l;
}).Add(button);
}
if (orderedBuckets.Count == 1)

View File

@ -36,9 +36,9 @@ namespace BizHawk.Emulation.Cores.Waterbox
private string OverrideButtonName(string original)
{
// VB hack
if (ButtonNameOverrides.ContainsKey(original))
if (ButtonNameOverrides.TryGetValue(original, out string vbOverrideName))
{
original = ButtonNameOverrides[original];
original = vbOverrideName;
}
original = Regex.Replace(original, @"\s*(↑|↓|←|→)\s*", "");
@ -48,9 +48,9 @@ namespace BizHawk.Emulation.Cores.Waterbox
original = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(original.ToLowerInvariant());
}
if (ButtonNameOverrides.ContainsKey(original))
if (ButtonNameOverrides.TryGetValue(original, out string overrideName))
{
original = ButtonNameOverrides[original];
original = overrideName;
}
// TODO: Add dictionaries or whatever here as needed