From 7fad6772e04e03e64ce55e5816dce60c245e012a Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Mon, 6 Apr 2026 12:25:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(generator):=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=9E=B6=E6=9E=84=E9=9B=86=E6=88=90=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=92=8CJSON=E6=A8=A1=E5=BC=8F=E9=85=8D=E7=BD=AE=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 ArchitectureConfigIntegrationTests 测试验证配置注册表初始化功能 - 实现 SchemaConfigGenerator 源代码生成器解析JSON schema文件 - 生成配置类型类、配置表包装器和运行时绑定辅助代码 - 支持嵌套对象、对象数组、标量数组的类型安全访问 - 提供强类型的配置表查询方法如 FindByProperty 等 - 实现跨表引用元数据生成和验证机制 --- .../Config/ArchitectureConfigIntegrationTests.cs | 4 ++++ .../Config/SchemaConfigGeneratorTests.cs | 4 ++++ GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs b/GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs index d4a448c5..95b5c5e8 100644 --- a/GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs +++ b/GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs @@ -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 = @"{ diff --git a/GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs b/GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs index 133884b2..20f74ea9 100644 --- a/GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs +++ b/GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs @@ -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(")); }); } } diff --git a/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs b/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs index 60f3ec53..50ac393a 100644 --- a/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs +++ b/GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs @@ -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))");