From bdf74be049c32c5d3715a50040ca48af23038f5c Mon Sep 17 00:00:00 2001 From: ilyfairy Date: Wed, 21 Aug 2024 00:01:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?v1.3.0=20=20=E4=BD=BF=E7=94=A8Json=E6=BA=90?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8,=20=E6=94=AF=E6=8C=81AOT&=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...> CqGetForwardMessageActionParamsModel.cs} | 0 ...CqGetLoginInformationActionParamsModel.cs} | 0 ...etStrangerInformationActionParamsModel.cs} | 0 ...=> CqSendGroupMessageActionParamsModel.cs} | 0 src/EleCho.GoCqHttpSdk/CqWsSession.cs | 8 +- .../EleCho.GoCqHttpSdk.csproj | 2 +- src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs | 211 +++++++++++++++++- 7 files changed, 213 insertions(+), 8 deletions(-) rename src/EleCho.GoCqHttpSdk/Action/Model/Params/{CqGetForwardMsgActionParamsModel.cs => CqGetForwardMessageActionParamsModel.cs} (100%) rename src/EleCho.GoCqHttpSdk/Action/Model/Params/{CqGetLoginInfomationActionParamsModel.cs => CqGetLoginInformationActionParamsModel.cs} (100%) rename src/EleCho.GoCqHttpSdk/Action/Model/Params/{CqGetStrangerInfoActionParamsModel.cs => CqGetStrangerInformationActionParamsModel.cs} (100%) rename src/EleCho.GoCqHttpSdk/Action/Model/Params/{CqSendGroupMsgActionParamsModel.cs => CqSendGroupMessageActionParamsModel.cs} (100%) diff --git a/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetForwardMsgActionParamsModel.cs b/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetForwardMessageActionParamsModel.cs similarity index 100% rename from src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetForwardMsgActionParamsModel.cs rename to src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetForwardMessageActionParamsModel.cs diff --git a/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetLoginInfomationActionParamsModel.cs b/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetLoginInformationActionParamsModel.cs similarity index 100% rename from src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetLoginInfomationActionParamsModel.cs rename to src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetLoginInformationActionParamsModel.cs diff --git a/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetStrangerInfoActionParamsModel.cs b/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetStrangerInformationActionParamsModel.cs similarity index 100% rename from src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetStrangerInfoActionParamsModel.cs rename to src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetStrangerInformationActionParamsModel.cs diff --git a/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqSendGroupMsgActionParamsModel.cs b/src/EleCho.GoCqHttpSdk/Action/Model/Params/CqSendGroupMessageActionParamsModel.cs similarity index 100% rename from src/EleCho.GoCqHttpSdk/Action/Model/Params/CqSendGroupMsgActionParamsModel.cs rename to src/EleCho.GoCqHttpSdk/Action/Model/Params/CqSendGroupMessageActionParamsModel.cs diff --git a/src/EleCho.GoCqHttpSdk/CqWsSession.cs b/src/EleCho.GoCqHttpSdk/CqWsSession.cs index 0f5ccda..01532ba 100644 --- a/src/EleCho.GoCqHttpSdk/CqWsSession.cs +++ b/src/EleCho.GoCqHttpSdk/CqWsSession.cs @@ -247,10 +247,10 @@ private async Task WebSocketLoop(WebSocket webSocket) #endif ms.Seek(0, SeekOrigin.Begin); - CqWsDataModel? wsDataModel = JsonSerializer.Deserialize(ms, JsonHelper.Options); - - // 处理 WebSocket 数据 - ProcWsDataAsync(wsDataModel); + CqWsDataModel? wsDataModel = JsonSerializer.Deserialize(ms, JsonHelper.Options); + + // 处理 WebSocket 数据 + ProcWsDataAsync(wsDataModel); #if DEBUG if (wsDataModel is not CqPostModel) diff --git a/src/EleCho.GoCqHttpSdk/EleCho.GoCqHttpSdk.csproj b/src/EleCho.GoCqHttpSdk/EleCho.GoCqHttpSdk.csproj index 3a7c973..4cea8be 100644 --- a/src/EleCho.GoCqHttpSdk/EleCho.GoCqHttpSdk.csproj +++ b/src/EleCho.GoCqHttpSdk/EleCho.GoCqHttpSdk.csproj @@ -8,7 +8,7 @@ SlimeNull Go-CqHttp 的 .NET SDK https://github.com/OrgEleCho/EleCho.GoCqHttpSdk - 1.2.6 + 1.3.0 README.md Copyright (c) EleCho 2023 https://github.com/OrgEleCho/EleCho.GoCqHttpSdk diff --git a/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs b/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs index 68bb6b8..5db20e3 100644 --- a/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs +++ b/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs @@ -1,10 +1,17 @@ -using EleCho.GoCqHttpSdk.JsonConverter; +using EleCho.GoCqHttpSdk.Action.Model; +using EleCho.GoCqHttpSdk.Action.Model.Params; +using EleCho.GoCqHttpSdk.Action.Model.ResultData; +using EleCho.GoCqHttpSdk.JsonConverter; +using EleCho.GoCqHttpSdk.Message.DataModel; using EleCho.GoCqHttpSdk.Message.JsonConverter; +using EleCho.GoCqHttpSdk.Model; using EleCho.GoCqHttpSdk.Post.JsonConverter; +using EleCho.GoCqHttpSdk.Post.Model; using System; using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using System.Text.Unicode; namespace EleCho.GoCqHttpSdk.Utils @@ -76,10 +83,208 @@ private static JsonSerializerOptions NewDebugOptions() new CqMsgModelArrayConverter(), new CpMsgModelConverter(), - } + }, +#if NET7_0_OR_GREATER + TypeInfoResolver = JsonGeneratorSourceContext.Default; +#endif }; } #endif } -} \ No newline at end of file +} + +#if NET7_0_OR_GREATER +[JsonSourceGenerationOptions] +[JsonSerializable(typeof(CqWsDataModel))] +[JsonSerializable(typeof(CqPostModel))] +[JsonSerializable(typeof(CqActionModel))] +[JsonSerializable(typeof(CqActionResultRaw))] + +[JsonSerializable(typeof(CqMessagePostModel))] +[JsonSerializable(typeof(CqSelfMessagePostModel))] +[JsonSerializable(typeof(CqNoticePostModel))] +[JsonSerializable(typeof(CqRequestPostModel))] +[JsonSerializable(typeof(CqMetaPostModel))] + +[JsonSerializable(typeof(CqPrivateMessagePostModel))] +[JsonSerializable(typeof(CqGroupMessagePostModel))] + +[JsonSerializable(typeof(CqPrivateSelfMessagePostModel))] +[JsonSerializable(typeof(CqGroupSelfMessagePostModel))] + +[JsonSerializable(typeof(CqNoticeGroupUploadPostModel))] +[JsonSerializable(typeof(CqNoticeGroupAdminPostModel))] +[JsonSerializable(typeof(CqNoticeGroupIncreasePostModel))] +[JsonSerializable(typeof(CqNoticeGroupDecreasePostModel))] +[JsonSerializable(typeof(CqNoticeGroupBanPostModel))] +[JsonSerializable(typeof(CqNoticeFriendAddPostModel))] +[JsonSerializable(typeof(CqNoticeGroupRecallPostModel))] +[JsonSerializable(typeof(CqNoticeFriendRecallPostModel))] +[JsonSerializable(typeof(CqNoticeGroupCardPostModel))] +[JsonSerializable(typeof(CqNoticeOfflineFilePostModel))] +[JsonSerializable(typeof(CqNoticeNotifyPostModel))] + +[JsonSerializable(typeof(CqNoticePokePostModel))] +[JsonSerializable(typeof(CqNoticeLuckyKingPostModel))] +[JsonSerializable(typeof(CqNoticeHonorPostModel))] +[JsonSerializable(typeof(CqNoticeTitlePostModel))] + +[JsonSerializable(typeof(CqMetaLifecyclePostModel))] +[JsonSerializable(typeof(CqMetaHeartbeatPostModel))] + +[JsonSerializable(typeof(CqRequestFriendPostModel))] +[JsonSerializable(typeof(CqRequestGroupPostModel))] + +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] +[JsonSerializable(typeof(CqMsgModel))] + +[JsonSerializable(typeof(CqActionParamsModel))] +[JsonSerializable(typeof(CqBanGroupAllMembersActionParamsModel))] +[JsonSerializable(typeof(CqBanGroupAnonymousMemberActionParamsModel))] +[JsonSerializable(typeof(CqBanGroupMemberActionParamsModel))] +[JsonSerializable(typeof(CqCanSendImageActionParamsModel))] +[JsonSerializable(typeof(CqCanSendRecordActionParamsModel))] +[JsonSerializable(typeof(CqCheckUrlSafetyActionParamsModel))] +[JsonSerializable(typeof(CqCreateGroupFolderActionParamsModel))] +[JsonSerializable(typeof(CqDeleteEssenceMessageActionParamsModel))] +[JsonSerializable(typeof(CqDeleteFriendActionParamsModel))] +[JsonSerializable(typeof(CqDeleteGroupFileActionParamsModel))] +[JsonSerializable(typeof(CqDeleteGroupFolderActionParamsModel))] +[JsonSerializable(typeof(CqDeleteUnidirectionalFriendActionParamsModel))] +[JsonSerializable(typeof(CqDownloadFileActionParamsModel))] +[JsonSerializable(typeof(CqGetCookiesActionParamsModel))] +[JsonSerializable(typeof(CqGetCsrfTokenActionParamsModel))] +[JsonSerializable(typeof(CqGetEssenceMessageListActionParamsModel))] +[JsonSerializable(typeof(CqGetForwardMessageActionParamsModel))] +[JsonSerializable(typeof(CqGetFriendListActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupFilesByFolderActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupFileSystemInformationActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupFileUrlActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupInformationActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupListActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupMemberInformationActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupMemberListActionParamsModel))] +[JsonSerializable(typeof(CqGetGroupRootFilesActionParamsModel))] +[JsonSerializable(typeof(CqGetImageActionParamsModel))] +[JsonSerializable(typeof(CqGetLoginInformationActionParamsModel))] +[JsonSerializable(typeof(CqGetMessageActionParamsModel))] +[JsonSerializable(typeof(CqGetModelShowActionParamsModel))] +[JsonSerializable(typeof(CqGetOnlineClientsActionParamsModel))] +[JsonSerializable(typeof(CqGetStrangerInformationActionParamsModel))] +[JsonSerializable(typeof(CqGetUnidirectionalFriendListActionParamsModel))] +[JsonSerializable(typeof(CqGetVersionInformationActionParamsModel))] +[JsonSerializable(typeof(CqGetWordSlicesActionParamsModel))] +[JsonSerializable(typeof(CqGroupSignInActionParamsModel))] +[JsonSerializable(typeof(CqHandleFriendRequestActionParamsModel))] +[JsonSerializable(typeof(CqHandleGroupRequestActionParamsModel))] +[JsonSerializable(typeof(CqKickGroupMemberActionParamsModel))] +[JsonSerializable(typeof(CqLeaveGroupActionParamsModel))] +[JsonSerializable(typeof(CqMarkMessageAsReadActionParamsModel))] +[JsonSerializable(typeof(CqOcrImageActionParamsModel))] +[JsonSerializable(typeof(CqRecallMessageActionParamsModel))] +[JsonSerializable(typeof(CqReloadEventFilterActionParamsModel))] +[JsonSerializable(typeof(CqSendGroupForwardMessageActionParamsModel))] +[JsonSerializable(typeof(CqSendGroupMessageActionParamsModel))] +[JsonSerializable(typeof(CqSendMessageActionParamsModel))] +[JsonSerializable(typeof(CqSendPrivateForwardMsgActionParamsModel))] +[JsonSerializable(typeof(CqSendPrivateMessageActionParamsModel))] +[JsonSerializable(typeof(CqSetAccountProfileActionParamsModel))] +[JsonSerializable(typeof(CqSetEssenceMessageActionParamsModel))] +[JsonSerializable(typeof(CqSetGroupAdministratorActionParamsModel))] +[JsonSerializable(typeof(CqSetGroupAnonymousActionParamsModel))] +[JsonSerializable(typeof(CqSetGroupAvatarActionParamsModel))] +[JsonSerializable(typeof(CqSetGroupNameActionParamsModel))] +[JsonSerializable(typeof(CqSetGroupNicknameActionParamsModel))] +[JsonSerializable(typeof(CqSetGroupSpecialTitleActionParamsModel))] +[JsonSerializable(typeof(CqSetModelShowActionParamsModel))] +[JsonSerializable(typeof(CqUploadGroupFileActionParamsModel))] +[JsonSerializable(typeof(CqUploadPrivateFileActionParamsModel))] + +[JsonSerializable(typeof(CqActionResultDataModel))] +[JsonSerializable(typeof(CqBanGroupAllMembersActionResultDataModel))] +[JsonSerializable(typeof(CqBanGroupAnonymousMemberActionResultDataModel))] +[JsonSerializable(typeof(CqBanGroupMemberActionResultDataModel))] +[JsonSerializable(typeof(CqCanSendImageActionResultDataModel))] +[JsonSerializable(typeof(CqCanSendRecordActionResultDataModel))] +[JsonSerializable(typeof(CqCheckUrlSafetyActionResultDataModel))] +[JsonSerializable(typeof(CqCreateGroupFolderActionResultDataModel))] +[JsonSerializable(typeof(CqDeleteEssenceMessageActionResultDataModel))] +[JsonSerializable(typeof(CqDeleteFriendActionResultDataModel))] +[JsonSerializable(typeof(CqDeleteGroupFileActionResultDataModel))] +[JsonSerializable(typeof(CqDeleteGroupFolderActionResultDataModel))] +[JsonSerializable(typeof(CqDeleteUnidirectionalFriendActionResultDataModel))] +[JsonSerializable(typeof(CqDownloadFileActionResultDataModel))] +[JsonSerializable(typeof(CqGetCookiesActionResultDataModel))] +[JsonSerializable(typeof(CqGetCsrfTokenActionResultDataModel))] +[JsonSerializable(typeof(CqGetEssenceMessageListActionResultDataModel))] +[JsonSerializable(typeof(CqGetForwardMessageActionResultDataModel))] +[JsonSerializable(typeof(CqGetFriendListActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupFilesByFolderActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupFileSystemInformationActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupFileUrlActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupInformationActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupListActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupMemberInformationActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupMemberListActionResultDataModel))] +[JsonSerializable(typeof(CqGetGroupRootFilesActionResultDataModel))] +[JsonSerializable(typeof(CqGetImageActionResultDataModel))] +[JsonSerializable(typeof(CqGetLoginInformationActionResultDataModel))] +[JsonSerializable(typeof(CqGetMessageActionResultDataModel))] +[JsonSerializable(typeof(CqGetModelShowActionResultDataModel))] +[JsonSerializable(typeof(CqGetOnlineClientsActionResultDataModel))] +[JsonSerializable(typeof(CqGetStrangerInformationActionResultDataModel))] +[JsonSerializable(typeof(CqGetUnidirectionalFriendListActionResultDataModel))] +[JsonSerializable(typeof(CqGetVersionInformationActionResultDataModel))] +[JsonSerializable(typeof(CqGetWordSlicesActionResultDataModel))] +[JsonSerializable(typeof(CqGroupSignInActionResultDataModel))] +[JsonSerializable(typeof(CqHandleFriendRequestActionResultDataModel))] +[JsonSerializable(typeof(CqHandleGroupRequestActionResultDataModel))] +[JsonSerializable(typeof(CqKickGroupMemberActionResultDataModel))] +[JsonSerializable(typeof(CqLeaveGroupActionResultDataModel))] +[JsonSerializable(typeof(CqMarkMessageAsReadActionResultDataModel))] +[JsonSerializable(typeof(CqOcrImageActionResultDataModel))] +[JsonSerializable(typeof(CqRecallMessageActionResultDataModel))] +[JsonSerializable(typeof(CqReloadEventFilterActionResultDataModel))] +[JsonSerializable(typeof(CqSendGroupForwardMessageActionResultDataModel))] +[JsonSerializable(typeof(CqSendGroupMessageActionResultDataModel))] +[JsonSerializable(typeof(CqSendMessageActionResultDataModel))] +[JsonSerializable(typeof(CqSendPrivateForwardMessageActionResultDataModel))] +[JsonSerializable(typeof(CqSendPrivateMessageActionResultDataModel))] +[JsonSerializable(typeof(CqSetAccountProfileActionResultDataModel))] +[JsonSerializable(typeof(CqSetEssenceMessageActionResultDataModel))] +[JsonSerializable(typeof(CqSetGroupAdministratorActionResultDataModel))] +[JsonSerializable(typeof(CqSetGroupAnonymousActionResultDataModel))] +[JsonSerializable(typeof(CqSetGroupAvatarActionResultDataModel))] +[JsonSerializable(typeof(CqSetGroupNameActionResultDataModel))] +[JsonSerializable(typeof(CqSetGroupNicknameActionResultDataModel))] +[JsonSerializable(typeof(CqSetGroupSpecialTitleActionResultDataModel))] +[JsonSerializable(typeof(CqSetModelShowActionResultDataModel))] +[JsonSerializable(typeof(CqUploadGroupFileActionResultDataModel))] +[JsonSerializable(typeof(CqUploadPrivateFileActionResultDataModel))] +internal partial class JsonGeneratorSourceContext : JsonSerializerContext; +#endif \ No newline at end of file From 1eeaf4ce0d54c01c53eea44eba0420bbfe2f6cb7 Mon Sep 17 00:00:00 2001 From: ilyfairy Date: Wed, 21 Aug 2024 00:58:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BF=98=E8=AE=B0=E5=9C=A8Release=E4=B8=AD?= =?UTF-8?q?=E5=8A=A0TypeInfoResolver=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs | 106 +++++++++++---------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs b/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs index 5db20e3..6121755 100644 --- a/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs +++ b/src/EleCho.GoCqHttpSdk/Utils/JsonHelper.cs @@ -14,84 +14,86 @@ using System.Text.Json.Serialization.Metadata; using System.Text.Unicode; -namespace EleCho.GoCqHttpSdk.Utils +namespace EleCho.GoCqHttpSdk.Utils; + +internal static class JsonHelper { - internal static class JsonHelper - { - private static Lazy options = new Lazy(NewOptions); + private static Lazy options = new Lazy(NewOptions); - private static JsonSerializerOptions NewOptions() + private static JsonSerializerOptions NewOptions() + { + return new JsonSerializerOptions() { - return new JsonSerializerOptions() + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals, + Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), + Converters = { - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals, - Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), - Converters = - { - new CqWsDataModelConverter(), + new CqWsDataModelConverter(), - new CqPostModelConverter(), - new CqMessageEventModelConverter(), - new CqSelfMessageEventModelConverter(), + new CqPostModelConverter(), + new CqMessageEventModelConverter(), + new CqSelfMessageEventModelConverter(), - new CqNoticeEventModelConverter(), - new CqNoticeNotifyEventModelConverter(), + new CqNoticeEventModelConverter(), + new CqNoticeNotifyEventModelConverter(), - new CqMetaEventModelConverter(), + new CqMetaEventModelConverter(), - new CqRequestEventModelConverter(), + new CqRequestEventModelConverter(), - new CqMsgModelArrayConverter(), - new CpMsgModelConverter(), - } - }; - } + new CqMsgModelArrayConverter(), + new CpMsgModelConverter(), + }, +#if NET7_0_OR_GREATER + TypeInfoResolver = JsonGeneratorSourceContext.Default, +#endif + }; + } - public static JsonSerializerOptions Options => + public static JsonSerializerOptions Options => #if DEBUG - debugOptions.Value; + debugOptions.Value; #else - options.Value; + options.Value; #endif #if DEBUG - private static Lazy debugOptions = new(NewDebugOptions); + private static Lazy debugOptions = new(NewDebugOptions); - private static JsonSerializerOptions NewDebugOptions() + private static JsonSerializerOptions NewDebugOptions() + { + return new JsonSerializerOptions() { - return new JsonSerializerOptions() + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals, + Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), + Converters = { - WriteIndented = true, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals, - Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), - Converters = - { - new CqWsDataModelConverter(), + new CqWsDataModelConverter(), - new CqPostModelConverter(), - new CqMessageEventModelConverter(), - new CqSelfMessageEventModelConverter(), + new CqPostModelConverter(), + new CqMessageEventModelConverter(), + new CqSelfMessageEventModelConverter(), - new CqNoticeEventModelConverter(), - new CqNoticeNotifyEventModelConverter(), + new CqNoticeEventModelConverter(), + new CqNoticeNotifyEventModelConverter(), - new CqMetaEventModelConverter(), + new CqMetaEventModelConverter(), - new CqRequestEventModelConverter(), + new CqRequestEventModelConverter(), - new CqMsgModelArrayConverter(), - new CpMsgModelConverter(), - }, + new CqMsgModelArrayConverter(), + new CpMsgModelConverter(), + }, #if NET7_0_OR_GREATER - TypeInfoResolver = JsonGeneratorSourceContext.Default; + TypeInfoResolver = JsonGeneratorSourceContext.Default, #endif - }; - } + }; + } #endif - } } #if NET7_0_OR_GREATER @@ -287,4 +289,4 @@ private static JsonSerializerOptions NewDebugOptions() [JsonSerializable(typeof(CqUploadGroupFileActionResultDataModel))] [JsonSerializable(typeof(CqUploadPrivateFileActionResultDataModel))] internal partial class JsonGeneratorSourceContext : JsonSerializerContext; -#endif \ No newline at end of file +#endif