fix ModFolder not being JSON-serializable
This commit is contained in:
parent
342b91ff80
commit
76a0497684
|
@ -12,6 +12,9 @@
|
||||||
* In multiplayer, the game/SMAPI window titles now show whether you're the main player or a farmhand.
|
* 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.
|
* Fixed logged SMAPI errors not having line numbers on Linux/macOS.
|
||||||
|
|
||||||
|
* For SMAPI toolkit users:
|
||||||
|
* Fixed `ModFolder` not being JSON-serializable.
|
||||||
|
|
||||||
## 3.18.3
|
## 3.18.3
|
||||||
Released 09 April 2023 for Stardew Valley 1.5.6 or later.
|
Released 09 April 2023 for Stardew Valley 1.5.6 or later.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using StardewModdingAPI.Toolkit.Serialization.Models;
|
using StardewModdingAPI.Toolkit.Serialization.Models;
|
||||||
using StardewModdingAPI.Toolkit.Utilities;
|
using StardewModdingAPI.Toolkit.Utilities;
|
||||||
|
|
||||||
|
@ -9,14 +10,25 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
|
||||||
/// <summary>The info about a mod read from its folder.</summary>
|
/// <summary>The info about a mod read from its folder.</summary>
|
||||||
public class ModFolder
|
public class ModFolder
|
||||||
{
|
{
|
||||||
|
/*********
|
||||||
|
** Fields
|
||||||
|
*********/
|
||||||
|
/// <summary>The backing field for <see cref="Directory"/>.</summary>
|
||||||
|
private DirectoryInfo? DirectoryImpl;
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Accessors
|
** Accessors
|
||||||
*********/
|
*********/
|
||||||
/// <summary>A suggested display name for the mod folder.</summary>
|
/// <summary>A suggested display name for the mod folder.</summary>
|
||||||
public string DisplayName { get; }
|
public string DisplayName { get; }
|
||||||
|
|
||||||
|
/// <summary>The folder path containing the mod's manifest.json.</summary>
|
||||||
|
public string DirectoryPath { get; }
|
||||||
|
|
||||||
/// <summary>The folder containing the mod's manifest.json.</summary>
|
/// <summary>The folder containing the mod's manifest.json.</summary>
|
||||||
public DirectoryInfo Directory { get; }
|
[JsonIgnore]
|
||||||
|
public DirectoryInfo Directory => this.DirectoryImpl ??= new DirectoryInfo(this.DirectoryPath);
|
||||||
|
|
||||||
/// <summary>The mod type.</summary>
|
/// <summary>The mod type.</summary>
|
||||||
public ModType Type { get; }
|
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)
|
public ModFolder(DirectoryInfo root, DirectoryInfo directory, ModType type, Manifest? manifest, ModParseError manifestParseError, string? manifestParseErrorText)
|
||||||
{
|
{
|
||||||
// save info
|
// save info
|
||||||
this.Directory = directory;
|
this.DirectoryImpl = directory;
|
||||||
|
this.DirectoryPath = directory.FullName;
|
||||||
this.Type = type;
|
this.Type = type;
|
||||||
this.Manifest = manifest;
|
this.Manifest = manifest;
|
||||||
this.ManifestParseError = manifestParseError;
|
this.ManifestParseError = manifestParseError;
|
||||||
|
@ -64,6 +77,24 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
|
||||||
: PathUtilities.GetRelativePath(root.FullName, directory.FullName);
|
: PathUtilities.GetRelativePath(root.FullName, directory.FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Construct an instance.</summary>
|
||||||
|
/// <param name="displayName">A suggested display name for the mod folder.</param>
|
||||||
|
/// <param name="directoryPath">The folder path containing the mod's manifest.json.</param>
|
||||||
|
/// <param name="type">The mod type.</param>
|
||||||
|
/// <param name="manifest">The mod manifest.</param>
|
||||||
|
/// <param name="manifestParseError">The error which occurred parsing the manifest, if any.</param>
|
||||||
|
/// <param name="manifestParseErrorText">A human-readable message for the <paramref name="manifestParseError"/>, if any.</param>
|
||||||
|
[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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Get the update keys for a mod.</summary>
|
/// <summary>Get the update keys for a mod.</summary>
|
||||||
/// <param name="manifest">The mod manifest.</param>
|
/// <param name="manifest">The mod manifest.</param>
|
||||||
public IEnumerable<string> GetUpdateKeys(Manifest manifest)
|
public IEnumerable<string> GetUpdateKeys(Manifest manifest)
|
||||||
|
|
Loading…
Reference in New Issue