From 4991b4d6afea97dc6c9aa5174d438cac72e7d116 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 2 Feb 2020 15:01:03 -0500 Subject: prefix OS name in log on Android --- src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Toolkit') diff --git a/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs b/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs index 2a01fe4b..c45448f3 100644 --- a/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs +++ b/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs @@ -53,7 +53,19 @@ namespace StardewModdingAPI.Toolkit.Utilities } catch { } #endif - return (platform == Platform.Mac ? "MacOS " : "") + Environment.OSVersion; + + string name = Environment.OSVersion.ToString(); + switch (platform) + { + case Platform.Android: + name = $"Android {name}"; + break; + + case Platform.Mac: + name = $"MacOS {name}"; + break; + } + return name; } /// Get the name of the Stardew Valley executable. -- cgit From dd27b3bf35d01e4fd0703e47d538bd8cec03652b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Feb 2020 21:32:55 -0500 Subject: fix parsing four-part versions from the update-check API --- .../Clients/WebApi/ModEntryVersionModel.cs | 4 ++++ src/SMAPI.Toolkit/SemanticVersion.cs | 9 +++++---- .../NonStandardSemanticVersionConverter.cs | 15 +++++++++++++++ .../Converters/SemanticVersionConverter.cs | 9 ++++++++- src/SMAPI.Web/Controllers/ModsApiController.cs | 22 +++++----------------- src/SMAPI.Web/Framework/VersionConstraint.cs | 2 +- 6 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 src/SMAPI.Toolkit/Serialization/Converters/NonStandardSemanticVersionConverter.cs (limited to 'src/SMAPI.Toolkit') diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryVersionModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryVersionModel.cs index dadb8c10..188db31d 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryVersionModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryVersionModel.cs @@ -1,3 +1,6 @@ +using Newtonsoft.Json; +using StardewModdingAPI.Toolkit.Serialization.Converters; + namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { /// Metadata about a version. @@ -7,6 +10,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi ** Accessors *********/ /// The version number. + [JsonConverter(typeof(NonStandardSemanticVersionConverter))] public ISemanticVersion Version { get; set; } /// The mod page URL. diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index 5ead6dc8..86db2820 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -199,18 +199,19 @@ namespace StardewModdingAPI.Toolkit /// Returns whether parsing the version succeeded. public static bool TryParse(string version, out ISemanticVersion parsed) { - return SemanticVersion.TryParseNonStandard(version, out parsed) && !parsed.IsNonStandard(); + return SemanticVersion.TryParse(version, allowNonStandard: false, out parsed); } - /// Parse a version string without throwing an exception if it fails, including support for non-standard extensions like . + /// Parse a version string without throwing an exception if it fails. /// The version string. + /// Whether to allow non-standard extensions to semantic versioning. /// The parsed representation. /// Returns whether parsing the version succeeded. - public static bool TryParseNonStandard(string version, out ISemanticVersion parsed) + public static bool TryParse(string version, bool allowNonStandard, out ISemanticVersion parsed) { try { - parsed = new SemanticVersion(version, true); + parsed = new SemanticVersion(version, allowNonStandard); return true; } catch diff --git a/src/SMAPI.Toolkit/Serialization/Converters/NonStandardSemanticVersionConverter.cs b/src/SMAPI.Toolkit/Serialization/Converters/NonStandardSemanticVersionConverter.cs new file mode 100644 index 00000000..6f870bcf --- /dev/null +++ b/src/SMAPI.Toolkit/Serialization/Converters/NonStandardSemanticVersionConverter.cs @@ -0,0 +1,15 @@ +namespace StardewModdingAPI.Toolkit.Serialization.Converters +{ + /// Handles deserialization of , allowing for non-standard extensions. + internal class NonStandardSemanticVersionConverter : SemanticVersionConverter + { + /********* + ** Public methods + *********/ + /// Construct an instance. + public NonStandardSemanticVersionConverter() + { + this.AllowNonStandard = true; + } + } +} diff --git a/src/SMAPI.Toolkit/Serialization/Converters/SemanticVersionConverter.cs b/src/SMAPI.Toolkit/Serialization/Converters/SemanticVersionConverter.cs index e1b9db1d..3604956b 100644 --- a/src/SMAPI.Toolkit/Serialization/Converters/SemanticVersionConverter.cs +++ b/src/SMAPI.Toolkit/Serialization/Converters/SemanticVersionConverter.cs @@ -7,6 +7,13 @@ namespace StardewModdingAPI.Toolkit.Serialization.Converters /// Handles deserialization of . internal class SemanticVersionConverter : JsonConverter { + /********* + ** Fields + *********/ + /// Whether to allow non-standard extensions to semantic versioning. + protected bool AllowNonStandard { get; set; } + + /********* ** Accessors *********/ @@ -78,7 +85,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Converters { if (string.IsNullOrWhiteSpace(str)) return null; - if (!SemanticVersion.TryParse(str, out ISemanticVersion version)) + if (!SemanticVersion.TryParse(str, allowNonStandard: this.AllowNonStandard, out ISemanticVersion version)) throw new SParseException($"Can't parse semantic version from invalid value '{str}', should be formatted like 1.2, 1.2.30, or 1.2.30-beta (path: {path})."); return version; } diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index 8370fe09..06768f03 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -296,7 +296,7 @@ namespace StardewModdingAPI.Web.Controllers { if (result.Version == null) result.SetError(RemoteModStatus.InvalidData, $"The update key '{updateKey}' matches a mod with no version number."); - else if (!this.TryParseVersion(result.Version, allowNonStandardVersions, out _)) + else if (!SemanticVersion.TryParse(result.Version, allowNonStandardVersions, out _)) result.SetError(RemoteModStatus.InvalidData, $"The update key '{updateKey}' matches a mod with invalid semantic version '{result.Version}'."); } @@ -360,11 +360,11 @@ namespace StardewModdingAPI.Web.Controllers { // try mapped version string rawNewVersion = this.GetRawMappedVersion(version, map, allowNonStandard); - if (this.TryParseVersion(rawNewVersion, allowNonStandard, out ISemanticVersion parsedNew)) + if (SemanticVersion.TryParse(rawNewVersion, allowNonStandard, out ISemanticVersion parsedNew)) return parsedNew; // return original version - return this.TryParseVersion(version, allowNonStandard, out ISemanticVersion parsedOld) + return SemanticVersion.TryParse(version, allowNonStandard, out ISemanticVersion parsedOld) ? parsedOld : null; } @@ -383,31 +383,19 @@ namespace StardewModdingAPI.Web.Controllers return map[version]; // match parsed version - if (this.TryParseVersion(version, allowNonStandard, out ISemanticVersion parsed)) + if (SemanticVersion.TryParse(version, allowNonStandard, out ISemanticVersion parsed)) { if (map.ContainsKey(parsed.ToString())) return map[parsed.ToString()]; foreach (var pair in map) { - if (this.TryParseVersion(pair.Key, allowNonStandard, out ISemanticVersion target) && parsed.Equals(target) && this.TryParseVersion(pair.Value, allowNonStandard, out ISemanticVersion newVersion)) + if (SemanticVersion.TryParse(pair.Key, allowNonStandard, out ISemanticVersion target) && parsed.Equals(target) && SemanticVersion.TryParse(pair.Value, allowNonStandard, out ISemanticVersion newVersion)) return newVersion.ToString(); } } return version; } - - /// Try to parse a version string. - /// The version string. - /// Whether to allow non-standard versions. - /// The parsed representation. - /// Returns whether parsing the version succeeded. - public bool TryParseVersion(string version, bool allowNonStandard, out ISemanticVersion parsed) - { - return allowNonStandard - ? SemanticVersion.TryParseNonStandard(version, out parsed) - : SemanticVersion.TryParse(version, out parsed); - } } } diff --git a/src/SMAPI.Web/Framework/VersionConstraint.cs b/src/SMAPI.Web/Framework/VersionConstraint.cs index 72f5ef84..f0c57c41 100644 --- a/src/SMAPI.Web/Framework/VersionConstraint.cs +++ b/src/SMAPI.Web/Framework/VersionConstraint.cs @@ -28,7 +28,7 @@ namespace StardewModdingAPI.Web.Framework return values.TryGetValue(routeKey, out object routeValue) && routeValue is string routeStr - && SemanticVersion.TryParseNonStandard(routeStr, out _); + && SemanticVersion.TryParse(routeStr, allowNonStandard: true, out _); } } } -- cgit From d3ec98fec8077026d3a97a74d4efc471ab37ad67 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 22 Feb 2020 11:26:05 -0500 Subject: update packages --- docs/release-notes.md | 1 + .../SMAPI.ModBuildConfig.Analyzer.Tests.csproj | 2 +- src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 2 +- src/SMAPI.Web/SMAPI.Web.csproj | 6 +++--- src/SMAPI/SMAPI.csproj | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/SMAPI.Toolkit') diff --git a/docs/release-notes.md b/docs/release-notes.md index 8ea6a9ea..fe43412a 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -20,6 +20,7 @@ * Added `helper.Input.GetState` to get the low-level state of a button. * **[Breaking change]** Map tilesheets are no loaded from `Content` if they can't be found in `Content/Maps`. This reflects an upcoming change in the game to delete map tilesheets under `Content`. * Improved map tilesheet errors so they provide more info. + * Updated dependencies (including Mono.Cecil 0.11.1 → 0.11.2). * Fixed dialogue propagation clearing marriage dialogue. * Fixed issue where SMAPI didn't call `IAssetEditor` with the actual type if a mod loaded an asset using `content.Load`. diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj b/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj index c1d5626f..e2be66d9 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj @@ -7,7 +7,7 @@ - + all diff --git a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj index 16a97dbf..a7de7166 100644 --- a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj +++ b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/SMAPI.Web/SMAPI.Web.csproj b/src/SMAPI.Web/SMAPI.Web.csproj index 148631a9..97bea0fb 100644 --- a/src/SMAPI.Web/SMAPI.Web.csproj +++ b/src/SMAPI.Web/SMAPI.Web.csproj @@ -12,11 +12,11 @@ - + - + @@ -25,7 +25,7 @@ - + diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index c5d0f247..c17f13c4 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -15,9 +15,9 @@ - + - + -- cgit