Replace `InvariantCultureIgnoreCase` str. cmps. w/ `OrdinalIgnoreCase`

doesn't matter for ASCII-only strings, and `InvariantCultureIgnoreCase`
is arguably correct in some circumstances, but IMO it's more foolproof
to simply ban it
This commit is contained in:
YoshiRulz 2025-01-29 19:31:23 +10:00
parent 5f29b50940
commit a9fd86689e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 9 additions and 6 deletions

View File

@ -22,4 +22,6 @@ M:System.Diagnostics.Debug.WriteLine(System.String);use Util.DebugWriteLine (fir
M:System.Diagnostics.Trace.Assert(System.Boolean);include a unique message
M:System.Diagnostics.Trace.Assert(System.Boolean,System.String);just do the check and throw a specific exception
M:System.String.GetHashCode;strings' hashcodes aren't stable
P:System.StringComparer.InvariantCultureIgnoreCase;use OrdinalIgnoreCase
F:System.StringComparison.InvariantCultureIgnoreCase;use OrdinalIgnoreCase
M:System.Windows.Forms.Control.Focus;use Activate for Forms, or Select otherwise

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.Common
var globalBase = collection[PathEntryCollection.GLOBAL, "Base"].Path;
// if %exe% prefixed then substitute exe path and repeat
if (globalBase.StartsWith("%exe%", StringComparison.InvariantCultureIgnoreCase))
if (globalBase.StartsWith("%exe%", StringComparison.OrdinalIgnoreCase))
{
globalBase = PathUtils.ExeDirectoryPath + globalBase.Substring(5);
}

View File

@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk
(linkLabel2.Text, linkLabel2.Tag) = VersionInfo.GetGitCommitLink();
foreach (var core in CoreInventory.Instance.SystemsFlat
.OrderBy(static core => core.CoreAttr.Released)
.ThenByDescending(static core => core.Name, StringComparer.InvariantCultureIgnoreCase))
.ThenByDescending(static core => core.Name, StringComparer.OrdinalIgnoreCase))
{
CoreInfoPanel.Controls.Add(new BizBoxInfoControl(core.CoreAttr)
{

View File

@ -270,7 +270,7 @@ namespace BizHawk.Client.EmuHawk
}
// super hacky! this needs to be done first. still not worth the trouble to make this system fully proper
if (Array.Exists(args, arg => arg.StartsWith("--gdi", StringComparison.InvariantCultureIgnoreCase)))
if (Array.Exists(args, static arg => arg.StartsWith("--gdi", StringComparison.OrdinalIgnoreCase)))
{
initialConfig.DispMethod = EDispMethod.GdiPlus;
}

View File

@ -87,7 +87,8 @@ namespace BizHawk.Common
return (winVer, null);
});
private static readonly Lazy<bool> _isWSL = new(() => IsUnixHost && SimpleSubshell("uname", "-r", "missing uname?").Contains("microsoft", StringComparison.InvariantCultureIgnoreCase));
private static readonly Lazy<bool> _isWSL = new(static () => IsUnixHost
&& SimpleSubshell(cmd: "uname", args: "-r", noOutputMsg: "missing uname?").Contains("microsoft", StringComparison.OrdinalIgnoreCase));
public static (WindowsVersion Version, Version? Win10PlusVersion)? HostWindowsVersion => _HostWindowsVersion.Value;

View File

@ -44,9 +44,9 @@ namespace BizHawk.Emulation.Common
private static void LoadDatabase_Escape(string line, bool inUser, bool silent)
{
if (!line.StartsWith("#include", StringComparison.InvariantCultureIgnoreCase)) return;
var isUserInclude = line.StartsWith("#includeuser", StringComparison.OrdinalIgnoreCase);
if (!isUserInclude && !line.StartsWith("#include", StringComparison.OrdinalIgnoreCase)) return;
var isUserInclude = line.StartsWith("#includeuser", StringComparison.InvariantCultureIgnoreCase);
var searchUser = inUser || isUserInclude;
line = line.Substring(isUserInclude ? 12 : 8).TrimStart();
var filename = Path.Combine(searchUser ? _userRoot : _bundledRoot, line);