From 998106a821d30d5e4e7cf074e99c1456277a9a4f Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 13 Mar 2026 17:39:44 +0100 Subject: [PATCH] Fix WireMockLogger implementation in dotnet-WireMock --- .../Matchers/Request/MatchDetail.cs | 2 +- .../Matchers/Request/RequestMatchResult.cs | 4 +--- src/WireMock.Net.Shared/Matchers/MatchResult.cs | 3 +-- src/dotnet-WireMock.Net/Json/SourceGenerationContext.cs | 4 ++++ src/dotnet-WireMock.Net/WireMockLogger.cs | 6 ------ 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/WireMock.Net.Abstractions/Matchers/Request/MatchDetail.cs b/src/WireMock.Net.Abstractions/Matchers/Request/MatchDetail.cs index b9dc4c6b6..69b653be1 100644 --- a/src/WireMock.Net.Abstractions/Matchers/Request/MatchDetail.cs +++ b/src/WireMock.Net.Abstractions/Matchers/Request/MatchDetail.cs @@ -10,7 +10,7 @@ public class MatchDetail /// /// Gets or sets the type of the matcher. /// - public required Type MatcherType { get; set; } + public required string MatcherType { get; set; } /// /// Gets or sets the type of the matcher. diff --git a/src/WireMock.Net.Minimal/Matchers/Request/RequestMatchResult.cs b/src/WireMock.Net.Minimal/Matchers/Request/RequestMatchResult.cs index 1884efd80..87d64e111 100644 --- a/src/WireMock.Net.Minimal/Matchers/Request/RequestMatchResult.cs +++ b/src/WireMock.Net.Minimal/Matchers/Request/RequestMatchResult.cs @@ -1,7 +1,5 @@ // Copyright © WireMock.Net -using System.Linq; - namespace WireMock.Matchers.Request; /// @@ -30,7 +28,7 @@ public double AddScore(Type matcherType, double score, Exception? exception) return AddMatchDetail(new MatchDetail { Name = matcherType.Name.Replace("RequestMessage", string.Empty), - MatcherType = matcherType, + MatcherType = matcherType.Name, Score = score, Exception = exception }); diff --git a/src/WireMock.Net.Shared/Matchers/MatchResult.cs b/src/WireMock.Net.Shared/Matchers/MatchResult.cs index a76f15fa9..4e5e38672 100644 --- a/src/WireMock.Net.Shared/Matchers/MatchResult.cs +++ b/src/WireMock.Net.Shared/Matchers/MatchResult.cs @@ -1,6 +1,5 @@ // Copyright © WireMock.Net -using System.Linq; using Stef.Validation; using WireMock.Extensions; using WireMock.Matchers.Request; @@ -119,7 +118,7 @@ public MatchDetail ToMatchDetail() return new MatchDetail { Name = Name, - MatcherType = typeof(MatchResult), + MatcherType = typeof(MatchResult).Name, Score = Score, Exception = Exception, MatchDetails = MatchResults?.Select(mr => mr.ToMatchDetail()).ToArray() diff --git a/src/dotnet-WireMock.Net/Json/SourceGenerationContext.cs b/src/dotnet-WireMock.Net/Json/SourceGenerationContext.cs index ba7312fff..919321871 100644 --- a/src/dotnet-WireMock.Net/Json/SourceGenerationContext.cs +++ b/src/dotnet-WireMock.Net/Json/SourceGenerationContext.cs @@ -1,6 +1,7 @@ // Copyright © WireMock.Net using System.Text.Json.Serialization; +using Newtonsoft.Json.Linq; using WireMock.Admin.Mappings; using WireMock.Admin.Requests; using WireMock.Types; @@ -9,10 +10,13 @@ namespace WireMock.Net.Json; [JsonSourceGenerationOptions(WriteIndented = true)] [JsonSerializable(typeof(EncodingModel))] +[JsonSerializable(typeof(JArray))] +[JsonSerializable(typeof(JObject))] [JsonSerializable(typeof(LogEntryModel))] [JsonSerializable(typeof(LogRequestModel))] [JsonSerializable(typeof(LogResponseModel))] [JsonSerializable(typeof(LogRequestMatchModel))] +[JsonSerializable(typeof(StatusModel))] [JsonSerializable(typeof(WireMockList))] internal partial class SourceGenerationContext : JsonSerializerContext { diff --git a/src/dotnet-WireMock.Net/WireMockLogger.cs b/src/dotnet-WireMock.Net/WireMockLogger.cs index 08398facd..61f69936f 100644 --- a/src/dotnet-WireMock.Net/WireMockLogger.cs +++ b/src/dotnet-WireMock.Net/WireMockLogger.cs @@ -1,6 +1,5 @@ // Copyright © WireMock.Net -using System; using System.Text.Json; using Microsoft.Extensions.Logging; using WireMock.Admin.Requests; @@ -11,11 +10,6 @@ namespace WireMock.Net; public class WireMockLogger : IWireMockLogger { - private readonly JsonSerializerOptions _options = new() - { - WriteIndented = true - }; - private readonly ILogger _logger; public WireMockLogger(ILogger logger)