From 7900a84bd68d7c9450bba719ce925b61043875f3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Jul 2020 02:50:20 -0400 Subject: use ordinal comparison/sorting instead of invariant --- src/SMAPI/Framework/ContentManagers/BaseContentManager.cs | 6 +++--- src/SMAPI/Framework/ContentManagers/GameContentManager.cs | 4 ++-- src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/SMAPI/Framework/ContentManagers') diff --git a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs index 36f2f650..a8de013a 100644 --- a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs @@ -87,7 +87,7 @@ namespace StardewModdingAPI.Framework.ContentManagers this.IsNamespaced = isNamespaced; // get asset data - this.LanguageCodes = this.GetKeyLocales().ToDictionary(p => p.Value, p => p.Key, StringComparer.InvariantCultureIgnoreCase); + this.LanguageCodes = this.GetKeyLocales().ToDictionary(p => p.Value, p => p.Key, StringComparer.OrdinalIgnoreCase); this.BaseDisposableReferences = reflection.GetField>(this, "disposableAssets").GetValue(); } @@ -192,7 +192,7 @@ namespace StardewModdingAPI.Framework.ContentManagers /// Returns the invalidated asset names and instances. public IDictionary InvalidateCache(Func predicate, bool dispose = false) { - IDictionary removeAssets = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + IDictionary removeAssets = new Dictionary(StringComparer.OrdinalIgnoreCase); this.Cache.Remove((key, asset) => { this.ParseCacheKey(key, out string assetName, out _); @@ -295,7 +295,7 @@ namespace StardewModdingAPI.Framework.ContentManagers // handle localized key if (!string.IsNullOrWhiteSpace(cacheKey)) { - int lastSepIndex = cacheKey.LastIndexOf(".", StringComparison.InvariantCulture); + int lastSepIndex = cacheKey.LastIndexOf(".", StringComparison.Ordinal); if (lastSepIndex >= 0) { string suffix = cacheKey.Substring(lastSepIndex + 1, cacheKey.Length - lastSepIndex - 1); diff --git a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs index eaaf0e6f..f20580e1 100644 --- a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs @@ -123,7 +123,7 @@ namespace StardewModdingAPI.Framework.ContentManagers base.OnLocaleChanged(); // find assets for which a translatable version was loaded - HashSet removeAssetNames = new HashSet(StringComparer.InvariantCultureIgnoreCase); + HashSet removeAssetNames = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (string key in this.IsLocalizableLookup.Where(p => p.Value).Select(p => p.Key)) removeAssetNames.Add(this.TryParseExplicitLanguageAssetKey(key, out string assetName, out _) ? assetName : key); @@ -134,7 +134,7 @@ namespace StardewModdingAPI.Framework.ContentManagers || (this.TryParseExplicitLanguageAssetKey(key, out string assetName, out _) && removeAssetNames.Contains(assetName)) ) .Select(p => p.Key) - .OrderBy(p => p, StringComparer.InvariantCultureIgnoreCase) + .OrderBy(p => p, StringComparer.OrdinalIgnoreCase) .ToArray(); if (invalidated.Any()) this.Monitor.Log($"Invalidated {invalidated.Length} asset names: {string.Join(", ", invalidated)} for locale change.", LogLevel.Trace); diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index cfda55b9..26ddb067 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -372,7 +372,7 @@ namespace StardewModdingAPI.Framework.ContentManagers break; } } - if (contentKey.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) + if (contentKey.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) contentKey = contentKey.Substring(0, contentKey.Length - 4); try -- cgit