From 7473adb78907e314d022812c5824a3da6c4a13bb Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Sun, 12 Apr 2026 14:51:36 +0800
Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=B7=BB=E5=8A=A0YAML=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E5=BA=8F=E5=88=97=E5=8C=96=E5=99=A8=E5=B9=B6=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E9=9B=86=E6=88=90=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增YamlConfigTextSerializer类提供统一的YAML序列化功能
- 集成测试中添加配置抽象接口引用
- 序列化器使用驼峰命名约定和默认值保留策略
- 自动确保YAML输出以换行符结尾
- 配置对象序列化时验证空值并抛出异常
---
.../Config/GeneratedConfigConsumerIntegrationTests.cs | 5 +++--
GFramework.Game/Config/YamlConfigTextSerializer.cs | 3 +++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs b/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs
index dc7f6dc2..248f7f9f 100644
--- a/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs
+++ b/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs
@@ -1,4 +1,5 @@
using System.IO;
+using GFramework.Game.Abstractions.Config;
using GFramework.Game.Config;
using GFramework.Game.Config.Generated;
@@ -11,8 +12,6 @@ namespace GFramework.Game.Tests.Config;
[TestFixture]
public class GeneratedConfigConsumerIntegrationTests
{
- private string _rootPath = null!;
-
///
/// 为每个端到端测试准备独立的配置根目录,避免编译期 schema 资产与运行时写入互相污染。
///
@@ -35,6 +34,8 @@ public class GeneratedConfigConsumerIntegrationTests
}
}
+ private string _rootPath = null!;
+
///
/// 验证生成器自动拾取消费者项目的 schema 后,
/// 可以用生成的聚合注册辅助完成加载,并通过强类型表包装访问运行时数据与查询辅助。
diff --git a/GFramework.Game/Config/YamlConfigTextSerializer.cs b/GFramework.Game/Config/YamlConfigTextSerializer.cs
index 726a2e39..b270dd7b 100644
--- a/GFramework.Game/Config/YamlConfigTextSerializer.cs
+++ b/GFramework.Game/Config/YamlConfigTextSerializer.cs
@@ -1,3 +1,6 @@
+using YamlDotNet.Serialization;
+using YamlDotNet.Serialization.NamingConventions;
+
namespace GFramework.Game.Config;
///