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/WebApi/ModSearchEntryModel.cs | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs') diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs index 8fe8fa2a..9c11e1db 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs @@ -1,6 +1,5 @@ -#nullable disable - using System; +using System.Linq; namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { @@ -11,37 +10,39 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi ** Accessors *********/ /// The unique mod ID. - public string ID { get; set; } + public string ID { get; } /// The namespaced mod update keys (if available). - public string[] UpdateKeys { get; set; } + public string[] UpdateKeys { get; private set; } /// The mod version installed by the local player. This is used for version mapping in some cases. - public ISemanticVersion InstalledVersion { get; set; } + public ISemanticVersion? InstalledVersion { get; } /// Whether the installed version is broken or could not be loaded. - public bool IsBroken { get; set; } + public bool IsBroken { get; } /********* ** Public methods *********/ - /// Construct an empty instance. - public ModSearchEntryModel() - { - // needed for JSON deserializing - } - /// Construct an instance. /// The unique mod ID. /// The version installed by the local player. This is used for version mapping in some cases. /// The namespaced mod update keys (if available). /// Whether the installed version is broken or could not be loaded. - public ModSearchEntryModel(string id, ISemanticVersion installedVersion, string[] updateKeys, bool isBroken = false) + public ModSearchEntryModel(string id, ISemanticVersion? installedVersion, string[]? updateKeys, bool isBroken = false) { this.ID = id; this.InstalledVersion = installedVersion; this.UpdateKeys = updateKeys ?? Array.Empty(); + this.IsBroken = isBroken; + } + + /// Add update keys for the mod. + /// The update keys to add. + public void AddUpdateKeys(params string[] updateKeys) + { + this.UpdateKeys = this.UpdateKeys.Concat(updateKeys).ToArray(); } } } -- cgit