mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-19 01:58:14 +08:00
fix(openai): 修复无法 XML 序列化派生类的问题
This commit is contained in:
@@ -60,6 +60,11 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
return Serialize(typeof(T), obj);
|
||||
}
|
||||
|
||||
public static string Serialize(object obj)
|
||||
{
|
||||
return Serialize(obj.GetType(), obj);
|
||||
}
|
||||
|
||||
public static object Deserialize(Type type, string xml)
|
||||
{
|
||||
using var reader = new StringReader(xml);
|
||||
|
@@ -0,0 +1,17 @@
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||
{
|
||||
public class TestCase_XmlUtilityTests
|
||||
{
|
||||
[Fact(DisplayName = "测试用例:XML 序列化派生类")]
|
||||
public void TestXmlSerializeSubClass()
|
||||
{
|
||||
Assert.Null(Record.Exception(() =>
|
||||
{
|
||||
object obj = new Models.SignRequest() { UserId = "TEST" };
|
||||
Utilities.XmlUtility.Serialize(obj);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user