summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/ModInfoModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework/ModInfoModel.cs')
-rw-r--r--src/SMAPI.Web/Framework/ModInfoModel.cs33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/SMAPI.Web/Framework/ModInfoModel.cs b/src/SMAPI.Web/Framework/ModInfoModel.cs
index 021d14fb..e70b60bf 100644
--- a/src/SMAPI.Web/Framework/ModInfoModel.cs
+++ b/src/SMAPI.Web/Framework/ModInfoModel.cs
@@ -1,4 +1,5 @@
-#nullable disable
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
namespace StardewModdingAPI.Web.Framework
{
@@ -9,22 +10,22 @@ namespace StardewModdingAPI.Web.Framework
** Accessors
*********/
/// <summary>The mod name.</summary>
- public string Name { get; set; }
+ public string? Name { get; private set; }
+
+ /// <summary>The mod's web URL.</summary>
+ public string? Url { get; private set; }
/// <summary>The mod's latest version.</summary>
- public ISemanticVersion Version { get; set; }
+ public ISemanticVersion? Version { get; private set; }
/// <summary>The mod's latest optional or prerelease version, if newer than <see cref="Version"/>.</summary>
- public ISemanticVersion PreviewVersion { get; set; }
-
- /// <summary>The mod's web URL.</summary>
- public string Url { get; set; }
+ public ISemanticVersion? PreviewVersion { get; private set; }
/// <summary>The mod availability status on the remote site.</summary>
- public RemoteModStatus Status { get; set; } = RemoteModStatus.Ok;
+ public RemoteModStatus Status { get; private set; }
/// <summary>The error message indicating why the mod is invalid (if applicable).</summary>
- public string Error { get; set; }
+ public string? Error { get; private set; }
/*********
@@ -35,19 +36,24 @@ namespace StardewModdingAPI.Web.Framework
/// <summary>Construct an instance.</summary>
/// <param name="name">The mod name.</param>
+ /// <param name="url">The mod's web URL.</param>
/// <param name="version">The semantic version for the mod's latest release.</param>
/// <param name="previewVersion">The semantic version for the mod's latest preview release, if available and different from <see cref="Version"/>.</param>
- /// <param name="url">The mod's web URL.</param>
- public ModInfoModel(string name, ISemanticVersion version, string url, ISemanticVersion previewVersion = null)
+ /// <param name="status">The mod availability status on the remote site.</param>
+ /// <param name="error">The error message indicating why the mod is invalid (if applicable).</param>
+ [JsonConstructor]
+ public ModInfoModel(string name, string url, ISemanticVersion? version, ISemanticVersion? previewVersion = null, RemoteModStatus status = RemoteModStatus.Ok, string? error = null)
{
this
.SetBasicInfo(name, url)
- .SetVersions(version, previewVersion);
+ .SetVersions(version!, previewVersion)
+ .SetError(status, error!);
}
/// <summary>Set the basic mod info.</summary>
/// <param name="name">The mod name.</param>
/// <param name="url">The mod's web URL.</param>
+ [MemberNotNull(nameof(ModInfoModel.Name), nameof(ModInfoModel.Url))]
public ModInfoModel SetBasicInfo(string name, string url)
{
this.Name = name;
@@ -59,7 +65,8 @@ namespace StardewModdingAPI.Web.Framework
/// <summary>Set the mod version info.</summary>
/// <param name="version">The semantic version for the mod's latest release.</param>
/// <param name="previewVersion">The semantic version for the mod's latest preview release, if available and different from <see cref="Version"/>.</param>
- public ModInfoModel SetVersions(ISemanticVersion version, ISemanticVersion previewVersion = null)
+ [MemberNotNull(nameof(ModInfoModel.Version))]
+ public ModInfoModel SetVersions(ISemanticVersion version, ISemanticVersion? previewVersion = null)
{
this.Version = version;
this.PreviewVersion = previewVersion;