From fef1fd4104b525b24bd3f8bfa1d4ed514d8fb093 Mon Sep 17 00:00:00 2001
From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com>
Date: Tue, 7 Apr 2026 04:59:22 +0000
Subject: [PATCH 1/4] Add JsonSerializerOptions property to support AOT
serialization
Agent-Logs-Url: https://github.com/XFEstudio/XFEExtension.NetCore.AutoConfig/sessions/8939dfa1-a714-424c-8b4a-898272447114
Co-authored-by: XFEstudio <132526994+XFEstudio@users.noreply.github.com>
---
XFEExtension.NetCore.AutoConfig/XFEProfile.cs | 20 +++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/XFEExtension.NetCore.AutoConfig/XFEProfile.cs b/XFEExtension.NetCore.AutoConfig/XFEProfile.cs
index 824499c..5da928a 100644
--- a/XFEExtension.NetCore.AutoConfig/XFEProfile.cs
+++ b/XFEExtension.NetCore.AutoConfig/XFEProfile.cs
@@ -13,6 +13,10 @@ public abstract class XFEProfile
{
private string id = Guid.NewGuid().ToString();
///
+ /// JSON序列化选项,用于配置序列化行为(支持AOT)
+ ///
+ public static JsonSerializerOptions JsonOptions { get; set; } = new JsonSerializerOptions();
+ ///
/// 配置文件所在的默认目录
///
public static string ProfilesDefaultPath { get; set; } = $@"{AppDomain.CurrentDomain.BaseDirectory}Profiles";
@@ -61,7 +65,7 @@ public abstract class XFEProfile
XFEDictionary propertyFileContent = profileString;
foreach (var property in propertyFileContent)
if (propertySetFuncDictionary.TryGetValue(property.Header, out var setValueDelegate) && propertyInfoDictionary.TryGetValue(property.Header, out var type))
- setValueDelegate(JsonSerializer.Deserialize(property.Content, type));
+ setValueDelegate(JsonSerializer.Deserialize(property.Content, type, JsonOptions));
return null;
}
///
@@ -77,7 +81,7 @@ public static string XFEDictionarySaveProfileOperation(XFEProfile profileInstanc
return string.Empty;
var saveProfileDictionary = new XFEDictionary();
foreach (var property in propertyGetFuncDictionary)
- saveProfileDictionary.Add(property.Key, JsonSerializer.Serialize(property.Value()));
+ saveProfileDictionary.Add(property.Key, JsonSerializer.Serialize(property.Value(), JsonOptions));
return saveProfileDictionary.ToString();
}
///
@@ -88,7 +92,7 @@ public static string XFEDictionarySaveProfileOperation(XFEProfile profileInstanc
/// 配置文件 “属性名称-属性类型” 字典
/// 配置文件 “属性名称-属性设置方法” 字典
/// 配置文件实例
- public static XFEProfile? JsonLoadProfileOperation(XFEProfile profileInstance, string profileString, Dictionary propertyInfoDictionary, Dictionary propertySetFuncDictionary) => JsonSerializer.Deserialize(profileString, profileInstance.GetType()) is XFEProfile xFEProfile ? xFEProfile : null;
+ public static XFEProfile? JsonLoadProfileOperation(XFEProfile profileInstance, string profileString, Dictionary propertyInfoDictionary, Dictionary propertySetFuncDictionary) => JsonSerializer.Deserialize(profileString, profileInstance.GetType(), JsonOptions) is XFEProfile xFEProfile ? xFEProfile : null;
///
/// 通过Json保存配置文件方法
@@ -97,7 +101,7 @@ public static string XFEDictionarySaveProfileOperation(XFEProfile profileInstanc
/// 配置文件 “属性名称-属性类型” 字典
/// 配置文件 “属性名称-属性值获取方法” 字典
/// 保存内容
- public static string JsonSaveProfileOperation(XFEProfile profileInstance, Dictionary propertyInfoDictionary, Dictionary propertyGetFuncDictionary) => profileInstance is null ? string.Empty : JsonSerializer.Serialize(profileInstance, profileInstance.GetType());
+ public static string JsonSaveProfileOperation(XFEProfile profileInstance, Dictionary propertyInfoDictionary, Dictionary propertyGetFuncDictionary) => profileInstance is null ? string.Empty : JsonSerializer.Serialize(profileInstance, profileInstance.GetType(), JsonOptions);
///
/// 通过XML加载配置文件方法
///
@@ -214,9 +218,9 @@ internal protected void SetProfileOperation()
private static Func