summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Caching/Wiki
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework/Caching/Wiki')
-rw-r--r--src/SMAPI.Web/Framework/Caching/Wiki/IWikiCacheRepository.cs7
-rw-r--r--src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs11
-rw-r--r--src/SMAPI.Web/Framework/Caching/Wiki/WikiMetadata.cs9
3 files changed, 13 insertions, 14 deletions
diff --git a/src/SMAPI.Web/Framework/Caching/Wiki/IWikiCacheRepository.cs b/src/SMAPI.Web/Framework/Caching/Wiki/IWikiCacheRepository.cs
index 2ab7ea5a..b8a0df34 100644
--- a/src/SMAPI.Web/Framework/Caching/Wiki/IWikiCacheRepository.cs
+++ b/src/SMAPI.Web/Framework/Caching/Wiki/IWikiCacheRepository.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using StardewModdingAPI.Toolkit.Framework.Clients.Wiki;
namespace StardewModdingAPI.Web.Framework.Caching.Wiki
@@ -12,16 +13,16 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki
*********/
/// <summary>Get the cached wiki metadata.</summary>
/// <param name="metadata">The fetched metadata.</param>
- bool TryGetWikiMetadata(out Cached<WikiMetadata> metadata);
+ bool TryGetWikiMetadata([NotNullWhen(true)] out Cached<WikiMetadata>? metadata);
/// <summary>Get the cached wiki mods.</summary>
/// <param name="filter">A filter to apply, if any.</param>
- IEnumerable<Cached<WikiModEntry>> GetWikiMods(Func<WikiModEntry, bool> filter = null);
+ IEnumerable<Cached<WikiModEntry>> GetWikiMods(Func<WikiModEntry, bool>? filter = null);
/// <summary>Save data fetched from the wiki compatibility list.</summary>
/// <param name="stableVersion">The current stable Stardew Valley version.</param>
/// <param name="betaVersion">The current beta Stardew Valley version.</param>
/// <param name="mods">The mod data.</param>
- void SaveWikiData(string stableVersion, string betaVersion, IEnumerable<WikiModEntry> mods);
+ void SaveWikiData(string? stableVersion, string? betaVersion, IEnumerable<WikiModEntry> mods);
}
}
diff --git a/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs b/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs
index 064a7c3c..8b4338e2 100644
--- a/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs
+++ b/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using StardewModdingAPI.Toolkit.Framework.Clients.Wiki;
@@ -12,10 +13,10 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki
** Fields
*********/
/// <summary>The saved wiki metadata.</summary>
- private Cached<WikiMetadata> Metadata;
+ private Cached<WikiMetadata>? Metadata;
/// <summary>The cached wiki data.</summary>
- private Cached<WikiModEntry>[] Mods = new Cached<WikiModEntry>[0];
+ private Cached<WikiModEntry>[] Mods = Array.Empty<Cached<WikiModEntry>>();
/*********
@@ -23,7 +24,7 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki
*********/
/// <summary>Get the cached wiki metadata.</summary>
/// <param name="metadata">The fetched metadata.</param>
- public bool TryGetWikiMetadata(out Cached<WikiMetadata> metadata)
+ public bool TryGetWikiMetadata([NotNullWhen(true)] out Cached<WikiMetadata>? metadata)
{
metadata = this.Metadata;
return metadata != null;
@@ -31,7 +32,7 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki
/// <summary>Get the cached wiki mods.</summary>
/// <param name="filter">A filter to apply, if any.</param>
- public IEnumerable<Cached<WikiModEntry>> GetWikiMods(Func<WikiModEntry, bool> filter = null)
+ public IEnumerable<Cached<WikiModEntry>> GetWikiMods(Func<WikiModEntry, bool>? filter = null)
{
foreach (var mod in this.Mods)
{
@@ -44,7 +45,7 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki
/// <param name="stableVersion">The current stable Stardew Valley version.</param>
/// <param name="betaVersion">The current beta Stardew Valley version.</param>
/// <param name="mods">The mod data.</param>
- public void SaveWikiData(string stableVersion, string betaVersion, IEnumerable<WikiModEntry> mods)
+ public void SaveWikiData(string? stableVersion, string? betaVersion, IEnumerable<WikiModEntry> mods)
{
this.Metadata = new Cached<WikiMetadata>(new WikiMetadata(stableVersion, betaVersion));
this.Mods = mods.Select(mod => new Cached<WikiModEntry>(mod)).ToArray();
diff --git a/src/SMAPI.Web/Framework/Caching/Wiki/WikiMetadata.cs b/src/SMAPI.Web/Framework/Caching/Wiki/WikiMetadata.cs
index c04de4a5..f53ea201 100644
--- a/src/SMAPI.Web/Framework/Caching/Wiki/WikiMetadata.cs
+++ b/src/SMAPI.Web/Framework/Caching/Wiki/WikiMetadata.cs
@@ -7,22 +7,19 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki
** Accessors
*********/
/// <summary>The current stable Stardew Valley version.</summary>
- public string StableVersion { get; set; }
+ public string? StableVersion { get; }
/// <summary>The current beta Stardew Valley version.</summary>
- public string BetaVersion { get; set; }
+ public string? BetaVersion { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- public WikiMetadata() { }
-
- /// <summary>Construct an instance.</summary>
/// <param name="stableVersion">The current stable Stardew Valley version.</param>
/// <param name="betaVersion">The current beta Stardew Valley version.</param>
- public WikiMetadata(string stableVersion, string betaVersion)
+ public WikiMetadata(string? stableVersion, string? betaVersion)
{
this.StableVersion = stableVersion;
this.BetaVersion = betaVersion;