diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs index 57a6bd4f..8cd97d73 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs @@ -17,8 +17,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Utilities { if (type == null) throw new ArgumentNullException(nameof(type)); - string skey = type.AssemblyQualifiedName; - XmlSerializer? xmlSerializer = (XmlSerializer)_serializers[skey]; + string skey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString(); + XmlSerializer? xmlSerializer = (XmlSerializer?)_serializers[skey]; if (xmlSerializer == null) { xmlSerializer = new XmlSerializer(type, new XmlRootAttribute("xml")); @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Utilities { using var reader = new StringReader(xml); XmlSerializer serializer = GetTypedSerializer(type); - return serializer.Deserialize(reader); + return serializer.Deserialize(reader)!; } public static T Deserialize(string xml) diff --git a/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs b/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs index 38d62f3c..4d305cc9 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs @@ -17,8 +17,8 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities { if (type == null) throw new ArgumentNullException(nameof(type)); - string skey = type.AssemblyQualifiedName; - XmlSerializer? xmlSerializer = (XmlSerializer)_serializers[skey]; + string skey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString(); + XmlSerializer? xmlSerializer = (XmlSerializer?)_serializers[skey]; if (xmlSerializer == null) { xmlSerializer = new XmlSerializer(type, new XmlRootAttribute("xml")); @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities { using var reader = new StringReader(xml); XmlSerializer serializer = GetTypedSerializer(type); - return serializer.Deserialize(reader); + return serializer.Deserialize(reader)!; } public static T Deserialize(string xml) diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs index 1260d779..0b331691 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs @@ -17,8 +17,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Utilities { if (type == null) throw new ArgumentNullException(nameof(type)); - string skey = type.AssemblyQualifiedName; - XmlSerializer? xmlSerializer = (XmlSerializer)_serializers[skey]; + string skey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString(); + XmlSerializer? xmlSerializer = (XmlSerializer?)_serializers[skey]; if (xmlSerializer == null) { xmlSerializer = new XmlSerializer(type, new XmlRootAttribute("xml")); @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Utilities { using var reader = new StringReader(xml); XmlSerializer serializer = GetTypedSerializer(type); - return serializer.Deserialize(reader); + return serializer.Deserialize(reader)!; } public static T Deserialize(string xml)