From 0b48c1748b354458059c7607415288de072b01e9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 12 Apr 2022 19:15:39 -0400 Subject: enable nullable annotations in the web project & related code (#837) --- .../Clients/Nexus/ResponseModels/NexusMod.cs | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'src/SMAPI.Web/Framework/Clients/Nexus/ResponseModels/NexusMod.cs') diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/ResponseModels/NexusMod.cs b/src/SMAPI.Web/Framework/Clients/Nexus/ResponseModels/NexusMod.cs index 358c4633..3155cfda 100644 --- a/src/SMAPI.Web/Framework/Clients/Nexus/ResponseModels/NexusMod.cs +++ b/src/SMAPI.Web/Framework/Clients/Nexus/ResponseModels/NexusMod.cs @@ -1,5 +1,4 @@ -#nullable disable - +using System; using Newtonsoft.Json; namespace StardewModdingAPI.Web.Framework.Clients.Nexus.ResponseModels @@ -11,25 +10,53 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus.ResponseModels ** Accessors *********/ /// The mod name. - public string Name { get; set; } + public string? Name { get; } /// The mod's semantic version number. - public string Version { get; set; } + public string? Version { get; } /// The mod's web URL. [JsonProperty("mod_page_uri")] - public string Url { get; set; } + public string? Url { get; } /// The mod's publication status. [JsonIgnore] - public NexusModStatus Status { get; set; } = NexusModStatus.Ok; + public NexusModStatus Status { get; } /// The files available to download. [JsonIgnore] - public IModDownload[] Downloads { get; set; } + public IModDownload[] Downloads { get; } /// A custom user-friendly error which indicates why fetching the mod info failed (if applicable). [JsonIgnore] - public string Error { get; set; } + public string? Error { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The mod name + /// The mod's semantic version number. + /// The mod's web URL. + /// The files available to download. + public NexusMod(string name, string? version, string url, IModDownload[] downloads) + { + this.Name = name; + this.Version = version; + this.Url = url; + this.Status = NexusModStatus.Ok; + this.Downloads = downloads; + } + + /// Construct an instance. + /// The mod's publication status. + /// A custom user-friendly error which indicates why fetching the mod info failed (if applicable). + public NexusMod(NexusModStatus status, string error) + { + this.Status = status; + this.Error = error; + this.Downloads = Array.Empty(); + } } } -- cgit