diff options
Diffstat (limited to 'src/SMAPI.Toolkit')
-rw-r--r-- | src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Framework/ModData/ModDataModel.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs | 4 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs | 51 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/ModToolkit.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/SemanticVersion.cs | 6 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Serialization/InternalExtensions.cs | 2 |
9 files changed, 52 insertions, 21 deletions
diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs index 34e2e1b8..89a22eaf 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs @@ -233,7 +233,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki // parse // Specified on the wiki in the form "remote version → mapped version; another remote version → mapped version" - IDictionary<string, string> map = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); + IDictionary<string, string> map = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); foreach (string pair in raw.Split(';')) { string[] versions = pair.Split('→'); diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs index 4eec3424..450d600a 100644 --- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs @@ -30,7 +30,7 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning .GetCustomInstallPaths(platform) .Concat(this.GetDefaultInstallPaths(platform)) .Select(PathUtilities.NormalizePathSeparators) - .Distinct(StringComparer.InvariantCultureIgnoreCase); + .Distinct(StringComparer.OrdinalIgnoreCase); // yield valid folders foreach (string path in paths) diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataModel.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataModel.cs index 8b40c301..2167d3e5 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDataModel.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataModel.cs @@ -68,7 +68,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData foreach (string part in parts.Take(parts.Length - 1)) { // 'default' - if (part.Equals("Default", StringComparison.InvariantCultureIgnoreCase)) + if (part.Equals("Default", StringComparison.OrdinalIgnoreCase)) { isDefault = true; continue; diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs index c892d820..3201c421 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs @@ -46,13 +46,13 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData public bool HasID(string id) { // try main ID - if (this.ID.Equals(id, StringComparison.InvariantCultureIgnoreCase)) + if (this.ID.Equals(id, StringComparison.OrdinalIgnoreCase)) return true; // try former IDs foreach (string formerID in this.FormerIDs) { - if (formerID.Equals(id, StringComparison.InvariantCultureIgnoreCase)) + if (formerID.Equals(id, StringComparison.OrdinalIgnoreCase)) return true; } diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs index f4857c7d..6d6b6417 100644 --- a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs +++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs @@ -18,22 +18,48 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning private readonly JsonHelper JsonHelper; /// <summary>A list of filesystem entry names to ignore when checking whether a folder should be treated as a mod.</summary> - private readonly HashSet<Regex> IgnoreFilesystemEntries = new HashSet<Regex> + private readonly HashSet<Regex> IgnoreFilesystemNames = new HashSet<Regex> { - // OS metadata files new Regex(@"^__folder_managed_by_vortex$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Vortex mod manager new Regex(@"(?:^\._|^\.DS_Store$|^__MACOSX$|^mcs$)", RegexOptions.Compiled | RegexOptions.IgnoreCase), // MacOS - new Regex(@"^(?:desktop\.ini|Thumbs\.db)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Windows - new Regex(@"\.(?:url|lnk)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Windows shortcut files + new Regex(@"^(?:desktop\.ini|Thumbs\.db)$", RegexOptions.Compiled | RegexOptions.IgnoreCase) // Windows + }; - // other - new Regex(@"\.(?:bmp|gif|jpeg|jpg|png|psd|tif)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // image files - new Regex(@"\.(?:md|rtf|txt)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // text files - new Regex(@"\.(?:backup|bak|old)$", RegexOptions.Compiled | RegexOptions.IgnoreCase) // backup file + /// <summary>A list of file extensions to ignore when searching for mod files.</summary> + private readonly HashSet<string> IgnoreFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) + { + // text + ".doc", + ".docx", + ".md", + ".rtf", + ".txt", + + // images + ".bmp", + ".gif", + ".jpeg", + ".jpg", + ".png", + ".psd", + ".tif", + + // archives + ".rar", + ".zip", + + // backup files + ".backup", + ".bak", + ".old", + + // Windows shortcut files + ".url", + ".lnk" }; /// <summary>The extensions for files which an XNB mod may contain. If a mod doesn't have a <c>manifest.json</c> and contains *only* these file extensions, it should be considered an XNB mod.</summary> - private readonly HashSet<string> PotentialXnbModExtensions = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase) + private readonly HashSet<string> PotentialXnbModExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { // XNB files ".xgs", @@ -258,7 +284,12 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning /// <param name="entry">The file or folder.</param> private bool IsRelevant(FileSystemInfo entry) { - return !this.IgnoreFilesystemEntries.Any(p => p.IsMatch(entry.Name)); + // ignored file extension + if (entry is FileInfo file && this.IgnoreFileExtensions.Contains(file.Extension)) + return false; + + // ignored entry name + return !this.IgnoreFilesystemNames.Any(p => p.IsMatch(entry.Name)); } /// <summary>Get whether a file is potentially part of an XNB mod.</summary> diff --git a/src/SMAPI.Toolkit/ModToolkit.cs b/src/SMAPI.Toolkit/ModToolkit.cs index 08fe0fed..695a2c52 100644 --- a/src/SMAPI.Toolkit/ModToolkit.cs +++ b/src/SMAPI.Toolkit/ModToolkit.cs @@ -22,7 +22,7 @@ namespace StardewModdingAPI.Toolkit private readonly string UserAgent; /// <summary>Maps vendor keys (like <c>Nexus</c>) to their mod URL template (where <c>{0}</c> is the mod ID). This doesn't affect update checks, which defer to the remote web API.</summary> - private readonly IDictionary<string, string> VendorModUrls = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) + private readonly IDictionary<string, string> VendorModUrls = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { ["Chucklefish"] = "https://community.playstarbound.com/resources/{0}", ["GitHub"] = "https://github.com/{0}/releases", diff --git a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj index 71ea0f12..9e9d824a 100644 --- a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj +++ b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="HtmlAgilityPack" Version="1.11.23" /> + <PackageReference Include="HtmlAgilityPack" Version="1.11.24" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Pathoschild.Http.FluentClient" Version="4.0.0" /> <PackageReference Include="System.Management" Version="4.5.0" Condition="'$(OS)' == 'Windows_NT'" /> diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index 86db2820..1a76bec3 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -278,9 +278,9 @@ namespace StardewModdingAPI.Toolkit if (curParts[i] != otherParts[i]) { // unofficial is always lower-precedence - if (otherParts[i].Equals("unofficial", StringComparison.InvariantCultureIgnoreCase)) + if (otherParts[i].Equals("unofficial", StringComparison.OrdinalIgnoreCase)) return curNewer; - if (curParts[i].Equals("unofficial", StringComparison.InvariantCultureIgnoreCase)) + if (curParts[i].Equals("unofficial", StringComparison.OrdinalIgnoreCase)) return curOlder; // compare numerically if possible @@ -295,7 +295,7 @@ namespace StardewModdingAPI.Toolkit } // fallback (this should never happen) - return string.Compare(this.ToString(), new SemanticVersion(otherMajor, otherMinor, otherPatch, otherPlatformRelease, otherTag).ToString(), StringComparison.InvariantCultureIgnoreCase); + return string.Compare(this.ToString(), new SemanticVersion(otherMajor, otherMinor, otherPatch, otherPlatformRelease, otherTag).ToString(), StringComparison.OrdinalIgnoreCase); } /// <summary>Assert that the current version is valid.</summary> diff --git a/src/SMAPI.Toolkit/Serialization/InternalExtensions.cs b/src/SMAPI.Toolkit/Serialization/InternalExtensions.cs index 9aba53bf..10f88dde 100644 --- a/src/SMAPI.Toolkit/Serialization/InternalExtensions.cs +++ b/src/SMAPI.Toolkit/Serialization/InternalExtensions.cs @@ -12,7 +12,7 @@ namespace StardewModdingAPI.Toolkit.Serialization /// <param name="fieldName">The field name.</param> public static T ValueIgnoreCase<T>(this JObject obj, string fieldName) { - JToken token = obj.GetValue(fieldName, StringComparison.InvariantCultureIgnoreCase); + JToken token = obj.GetValue(fieldName, StringComparison.OrdinalIgnoreCase); return token != null ? token.Value<T>() : default(T); |