Skip to content

feat(config): 添加配置系统集成测试和文档#189

Merged
GeWuYou merged 2 commits into
mainfrom
feat/config-system-integration
Apr 6, 2026
Merged

feat(config): 添加配置系统集成测试和文档#189
GeWuYou merged 2 commits into
mainfrom
feat/config-system-integration

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 6, 2026

Copy link
Copy Markdown
Owner
  • 添加 ArchitectureConfigIntegrationTests 验证架构初始化流程中配置加载
  • 添加 GeneratedConfigConsumerIntegrationTests 测试消费者项目配置绑定功能
  • 添加完整的游戏内容配置系统中文文档
  • 添加生成配置目录和注册选项支持批量表注册与筛选
  • 实现配置架构集成模板和热重载功能
  • 添加跨表引用校验和运行时诊断功能
  • 实现 VS Code 工具支持配置浏览和表单编辑
  • 添加查询辅助方法支持按字段快速检索配置数据

Summary by CodeRabbit

  • New Features

    • Added selective registration for generated config tables: restrict which tables register by domain, name, or custom predicate.
  • Tests

    • Expanded integration tests to cover multi-domain config assets, item schema handling, and the new filtering behaviors.
  • Documentation

    • Added examples and guidance for using selective config-table registration and updated testing requirements for API branch coverage.

- 添加 ArchitectureConfigIntegrationTests 验证架构初始化流程中配置加载
- 添加 GeneratedConfigConsumerIntegrationTests 测试消费者项目配置绑定功能
- 添加完整的游戏内容配置系统中文文档
- 添加生成配置目录和注册选项支持批量表注册与筛选
- 实现配置架构集成模板和热重载功能
- 添加跨表引用校验和运行时诊断功能
- 实现 VS Code 工具支持配置浏览和表单编辑
- 添加查询辅助方法支持按字段快速检索配置数据

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @GeWuYou, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepsource-io

deepsource-io Bot commented Apr 6, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in e9e04d9...975f556 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
C# Apr 6, 2026 9:24a.m. Review ↗
Secrets Apr 6, 2026 9:24a.m. Review ↗

@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f50dce70-8c92-4d1c-b1f2-a0c48d4b1084

📥 Commits

Reviewing files that changed from the base of the PR and between 92eb365 and 975f556.

📒 Files selected for processing (2)
  • AGENTS.md
  • GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs
✅ Files skipped from review due to trivial changes (1)
  • AGENTS.md

📝 Walkthrough

Walkthrough

Adds per-call filtering to aggregated generated-config registration. GeneratedConfigRegistrationOptions gains IncludedConfigDomains, IncludedTableNames, and TableFilter; the generator emits per-table ShouldRegisterTable(...) guards and tests/docs updated to validate domain/table/predicate filtering and expanded monster/item integration scenarios.

Changes

Cohort / File(s) Summary
Integration Tests
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs, GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs
Tightens architecture test to assert item table is not registered when filtering to the monster domain. Expands consumer integration test to create monster+item assets, validate both tables, add helpers, and add a new test exercising filtering by domain, table name, empty allowlists, and predicate.
Test Schema Asset
GFramework.Game.Tests/schemas/item.schema.json
New JSON Schema for Item Config (required id, name, category string properties) used by integration tests.
Generator Tests & Snapshot
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs, GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/GeneratedConfigCatalog.g.txt
Expectations updated for three new optional properties on GeneratedConfigRegistrationOptions and conditional registration guards (ShouldRegisterTable, MatchesOptionalAllowList) in generated catalog snapshot.
Source Generator
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
Emits IncludedConfigDomains, IncludedTableNames, and TableFilter on GeneratedConfigRegistrationOptions; changes aggregate registration to iterate tables and call generated ShouldRegisterTable(...) to apply allow-lists and predicate filtering before registering each table.
Docs & Policy
docs/zh-CN/game/config-system.md, AGENTS.md
Adds examples and rules documenting RegisterAllGeneratedConfigTables(...) filtering semantics (ordinal comparison, null/empty = unrestricted, predicate after allow-lists) and updates testing guidance to require coverage of null/empty/default/filtered variants.

Sequence Diagram

