From c6ec9400a9a5c3513805a8b62fd8b32527ef24d4 Mon Sep 17 00:00:00 2001 From: fangyangci Date: Sun, 31 Dec 2023 23:12:06 +0800 Subject: [PATCH] fix setting --- .../Session/StreamingSession.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/Microsoft.Bot.Connector.Streaming/Session/StreamingSession.cs b/libraries/Microsoft.Bot.Connector.Streaming/Session/StreamingSession.cs index e83e3fedd1..d05289171d 100644 --- a/libraries/Microsoft.Bot.Connector.Streaming/Session/StreamingSession.cs +++ b/libraries/Microsoft.Bot.Connector.Streaming/Session/StreamingSession.cs @@ -19,6 +19,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Net.Http.Headers; using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; namespace Microsoft.Bot.Connector.Streaming.Session { @@ -42,6 +43,13 @@ internal class StreamingSession private readonly object _receiveSync = new object(); + static StreamingSession() + { + var tmpSetting = SerializationSettings.DefaultSerializationSettings; + tmpSetting.NullValueHandling = NullValueHandling.Ignore; + Serializer = JsonSerializer.Create(tmpSetting); + } + public StreamingSession(RequestHandler receiver, TransportHandler sender, ILogger logger, CancellationToken connectionCancellationToken = default) { _receiver = receiver ?? throw new ArgumentNullException(nameof(receiver)); @@ -52,7 +60,7 @@ public StreamingSession(RequestHandler receiver, TransportHandler sender, ILogge _connectionCancellationToken = connectionCancellationToken; } - private static JsonSerializer Serializer { get; set; } = JsonSerializer.Create(SerializationSettings.DefaultSerializationSettings); + private static JsonSerializer Serializer { get; } public async Task SendRequestAsync(StreamingRequest request, CancellationToken cancellationToken) {