diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-07-05 22:09:46 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-07-05 22:09:46 -0400 |
commit | 0ba4fd1785fc6a6aa931f18552261f33c2a2c0ef (patch) | |
tree | 6f95776a808e73a5d638b49eb951c0971c83185a /src/SMAPI.Web/Framework | |
parent | f3a4b316b7294fea897514a08c45bc9d926a00c6 (diff) | |
download | SMAPI-0ba4fd1785fc6a6aa931f18552261f33c2a2c0ef.tar.gz SMAPI-0ba4fd1785fc6a6aa931f18552261f33c2a2c0ef.tar.bz2 SMAPI-0ba4fd1785fc6a6aa931f18552261f33c2a2c0ef.zip |
detect missing/outdated Error Handler for 'suggested fixes' section
Diffstat (limited to 'src/SMAPI.Web/Framework')
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/LogParser.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs | 32 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs | 3 |
3 files changed, 36 insertions, 1 deletions
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs index 7fc8f958..0efa62c5 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -200,6 +200,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing log.GameVersion = match.Groups["gameVersion"].Value; log.OperatingSystem = match.Groups["os"].Value; smapiMod.OverrideVersion(log.ApiVersion); + + log.ApiVersionParsed = smapiMod.GetParsedVersion(); } // mod path line diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs index 4b80a830..557f08ff 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs @@ -1,4 +1,6 @@ +using System; using System.Diagnostics.CodeAnalysis; +using StardewModdingAPI.Toolkit; namespace StardewModdingAPI.Web.Framework.LogParsing.Models { @@ -6,6 +8,13 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models public class LogModInfo { /********* + ** Private fields + *********/ + /// <summary>The parsed mod version, if valid.</summary> + private Lazy<ISemanticVersion?> ParsedVersionImpl; + + + /********* ** Accessors *********/ /// <summary>The mod name.</summary> @@ -68,7 +77,6 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models { this.Name = name; this.Author = author; - this.Version = version; this.Description = description; this.UpdateVersion = updateVersion; this.UpdateLink = updateLink; @@ -82,6 +90,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models this.IsContentPack = !string.IsNullOrWhiteSpace(this.ContentPackFor); this.IsCodeMod = !this.IsContentPack; } + + this.OverrideVersion(version); } /// <summary>Add an update alert for this mod.</summary> @@ -95,9 +105,29 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models /// <summary>Override the version number, for cases like SMAPI itself where the version is only known later during parsing.</summary> /// <param name="version">The new mod version.</param> + [MemberNotNull(nameof(LogModInfo.Version), nameof(LogModInfo.ParsedVersionImpl))] public void OverrideVersion(string version) { this.Version = version; + this.ParsedVersionImpl = new Lazy<ISemanticVersion?>(this.ParseVersion); + } + + /// <summary>Get the semantic version for this mod, if it's valid.</summary> + public ISemanticVersion? GetParsedVersion() + { + return this.ParsedVersionImpl.Value; + } + + + /********* + ** Private methods + *********/ + /// <summary>Get the semantic version for this mod, if it's valid.</summary> + public ISemanticVersion? ParseVersion() + { + return !string.IsNullOrWhiteSpace(this.Version) && SemanticVersion.TryParse(this.Version, out ISemanticVersion? version) + ? version + : null; } } } diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs index 6951e434..3f649199 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs @@ -28,6 +28,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models /// <summary>The SMAPI version.</summary> public string? ApiVersion { get; set; } + /// <summary>The parsed SMAPI version, if it's valid.</summary> + public ISemanticVersion? ApiVersionParsed { get; set; } + /// <summary>The game version.</summary> public string? GameVersion { get; set; } |