From b7fb188513a844afed66b9b292ecfddb58528a42 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 7 Oct 2017 23:57:47 -0400 Subject: rename shared project for broader use --- src/SMAPI.Common/Models/ModInfoModel.cs | 48 ++++++++++++++++++++++++++++++++ src/SMAPI.Common/Models/ModSeachModel.cs | 30 ++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/SMAPI.Common/Models/ModInfoModel.cs create mode 100644 src/SMAPI.Common/Models/ModSeachModel.cs (limited to 'src/SMAPI.Common/Models') diff --git a/src/SMAPI.Common/Models/ModInfoModel.cs b/src/SMAPI.Common/Models/ModInfoModel.cs new file mode 100644 index 00000000..e071c0bb --- /dev/null +++ b/src/SMAPI.Common/Models/ModInfoModel.cs @@ -0,0 +1,48 @@ +using Newtonsoft.Json; + +namespace StardewModdingAPI.Common.Models +{ + /// Generic metadata about a mod. + internal class ModInfoModel + { + /********* + ** Accessors + *********/ + /// The mod name. + public string Name { get; } + + /// The mod's semantic version number. + public string Version { get; } + + /// The mod's web URL. + public string Url { get; } + + /// The error message indicating why the mod is invalid (if applicable). + public string Error { get; } + + + /********* + ** Public methods + *********/ + /// Construct a valid instance. + /// The mod name. + /// The mod's semantic version number. + /// The mod's web URL. + /// The error message indicating why the mod is invalid (if applicable). + [JsonConstructor] + public ModInfoModel(string name, string version, string url, string error = null) + { + this.Name = name; + this.Version = version; + this.Url = url; + this.Error = error; // mainly initialised here for the JSON deserialiser + } + + /// Construct an valid instance. + /// The error message indicating why the mod is invalid. + public ModInfoModel(string error) + { + this.Error = error; + } + } +} diff --git a/src/SMAPI.Common/Models/ModSeachModel.cs b/src/SMAPI.Common/Models/ModSeachModel.cs new file mode 100644 index 00000000..3f69f0ae --- /dev/null +++ b/src/SMAPI.Common/Models/ModSeachModel.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Linq; + +namespace StardewModdingAPI.Common.Models +{ + /// Specifies mods whose update-check info to fetch. + internal class ModSearchModel + { + /********* + ** Accessors + *********/ + /// The namespaced mod keys to search. + public string[] ModKeys { get; set; } + + + /********* + ** Public methods + *********/ + /// Construct an empty instance. + /// This constructed is needed for JSON deserialisation. + public ModSearchModel() { } + + /// Construct an valid instance. + /// The namespaced mod keys to search. + public ModSearchModel(IEnumerable modKeys) + { + this.ModKeys = modKeys.ToArray(); + } + } +} -- cgit From ca58da37cd8cd9818b71a2b67b5186e7ab81a73c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 Oct 2017 02:13:08 -0400 Subject: add prerelease tag to zip name & normalise version format --- src/SMAPI.Common/Models/ModInfoModel.cs | 11 ++++------- src/SMAPI.Common/SemanticVersionImpl.cs | 2 -- .../StardewModdingAPI.ModBuildConfig.csproj | 3 ++- src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs | 4 +++- src/SMAPI.sln | 1 + 5 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/SMAPI.Common/Models') diff --git a/src/SMAPI.Common/Models/ModInfoModel.cs b/src/SMAPI.Common/Models/ModInfoModel.cs index e071c0bb..4daa7064 100644 --- a/src/SMAPI.Common/Models/ModInfoModel.cs +++ b/src/SMAPI.Common/Models/ModInfoModel.cs @@ -1,5 +1,3 @@ -using Newtonsoft.Json; - namespace StardewModdingAPI.Common.Models { /// Generic metadata about a mod. @@ -9,16 +7,16 @@ namespace StardewModdingAPI.Common.Models ** Accessors *********/ /// The mod name. - public string Name { get; } + public string Name { get; set; } /// The mod's semantic version number. - public string Version { get; } + public string Version { get; set; } /// The mod's web URL. - public string Url { get; } + public string Url { get; set; } /// The error message indicating why the mod is invalid (if applicable). - public string Error { get; } + public string Error { get; set; } /********* @@ -29,7 +27,6 @@ namespace StardewModdingAPI.Common.Models /// The mod's semantic version number. /// The mod's web URL. /// The error message indicating why the mod is invalid (if applicable). - [JsonConstructor] public ModInfoModel(string name, string version, string url, string error = null) { this.Name = name; diff --git a/src/SMAPI.Common/SemanticVersionImpl.cs b/src/SMAPI.Common/SemanticVersionImpl.cs index e0f68a7e..193d23f9 100644 --- a/src/SMAPI.Common/SemanticVersionImpl.cs +++ b/src/SMAPI.Common/SemanticVersionImpl.cs @@ -1,6 +1,5 @@ using System; using System.Text.RegularExpressions; -using Newtonsoft.Json; namespace StardewModdingAPI.Common { @@ -41,7 +40,6 @@ namespace StardewModdingAPI.Common /// The minor version incremented for backwards-compatible changes. /// The patch version for backwards-compatible bug fixes. /// An optional prerelease tag. - [JsonConstructor] public SemanticVersionImpl(int major, int minor, int patch, string tag = null) { this.Major = major; diff --git a/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj index 9b68fe57..d32ccd9f 100644 --- a/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj @@ -1,4 +1,4 @@ - + @@ -55,5 +55,6 @@ + \ No newline at end of file diff --git a/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs b/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs index c8582488..26f2ed44 100644 --- a/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs +++ b/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Web.Script.Serialization; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using StardewModdingAPI.Common; namespace StardewModdingAPI.ModBuildConfig.Tasks { @@ -115,8 +116,9 @@ namespace StardewModdingAPI.ModBuildConfig.Tasks int major = versionFields.ContainsKey("MajorVersion") ? (int)versionFields["MajorVersion"] : 0; int minor = versionFields.ContainsKey("MinorVersion") ? (int)versionFields["MinorVersion"] : 0; int patch = versionFields.ContainsKey("PatchVersion") ? (int)versionFields["PatchVersion"] : 0; + string tag = versionFields.ContainsKey("Build") ? (string)versionFields["Build"] : null; - return $"{major}.{minor}.{patch}"; + return new SemanticVersionImpl(major, minor, patch, tag).ToString(); } /// Get a case-insensitive dictionary matching the given JSON. diff --git a/src/SMAPI.sln b/src/SMAPI.sln index d43ba1c2..5590d497 100644 --- a/src/SMAPI.sln +++ b/src/SMAPI.sln @@ -50,6 +50,7 @@ EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution SMAPI.Common\StardewModdingAPI.Common.projitems*{2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc}*SharedItemsImports = 13 + SMAPI.Common\StardewModdingAPI.Common.projitems*{ea4f1e80-743f-4a1d-9757-ae66904a196a}*SharedItemsImports = 4 SMAPI.Common\StardewModdingAPI.Common.projitems*{f1a573b0-f436-472c-ae29-0b91ea6b9f8f}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution -- cgit From 4f8994a1debdc4f1b2cb39854977e3b00a851992 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 9 Oct 2017 21:03:25 -0400 Subject: fix update check error --- src/SMAPI.Common/Models/ModInfoModel.cs | 11 +++++++++-- src/SMAPI.Common/Models/ModSeachModel.cs | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Common/Models') diff --git a/src/SMAPI.Common/Models/ModInfoModel.cs b/src/SMAPI.Common/Models/ModInfoModel.cs index 4daa7064..48305cb8 100644 --- a/src/SMAPI.Common/Models/ModInfoModel.cs +++ b/src/SMAPI.Common/Models/ModInfoModel.cs @@ -22,7 +22,14 @@ namespace StardewModdingAPI.Common.Models /********* ** Public methods *********/ - /// Construct a valid instance. + /// Construct an empty instance. + public ModInfoModel() + { + // needed for JSON deserialising + } + + + /// Construct an instance. /// The mod name. /// The mod's semantic version number. /// The mod's web URL. @@ -35,7 +42,7 @@ namespace StardewModdingAPI.Common.Models this.Error = error; // mainly initialised here for the JSON deserialiser } - /// Construct an valid instance. + /// Construct an instance. /// The error message indicating why the mod is invalid. public ModInfoModel(string error) { diff --git a/src/SMAPI.Common/Models/ModSeachModel.cs b/src/SMAPI.Common/Models/ModSeachModel.cs index 3f69f0ae..13b05d2d 100644 --- a/src/SMAPI.Common/Models/ModSeachModel.cs +++ b/src/SMAPI.Common/Models/ModSeachModel.cs @@ -17,10 +17,12 @@ namespace StardewModdingAPI.Common.Models ** Public methods *********/ /// Construct an empty instance. - /// This constructed is needed for JSON deserialisation. - public ModSearchModel() { } + public ModSearchModel() + { + // needed for JSON deserialising + } - /// Construct an valid instance. + /// Construct an instance. /// The namespaced mod keys to search. public ModSearchModel(IEnumerable modKeys) { -- cgit