Fix WireMockLogger implementation in dotnet-WireMock (#1431)

This commit is contained in:
Stef Heyenrath
2026-03-13 18:34:47 +01:00
committed by GitHub
parent 0a9f37e857
commit d08ce944b6
5 changed files with 7 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ public class MatchDetail
/// <summary> /// <summary>
/// Gets or sets the type of the matcher. /// Gets or sets the type of the matcher.
/// </summary> /// </summary>
public required Type MatcherType { get; set; } public required string MatcherType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of the matcher. /// Gets or sets the type of the matcher.

View File

@@ -1,7 +1,5 @@
// Copyright © WireMock.Net // Copyright © WireMock.Net
using System.Linq;
namespace WireMock.Matchers.Request; namespace WireMock.Matchers.Request;
/// <summary> /// <summary>
@@ -30,7 +28,7 @@ public class RequestMatchResult : IRequestMatchResult
return AddMatchDetail(new MatchDetail return AddMatchDetail(new MatchDetail
{ {
Name = matcherType.Name.Replace("RequestMessage", string.Empty), Name = matcherType.Name.Replace("RequestMessage", string.Empty),
MatcherType = matcherType, MatcherType = matcherType.Name,
Score = score, Score = score,
Exception = exception Exception = exception
}); });

View File

@@ -1,6 +1,5 @@
// Copyright © WireMock.Net // Copyright © WireMock.Net
using System.Linq;
using Stef.Validation; using Stef.Validation;
using WireMock.Extensions; using WireMock.Extensions;
using WireMock.Matchers.Request; using WireMock.Matchers.Request;
@@ -119,7 +118,7 @@ public class MatchResult
return new MatchDetail return new MatchDetail
{ {
Name = Name, Name = Name,
MatcherType = typeof(MatchResult), MatcherType = typeof(MatchResult).Name,
Score = Score, Score = Score,
Exception = Exception, Exception = Exception,
MatchDetails = MatchResults?.Select(mr => mr.ToMatchDetail()).ToArray() MatchDetails = MatchResults?.Select(mr => mr.ToMatchDetail()).ToArray()

View File

@@ -1,6 +1,7 @@
// Copyright © WireMock.Net // Copyright © WireMock.Net
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Newtonsoft.Json.Linq;
using WireMock.Admin.Mappings; using WireMock.Admin.Mappings;
using WireMock.Admin.Requests; using WireMock.Admin.Requests;
using WireMock.Types; using WireMock.Types;
@@ -9,10 +10,13 @@ namespace WireMock.Net.Json;
[JsonSourceGenerationOptions(WriteIndented = true)] [JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(EncodingModel))] [JsonSerializable(typeof(EncodingModel))]
[JsonSerializable(typeof(JArray))]
[JsonSerializable(typeof(JObject))]
[JsonSerializable(typeof(LogEntryModel))] [JsonSerializable(typeof(LogEntryModel))]
[JsonSerializable(typeof(LogRequestModel))] [JsonSerializable(typeof(LogRequestModel))]
[JsonSerializable(typeof(LogResponseModel))] [JsonSerializable(typeof(LogResponseModel))]
[JsonSerializable(typeof(LogRequestMatchModel))] [JsonSerializable(typeof(LogRequestMatchModel))]
[JsonSerializable(typeof(StatusModel))]
[JsonSerializable(typeof(WireMockList<string>))] [JsonSerializable(typeof(WireMockList<string>))]
internal partial class SourceGenerationContext : JsonSerializerContext internal partial class SourceGenerationContext : JsonSerializerContext
{ {

View File

@@ -1,6 +1,5 @@
// Copyright © WireMock.Net // Copyright © WireMock.Net
using System;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using WireMock.Admin.Requests; using WireMock.Admin.Requests;
@@ -11,11 +10,6 @@ namespace WireMock.Net;
public class WireMockLogger : IWireMockLogger public class WireMockLogger : IWireMockLogger
{ {
private readonly JsonSerializerOptions _options = new()
{
WriteIndented = true
};
private readonly ILogger _logger; private readonly ILogger _logger;
public WireMockLogger(ILogger logger) public WireMockLogger(ILogger logger)