feat(generator): 添加配置架构集成测试和JSON模式配置生成器

- 添加 ArchitectureConfigIntegrationTests 测试验证配置注册表初始化功能
- 实现 SchemaConfigGenerator 源代码生成器解析JSON schema文件
- 生成配置类型类、配置表包装器和运行时绑定辅助代码
- 支持嵌套对象、对象数组、标量数组的类型安全访问
- 提供强类型的配置表查询方法如 FindByProperty 等
- 实现跨表引用元数据生成和验证机制
This commit is contained in:
GeWuYou 2026-04-06 12:25:11 +08:00
parent 2b30e859e9
commit 7fad6772e0
3 changed files with 9 additions and 1 deletions

View File

@ -86,6 +86,10 @@ public class ArchitectureConfigIntegrationTests
{
// Ignored: cleanup is best effort and should not fail the test.
}
catch (UnauthorizedAccessException)
{
// Ignored: cleanup is best effort and can transiently fail when files are still being released.
}
}
private const string MonsterSchemaJson = @"{

View File

@ -345,6 +345,10 @@ public class SchemaConfigGeneratorTests
Assert.That(tableSource, Does.Not.Contain("FindByDropItems("));
Assert.That(tableSource, Does.Not.Contain("FindByTargetId("));
Assert.That(tableSource, Does.Not.Contain("FindByReward("));
Assert.That(tableSource, Does.Not.Contain("TryFindFirstById("));
Assert.That(tableSource, Does.Not.Contain("TryFindFirstByDropItems("));
Assert.That(tableSource, Does.Not.Contain("TryFindFirstByTargetId("));
Assert.That(tableSource, Does.Not.Contain("TryFindFirstByReward("));
});
}
}

View File

@ -1043,7 +1043,7 @@ public sealed class SchemaConfigGenerator : IIncrementalGenerator
builder.AppendLine();
builder.AppendLine(
" // Scan the current table snapshot on demand so generated helpers stay aligned with reloadable runtime data.");
builder.AppendLine($" foreach (var candidate in All())");
builder.AppendLine(" foreach (var candidate in All())");
builder.AppendLine(" {");
builder.AppendLine(
$" if (global::System.Collections.Generic.EqualityComparer<{property.TypeSpec.ClrType}>.Default.Equals(candidate.{property.PropertyName}, value))");