diff --git a/docs/release-notes.md b/docs/release-notes.md
index 49545d50..0b0a37d8 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -12,6 +12,9 @@
* In multiplayer, the game/SMAPI window titles now show whether you're the main player or a farmhand.
* Fixed logged SMAPI errors not having line numbers on Linux/macOS.
+* For SMAPI toolkit users:
+ * Fixed `ModFolder` not being JSON-serializable.
+
## 3.18.3
Released 09 April 2023 for Stardew Valley 1.5.6 or later.
diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModFolder.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModFolder.cs
index da2a3c85..106e3622 100644
--- a/src/SMAPI.Toolkit/Framework/ModScanning/ModFolder.cs
+++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModFolder.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using Newtonsoft.Json;
using StardewModdingAPI.Toolkit.Serialization.Models;
using StardewModdingAPI.Toolkit.Utilities;
@@ -9,14 +10,25 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
/// The info about a mod read from its folder.
public class ModFolder
{
+ /*********
+ ** Fields
+ *********/
+ /// The backing field for .
+ private DirectoryInfo? DirectoryImpl;
+
+
/*********
** Accessors
*********/
/// A suggested display name for the mod folder.
public string DisplayName { get; }
+ /// The folder path containing the mod's manifest.json.
+ public string DirectoryPath { get; }
+
/// The folder containing the mod's manifest.json.
- public DirectoryInfo Directory { get; }
+ [JsonIgnore]
+ public DirectoryInfo Directory => this.DirectoryImpl ??= new DirectoryInfo(this.DirectoryPath);
/// The mod type.
public ModType Type { get; }
@@ -52,7 +64,8 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
public ModFolder(DirectoryInfo root, DirectoryInfo directory, ModType type, Manifest? manifest, ModParseError manifestParseError, string? manifestParseErrorText)
{
// save info
- this.Directory = directory;
+ this.DirectoryImpl = directory;
+ this.DirectoryPath = directory.FullName;
this.Type = type;
this.Manifest = manifest;
this.ManifestParseError = manifestParseError;
@@ -64,6 +77,24 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
: PathUtilities.GetRelativePath(root.FullName, directory.FullName);
}
+ /// Construct an instance.
+ /// A suggested display name for the mod folder.
+ /// The folder path containing the mod's manifest.json.
+ /// The mod type.
+ /// The mod manifest.
+ /// The error which occurred parsing the manifest, if any.
+ /// A human-readable message for the , if any.
+ [JsonConstructor]
+ public ModFolder(string displayName, string directoryPath, ModType type, Manifest? manifest, ModParseError manifestParseError, string? manifestParseErrorText)
+ {
+ this.DisplayName = displayName;
+ this.DirectoryPath = directoryPath;
+ this.Type = type;
+ this.Manifest = manifest;
+ this.ManifestParseError = manifestParseError;
+ this.ManifestParseErrorText = manifestParseErrorText;
+ }
+
/// Get the update keys for a mod.
/// The mod manifest.
public IEnumerable GetUpdateKeys(Manifest manifest)