From 3bca6390ce1d0c652948783458ae9bff991a105a Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Fri, 3 Apr 2026 09:53:51 +0800
Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=B7=BB=E5=8A=A0JSON=20schema?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=94=9F=E6=88=90=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 实现了根据JSON schema自动生成配置类型和配置表包装的功能
- 支持嵌套对象、对象数组、标量数组的类型生成
- 提供可映射的default/enum/ref-table元数据支持
- 生成强类型的配置表包装器和运行时绑定辅助类
- 实现了完整的schema解析和C#代码生成功能
- 添加了详细的XML文档注释和错误诊断功能
---
.../SchemaConfigGenerator/MonsterConfigBindings.g.txt | 6 +++---
.../Config/SchemaConfigGenerator.cs | 10 +++-------
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfigBindings.g.txt b/GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfigBindings.g.txt
index 9893f455..a2954ce7 100644
--- a/GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfigBindings.g.txt
+++ b/GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfigBindings.g.txt
@@ -5,7 +5,7 @@ namespace GFramework.Game.Config.Generated;
///
/// Auto-generated registration and lookup helpers for schema file 'monster.schema.json'.
-/// The helper centralizes table naming, config directory, schema path, and strong-typed registry access so consumer projects do not need to duplicate the same conventions.
+/// The helper centralizes table naming, config directory, schema path, and strongly-typed registry access so consumer projects do not need to duplicate the same conventions.
///
public static class MonsterConfigBindings
{
@@ -51,7 +51,7 @@ public static class MonsterConfigBindings
/// Gets the generated config table wrapper from the registry.
///
/// The source config registry.
- /// The generated strong-typed table wrapper.
+ /// The generated strongly-typed table wrapper.
/// When is null.
public static MonsterTable GetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry)
{
@@ -67,7 +67,7 @@ public static class MonsterConfigBindings
/// Tries to get the generated config table wrapper from the registry.
///
/// The source config registry.
- /// The generated strong-typed table wrapper when lookup succeeds; otherwise null.
+ /// The generated strongly-typed table wrapper when lookup succeeds; otherwise null.
/// True when the generated table is registered and type-compatible; otherwise false.
/// When is null.
public static bool TryGetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry, out MonsterTable? table)
diff --git a/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs b/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
index 6428f624..29d52fdb 100644
--- a/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
+++ b/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
@@ -1,7 +1,3 @@
-using System.Globalization;
-using System.IO;
-using System.Text;
-using System.Text.Json;
using GFramework.SourceGenerators.Diagnostics;
namespace GFramework.SourceGenerators.Config;
@@ -640,7 +636,7 @@ public sealed class SchemaConfigGenerator : IIncrementalGenerator
builder.AppendLine(
$"/// Auto-generated registration and lookup helpers for schema file '{schema.FileName}'.");
builder.AppendLine(
- "/// The helper centralizes table naming, config directory, schema path, and strong-typed registry access so consumer projects do not need to duplicate the same conventions.");
+ "/// The helper centralizes table naming, config directory, schema path, and strongly-typed registry access so consumer projects do not need to duplicate the same conventions.");
builder.AppendLine("/// ");
builder.AppendLine($"public static class {bindingsClassName}");
builder.AppendLine("{");
@@ -694,7 +690,7 @@ public sealed class SchemaConfigGenerator : IIncrementalGenerator
builder.AppendLine(" /// Gets the generated config table wrapper from the registry.");
builder.AppendLine(" /// ");
builder.AppendLine(" /// The source config registry.");
- builder.AppendLine(" /// The generated strong-typed table wrapper.");
+ builder.AppendLine(" /// The generated strongly-typed table wrapper.");
builder.AppendLine(
" /// When is null.");
builder.AppendLine(
@@ -714,7 +710,7 @@ public sealed class SchemaConfigGenerator : IIncrementalGenerator
builder.AppendLine(" /// ");
builder.AppendLine(" /// The source config registry.");
builder.AppendLine(
- " /// The generated strong-typed table wrapper when lookup succeeds; otherwise null.");
+ " /// The generated strongly-typed table wrapper when lookup succeeds; otherwise null.");
builder.AppendLine(
" /// True when the generated table is registered and type-compatible; otherwise false.");
builder.AppendLine(