mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-11 20:38:58 +08:00
feat(config): 添加JSON schema配置生成器
- 实现了根据JSON schema自动生成配置类型和配置表包装的功能 - 支持嵌套对象、对象数组、标量数组的类型生成 - 提供可映射的default/enum/ref-table元数据支持 - 生成强类型的配置表包装器和运行时绑定辅助类 - 实现了完整的schema解析和C#代码生成功能 - 添加了详细的XML文档注释和错误诊断功能
This commit is contained in:
parent
48fd8a22bb
commit
3bca6390ce
@ -5,7 +5,7 @@ namespace GFramework.Game.Config.Generated;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public static class MonsterConfigBindings
|
||||
{
|
||||
@ -51,7 +51,7 @@ public static class MonsterConfigBindings
|
||||
/// Gets the generated config table wrapper from the registry.
|
||||
/// </summary>
|
||||
/// <param name="registry">The source config registry.</param>
|
||||
/// <returns>The generated strong-typed table wrapper.</returns>
|
||||
/// <returns>The generated strongly-typed table wrapper.</returns>
|
||||
/// <exception cref="global::System.ArgumentNullException">When <paramref name="registry"/> is null.</exception>
|
||||
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.
|
||||
/// </summary>
|
||||
/// <param name="registry">The source config registry.</param>
|
||||
/// <param name="table">The generated strong-typed table wrapper when lookup succeeds; otherwise null.</param>
|
||||
/// <param name="table">The generated strongly-typed table wrapper when lookup succeeds; otherwise null.</param>
|
||||
/// <returns>True when the generated table is registered and type-compatible; otherwise false.</returns>
|
||||
/// <exception cref="global::System.ArgumentNullException">When <paramref name="registry"/> is null.</exception>
|
||||
public static bool TryGetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry, out MonsterTable? table)
|
||||
|
||||
@ -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("/// </summary>");
|
||||
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(" /// </summary>");
|
||||
builder.AppendLine(" /// <param name=\"registry\">The source config registry.</param>");
|
||||
builder.AppendLine(" /// <returns>The generated strong-typed table wrapper.</returns>");
|
||||
builder.AppendLine(" /// <returns>The generated strongly-typed table wrapper.</returns>");
|
||||
builder.AppendLine(
|
||||
" /// <exception cref=\"global::System.ArgumentNullException\">When <paramref name=\"registry\"/> is null.</exception>");
|
||||
builder.AppendLine(
|
||||
@ -714,7 +710,7 @@ public sealed class SchemaConfigGenerator : IIncrementalGenerator
|
||||
builder.AppendLine(" /// </summary>");
|
||||
builder.AppendLine(" /// <param name=\"registry\">The source config registry.</param>");
|
||||
builder.AppendLine(
|
||||
" /// <param name=\"table\">The generated strong-typed table wrapper when lookup succeeds; otherwise null.</param>");
|
||||
" /// <param name=\"table\">The generated strongly-typed table wrapper when lookup succeeds; otherwise null.</param>");
|
||||
builder.AppendLine(
|
||||
" /// <returns>True when the generated table is registered and type-compatible; otherwise false.</returns>");
|
||||
builder.AppendLine(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user