Skip to content

Commit 7900a84

Browse files
committed
use ordinal comparison/sorting instead of invariant
1 parent ee4c88f commit 7900a84

43 files changed

Lines changed: 76 additions & 75 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Added trace log for GPU running the game to simplify troubleshooting some issues.
1414
* Fixed launcher's fallback logic on Linux when no compatible terminal was found (thanks to jlaw!).
1515
* Fixed rare crash when a mod adds/removes an event handler from an event handler.
16+
* Fixed string sorting/comparison for some special characters.
1617

1718
* For the Console Commands mod:
1819
* Fixed error opening menu when some item data is invalid.

src/SMAPI.Installer/InteractiveInstaller.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public void Run(string[] args)
468468
}
469469

470470
// find target folder
471-
ModFolder targetMod = targetMods.FirstOrDefault(p => p.Manifest?.UniqueID?.Equals(sourceMod.Manifest.UniqueID, StringComparison.InvariantCultureIgnoreCase) == true);
471+
ModFolder targetMod = targetMods.FirstOrDefault(p => p.Manifest?.UniqueID?.Equals(sourceMod.Manifest.UniqueID, StringComparison.OrdinalIgnoreCase) == true);
472472
DirectoryInfo defaultTargetFolder = new DirectoryInfo(Path.Combine(paths.ModsPath, sourceMod.Directory.Name));
473473
DirectoryInfo targetFolder = targetMod?.Directory ?? defaultTargetFolder;
474474
this.PrintDebug(targetFolder.FullName == defaultTargetFolder.FullName
@@ -808,7 +808,7 @@ private void InteractivelyRemoveAppDataMods(DirectoryInfo properModsDir, Directo
808808
continue; // should never happen
809809

810810
// delete packaged mods (newer version bundled into SMAPI)
811-
if (isDir && packagedModNames.Contains(entry.Name, StringComparer.InvariantCultureIgnoreCase))
811+
if (isDir && packagedModNames.Contains(entry.Name, StringComparer.OrdinalIgnoreCase))
812812
{
813813
this.PrintDebug($" Deleting {entry.Name} because it's bundled into SMAPI...");
814814
this.InteractivelyDelete(entry.FullName);

src/SMAPI.Installer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
6767
AssemblyName name = new AssemblyName(e.Name);
6868
foreach (FileInfo dll in new DirectoryInfo(Program.InternalFilesPath).EnumerateFiles("*.dll"))
6969
{
70-
if (name.Name.Equals(AssemblyName.GetAssemblyName(dll.FullName).Name, StringComparison.InvariantCultureIgnoreCase))
70+
if (name.Name.Equals(AssemblyName.GetAssemblyName(dll.FullName).Name, StringComparison.OrdinalIgnoreCase))
7171
return Assembly.LoadFrom(dll.FullName);
7272
}
7373
return null;

src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class ModFileManager
3333
/// <exception cref="UserErrorException">The mod package isn't valid.</exception>
3434
public ModFileManager(string projectDir, string targetDir, Regex[] ignoreFilePatterns, bool validateRequiredModFiles)
3535
{
36-
this.Files = new Dictionary<string, FileInfo>(StringComparer.InvariantCultureIgnoreCase);
36+
this.Files = new Dictionary<string, FileInfo>(StringComparer.OrdinalIgnoreCase);
3737

3838
// validate paths
3939
if (!Directory.Exists(projectDir))
@@ -68,7 +68,7 @@ public ModFileManager(string projectDir, string targetDir, Regex[] ignoreFilePat
6868
/// <summary>Get the files in the mod package.</summary>
6969
public IDictionary<string, FileInfo> GetFiles()
7070
{
71-
return new Dictionary<string, FileInfo>(this.Files, StringComparer.InvariantCultureIgnoreCase);
71+
return new Dictionary<string, FileInfo>(this.Files, StringComparer.OrdinalIgnoreCase);
7272
}
7373

7474
/// <summary>Get a semantic version from the mod manifest.</summary>
@@ -165,8 +165,8 @@ private bool ShouldIgnore(FileInfo file, string relativePath, Regex[] ignoreFile
165165
|| this.EqualsInvariant(file.Name, "Newtonsoft.Json.xml")
166166

167167
// code analysis files
168-
|| file.Name.EndsWith(".CodeAnalysisLog.xml", StringComparison.InvariantCultureIgnoreCase)
169-
|| file.Name.EndsWith(".lastcodeanalysissucceeded", StringComparison.InvariantCultureIgnoreCase)
168+
|| file.Name.EndsWith(".CodeAnalysisLog.xml", StringComparison.OrdinalIgnoreCase)
169+
|| file.Name.EndsWith(".lastcodeanalysissucceeded", StringComparison.OrdinalIgnoreCase)
170170

171171
// OS metadata files
172172
|| this.EqualsInvariant(file.Name, ".DS_Store")
@@ -183,7 +183,7 @@ private bool EqualsInvariant(string str, string other)
183183
{
184184
if (str == null)
185185
return other == null;
186-
return str.Equals(other, StringComparison.InvariantCultureIgnoreCase);
186+
return str.Equals(other, StringComparison.OrdinalIgnoreCase);
187187
}
188188
}
189189
}

src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ArgumentParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public bool TryGet(int index, string name, out string value, bool required = tru
6464
this.LogError($"Argument {index} ({name}) is required.");
6565
return false;
6666
}
67-
if (oneOf?.Any() == true && !oneOf.Contains(this.Args[index], StringComparer.InvariantCultureIgnoreCase))
67+
if (oneOf?.Any() == true && !oneOf.Contains(this.Args[index], StringComparer.OrdinalIgnoreCase))
6868
{
6969
this.LogError($"Argument {index} ({name}) must be one of {string.Join(", ", oneOf)}.");
7070
return false;

src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public override void Handle(IMonitor monitor, string command, ArgumentParser arg
5656
return;
5757

5858
// get target location
59-
GameLocation location = Game1.locations.FirstOrDefault(p => p.Name != null && p.Name.Equals(locationName, StringComparison.InvariantCultureIgnoreCase));
59+
GameLocation location = Game1.locations.FirstOrDefault(p => p.Name != null && p.Name.Equals(locationName, StringComparison.OrdinalIgnoreCase));
6060
if (location == null && locationName == "current")
6161
location = Game1.currentLocation;
6262
if (location == null)

src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ public SearchableItem(ItemType type, int id, Item item)
4444
public bool NameContains(string substring)
4545
{
4646
return
47-
this.Name.IndexOf(substring, StringComparison.InvariantCultureIgnoreCase) != -1
48-
|| this.DisplayName.IndexOf(substring, StringComparison.InvariantCultureIgnoreCase) != -1;
47+
this.Name.IndexOf(substring, StringComparison.OrdinalIgnoreCase) != -1
48+
|| this.DisplayName.IndexOf(substring, StringComparison.OrdinalIgnoreCase) != -1;
4949
}
5050

5151
/// <summary>Get whether the item name is exactly equal to a case-insensitive string.</summary>
5252
/// <param name="name">The substring to find.</param>
5353
public bool NameEquivalentTo(string name)
5454
{
5555
return
56-
this.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)
57-
|| this.DisplayName.Equals(name, StringComparison.InvariantCultureIgnoreCase);
56+
this.Name.Equals(name, StringComparison.OrdinalIgnoreCase)
57+
|| this.DisplayName.Equals(name, StringComparison.OrdinalIgnoreCase);
5858
}
5959
}
6060
}

src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private IDictionary<string, string> GetAttributeAsVersionMapping(HtmlNode elemen
233233

234234
// parse
235235
// Specified on the wiki in the form "remote version → mapped version; another remote version → mapped version"
236-
IDictionary<string, string> map = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
236+
IDictionary<string, string> map = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
237237
foreach (string pair in raw.Split(';'))
238238
{
239239
string[] versions = pair.Split('→');

src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public IEnumerable<DirectoryInfo> Scan()
3030
.GetCustomInstallPaths(platform)
3131
.Concat(this.GetDefaultInstallPaths(platform))
3232
.Select(PathUtilities.NormalizePathSeparators)
33-
.Distinct(StringComparer.InvariantCultureIgnoreCase);
33+
.Distinct(StringComparer.OrdinalIgnoreCase);
3434

3535
// yield valid folders
3636
foreach (string path in paths)

src/SMAPI.Toolkit/Framework/ModData/ModDataModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public IEnumerable<ModDataField> GetFields()
6868
foreach (string part in parts.Take(parts.Length - 1))
6969
{
7070
// 'default'
71-
if (part.Equals("Default", StringComparison.InvariantCultureIgnoreCase))
71+
if (part.Equals("Default", StringComparison.OrdinalIgnoreCase))
7272
{
7373
isDefault = true;
7474
continue;

0 commit comments

Comments
 (0)