diff --git a/src/AcDream.Core/Plugins/PluginManifest.cs b/src/AcDream.Core/Plugins/PluginManifest.cs index 446178c..da16dcf 100644 --- a/src/AcDream.Core/Plugins/PluginManifest.cs +++ b/src/AcDream.Core/Plugins/PluginManifest.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Text.Json.Serialization; namespace AcDream.Core.Plugins; @@ -26,10 +25,10 @@ public sealed record PluginManifest( if (dto is null) throw new PluginManifestException("manifest is empty"); - Require(dto.Id, nameof(dto.Id)); - Require(dto.DisplayName, nameof(dto.DisplayName)); - Require(dto.Version, nameof(dto.Version)); - Require(dto.EntryDll, nameof(dto.EntryDll)); + Require(dto.Id, "id"); + Require(dto.DisplayName, "displayName"); + Require(dto.Version, "version"); + Require(dto.EntryDll, "entryDll"); if (dto.ApiVersion <= 0) throw new PluginManifestException("apiVersion must be >= 1"); @@ -42,11 +41,10 @@ public sealed record PluginManifest( dto.Dependencies ?? Array.Empty()); } - private static void Require(string? value, string fieldName) + private static void Require(string? value, string jsonFieldName) { if (string.IsNullOrWhiteSpace(value)) - throw new PluginManifestException( - $"missing required field: {char.ToLowerInvariant(fieldName[0])}{fieldName[1..]}"); + throw new PluginManifestException($"missing required field: {jsonFieldName}"); } private static readonly JsonSerializerOptions JsonOptions = new() diff --git a/tests/AcDream.Core.Tests/Plugins/PluginManifestTests.cs b/tests/AcDream.Core.Tests/Plugins/PluginManifestTests.cs index 180eeee..cfe08bc 100644 --- a/tests/AcDream.Core.Tests/Plugins/PluginManifestTests.cs +++ b/tests/AcDream.Core.Tests/Plugins/PluginManifestTests.cs @@ -34,7 +34,7 @@ public class PluginManifestTests """; var ex = Assert.Throws(() => PluginManifest.Parse(json)); - Assert.Contains("displayName", ex.Message); + Assert.Equal("missing required field: displayName", ex.Message); } [Fact]