sequenceDiagram
    participant Test
    participant YamlConfigLoader
    participant GeneratedCatalog as GeneratedCatalog (Tables...)
    participant ShouldRegister as ShouldRegisterTable (Filter Helper)
    participant Registry as Config Registry

    Test->>YamlConfigLoader: RegisterAllGeneratedConfigTables(loader, options)
    Note over YamlConfigLoader: options = {IncludedConfigDomains, IncludedTableNames, TableFilter}

    loop for each metadata in GeneratedCatalog.Tables
        YamlConfigLoader->>ShouldRegister: ShouldRegisterTable(metadata, options)
        ShouldRegister-->>YamlConfigLoader: true/false
        alt true
            YamlConfigLoader->>Registry: RegisterTable(metadata, loader, ...)
        else false
            Note over YamlConfigLoader: Skip registration for this table
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #188 — Introduced the aggregated RegisterAllGeneratedConfigTables catalog/registration flow that this change extends with per-call filtering options.

Poem

🐰 I hopped through tables, sniffed each name,
I sorted domains with a playful game,
By name or predicate, I choose the few,
Only what’s needed jumps into view! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title describes adding integration tests and documentation to the config system, which aligns with the main changes: new integration tests, documentation, and filtering registration features.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/config-system-integration

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs (1)

188-282: Avoid maintaining a second copy of the schemas in this test.

CreateMonsterFiles() and CreateItemFiles() now duplicate the same contracts that already live in the test project’s schemas/ inputs. If those copies drift, this stops being a true end-to-end consumer test because generation and runtime validation are no longer using the same schema.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs`
around lines 188 - 282, CreateMonsterFiles and CreateItemFiles duplicate schema
definitions that already exist in the test project's schemas inputs; remove the
hard-coded JSON/YAML literals and instead have those helpers copy or reference
the existing schema and sample YAML files from the test project's "schemas/" and
related input directories (use the existing CreateFile callers like CreateFile
and the helpers CreateMonsterFiles/CreateItemFiles to read and write from the
canonical source files rather than embedding new literals) so generation and
runtime validation use the same single source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs`:
- Around line 118-166: Extend the existing test
RegisterAllGeneratedConfigTables_Should_Support_Filtering_By_Domain_Table_Name_And_Predicate
to also exercise the "empty allow-list" branches by creating additional
ConfigRegistry/YamlConfigLoader pairs that call RegisterAllGeneratedConfigTables
with GeneratedConfigRegistrationOptions.IncludedConfigDomains =
Array.Empty<string>() and IncludedTableNames = Array.Empty<string>(); after
LoadAsync assert that these empty-list registries behave like the unrestricted
case (i.e., both Monster and Item tables are registered and accessible, similar
to the null/default behavior already asserted), using the existing
TryGetMonsterTable/TryGetItemTable assertions to validate the result.

---

Nitpick comments:
In `@GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs`:
- Around line 188-282: CreateMonsterFiles and CreateItemFiles duplicate schema
definitions that already exist in the test project's schemas inputs; remove the
hard-coded JSON/YAML literals and instead have those helpers copy or reference
the existing schema and sample YAML files from the test project's "schemas/" and
related input directories (use the existing CreateFile callers like CreateFile
and the helpers CreateMonsterFiles/CreateItemFiles to read and write from the
canonical source files rather than embedding new literals) so generation and
runtime validation use the same single source of truth.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f808215b-04b6-4fe5-887e-0021a0006594

📥 Commits

Reviewing files that changed from the base of the PR and between e9e04d9 and 92eb365.

📒 Files selected for processing (7)
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
  • GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs
  • GFramework.Game.Tests/schemas/item.schema.json
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/GeneratedConfigCatalog.g.txt
  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • docs/zh-CN/game/config-system.md

- 创建AGENTS.md文档定义AI代理编码行为规则
- 包含环境能力清单、注释规则、代码风格要求
- 定义测试要求、安全规则和文档规范
- 添加端到端集成测试验证生成配置消费者功能
- 实现跨域配置表加载和强类型访问验证
- 添加按域、表名和自定义谓词过滤注册支持
- 提供完整的测试验证命令和执行期望说明
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant