Skip to content

docs(config): 添加配置系统文档和分析器规则清单#243

Merged
GeWuYou merged 4 commits into
mainfrom
feature/game-content-config-system
Apr 17, 2026
Merged

docs(config): 添加配置系统文档和分析器规则清单#243
GeWuYou merged 4 commits into
mainfrom
feature/game-content-config-system

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 17, 2026

Copy link
Copy Markdown
Owner
  • 创建游戏内容配置系统详细文档,涵盖 YAML 配置、JSON Schema 结构、目录组织等
  • 添加配置系统的当前能力说明,包括运行时查询、生成器支持等功能特性
  • 完善 Schema 示例和 YAML 示例,提供完整的配置定义和数据样例
  • 整理推荐接入模板,包含目录结构、csproj 配置、启动帮助器等最佳实践
  • 补充运行时读取模板、生成查询辅助、Architecture 接入等高级使用方式
  • 添加运行时校验行为说明,涵盖跨表引用、格式验证、约束检查等内容
  • 提供开发期热重载功能文档,说明自动刷新运行时表的工作机制
  • 创建 VS Code 工具使用指南,介绍浏览、编辑、校验等开发辅助功能
  • 生成分析器规则清单文件,记录所有配置相关的诊断规则和严重级别

Summary by CodeRabbit

  • New Features
    • 新增对对象级 dependentSchemas 的支持:生成时与运行时均会解析、校验并在约束文档中展示,违反时产生明确定义的错误。
  • Documentation
    • 更新配置系统文档与 VS Code 表单提示,说明 dependentSchemas 的语义与运行时行为及提示文本。
  • Tests
    • 添加多处单元/集成测试,覆盖解析、生成时诊断、运行时拒绝/接受及引用去重场景。
  • Chores
    • 增补本地化消息、验证提示键与分析器规则条目。

- 创建游戏内容配置系统详细文档,涵盖 YAML 配置、JSON Schema 结构、目录组织等
- 添加配置系统的当前能力说明,包括运行时查询、生成器支持等功能特性
- 完善 Schema 示例和 YAML 示例,提供完整的配置定义和数据样例
- 整理推荐接入模板,包含目录结构、csproj 配置、启动帮助器等最佳实践
- 补充运行时读取模板、生成查询辅助、Architecture 接入等高级使用方式
- 添加运行时校验行为说明,涵盖跨表引用、格式验证、约束检查等内容
- 提供开发期热重载功能文档,说明自动刷新运行时表的工作机制
- 创建 VS Code 工具使用指南,介绍浏览、编辑、校验等开发辅助功能
- 生成分析器规则清单文件,记录所有配置相关的诊断规则和严重级别
@coderabbitai

coderabbitai Bot commented Apr 17, 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: d340ef29-0b96-4ccb-a070-51218a58a96c

📥 Commits

Reviewing files that changed from the base of the PR and between 2486352 and cde234d.

📒 Files selected for processing (1)
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
✅ Files skipped from review due to trivial changes (1)
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (C#)
  • GitHub Check: Code Quality & Security

📝 Walkthrough

Walkthrough

在配置系统中加入对 JSON-Schema dependentSchemas 关键字的端到端支持:生成期解析/校验、生成文档扩展、运行时解析与强制、前端工具提示与本地化、以及新增/更新的单元与集成测试与文档说明。

Changes

Cohort / File(s) Summary
源代码生成
GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs, GFramework.Game.SourceGenerators/Diagnostics/ConfigSchemaDiagnostics.cs, GFramework.Game.SourceGenerators/AnalyzerReleases.Unshipped.md
新增对 dependentSchemas 的解析与递归验证;在解析期对无效元数据立即返回 GF_ConfigSchema_011 诊断;约束文档生成扩展以渲染 dependentSchemas 的内联摘要与所需属性片段。
源代码生成测试
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
新增若干测试覆盖 dependentSchemas 的成功生成与多种生成期失败(非 object 目标、子 schema 格式错误、内联 schema 的 format 校验等)。
运行时模式验证
GFramework.Game/Config/YamlConfigSchemaValidator.cs
对象约束类型扩展以包含 DependentSchemas;解析/收集引用时遍历 dependentSchemas;在对象验证中,当触发字段存在时以 allowUnknownObjectProperties 模式匹配条件子 schema,匹配失败则抛出约束违例;引用收集合并与去重逻辑更新。
运行时验证测试
GFramework.Game.Tests/Config/YamlConfigSchemaValidatorTests.cs
调整清理逻辑并新增测试确保从 dependentSchemas 收集的跨表引用不会重复;添加 null-guard。
配置加载测试
GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
新增集成测试类,覆盖加载时对 dependentSchemas 的解析期拒绝(非 object、未声明触发属性、子 schema 非 object)与运行时行为(触发且不满足 -> 抛出 ConstraintViolation;触发缺失/满足 -> 正常加载)。
前端工具 - 验证
tools/gframework-config-tool/src/configValidation.js
解析与规范化 dependentSchemas,在对象匹配逻辑中实现触发器触发的条件子 schema 匹配(allowUnknownObjectProperties:true),验证失败时报告去重的 dependentSchemas 违规诊断;JSDoc 的 SchemaNode 增加 dependentSchemas 字段。
前端工具 - 扩展/提示
tools/gframework-config-tool/src/extension.js
新增 describeInlineSchemaForHint() 并在字段提示中为对象类型的每个 dependentSchemas 触发器附加紧凑内联模式提示(可包含必需属性摘要)。
前端工具 - 本地化
tools/gframework-config-tool/src/localization.js, tools/gframework-config-tool/src/localizationKeys.js
新增提示与验证字符串键值(webview.hint.dependentSchemaswebview.hint.requireddependentSchemasViolation)及其中/英文条目。
前端工具测试
tools/gframework-config-tool/test/configValidation.test.js, tools/gframework-config-tool/test/localization.test.js
新增解析/验证/本地化测试,涵盖 dependentSchemas 的接受/拒绝条件与本地化输出。
文档
docs/zh-CN/game/config-system.md
文档更新:能力列表、运行时校验行为及示例中加入 dependentSchemas 的说明与语义。

序列图

sequenceDiagram
    participant User as 用户
    participant Generator as SchemaConfigGenerator
    participant Validator as YamlConfigSchemaValidator
    participant Loader as YamlConfigLoader
    participant Registry as ConfigRegistry

    User->>Generator: 提交包含 dependentSchemas 的 schema
    Generator->>Generator: 解析并递归验证 dependentSchemas 元数据
    alt 元数据无效
        Generator-->>User: 返回诊断 GF_ConfigSchema_011
    else 元数据有效
        Generator-->>User: 生成包含 dependentSchemas 的约束文档
    end

    User->>Loader: 请求加载 YAML 配置
    Loader->>Validator: 使用 schema 验证 YAML
    Validator->>Validator: 解析 dependentSchemas 并遍历触发器
    alt 触发字段存在
        Validator->>Validator: 用 allowUnknownObjectProperties 匹配触发子 schema
        alt 匹配失败
            Validator-->>Loader: 抛出 ConfigLoadException (ConstraintViolation)
            Loader-->>User: 加载失败
        else 匹配成功
            Validator-->>Loader: 验证通过
            Loader->>Registry: 注册配置项
            Registry-->>User: 加载成功
        end
    else 未触发
        Validator-->>Loader: 跳过 dependentSchemas 检查
        Loader->>Registry: 注册配置项
        Registry-->>User: 加载成功
    end
Loading

估计代码审查工作量

🎯 4 (Complex) | ⏱️ ~45 分钟

可能相关的 PR

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning PR标题关注于文档和分析器规则清单,但实际变更包含了对dependentSchemas功能的完整实现,涵盖生成器、验证器、运行时、测试和工具支持等关键功能。 建议更新PR标题以反映主要变更:实现dependentSchemas约束支持,或更改为突出功能实现而非仅文档的标题,如'feat(config): 实现dependentSchemas对象级约束支持'或类似的更准确描述。
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 94.64% 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 feature/game-content-config-system

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: 5

🧹 Nitpick comments (2)
tools/gframework-config-tool/src/configValidation.js (1)

1744-1768: 建议把 dependentSchemas 触发判断抽成共享 helper。

validateObjectNode()matchesSchemaNodeInternal() 现在各维护了一遍同样的触发/匹配循环;后面如果再调整触发条件或 object 匹配语义,这两处很容易只改到一边。

Also applies to: 1872-1879

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

In `@tools/gframework-config-tool/src/configValidation.js` around lines 1744 -
1768, The duplicate dependentSchemas trigger/match loop in validateObjectNode()
and matchesSchemaNodeInternal() should be extracted into a shared helper to
avoid drift; create a function (e.g., checkDependentSchemas(schemaNode,
yamlNode, displayPath, localizer, reportedMessages, diagnostics,
matchesSchemaNode)) that encapsulates the iteration over
schemaNode.dependentSchemas, the trigger property existence check, calling the
existing matching routine (or an injected matchesSchemaNode reference), building
the localized message via
localizeValidationMessage(ValidationMessageKeys.dependentSchemasViolation, ...),
deduplicating with reportedMessages, and pushing diagnostics; replace the
duplicated blocks in validateObjectNode() and matchesSchemaNodeInternal() with
calls to this helper, passing the appropriate parameters and the matching
function reference so behavior is unchanged.
GFramework.Game/Config/YamlConfigSchemaValidator.cs (1)

815-833: 请把 ValidateObjectConstraints 的 XML 注释同步到新职责。

这个方法现在不仅做属性数量检查,还负责 dependentRequireddependentSchemas 的条件校验;但摘要仍写成“校验对象节点声明的属性数量约束”,和实际行为已经不一致。建议把方法意图、mappingNode/references 的用途,以及条件子 schema 的匹配语义补齐到注释里。

As per coding guidelines, "Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any".

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

In `@GFramework.Game/Config/YamlConfigSchemaValidator.cs` around lines 815 - 833,
更新 ValidateObjectConstraints 的 XML
注释以反映其真实职责:说明该方法不仅校验对象属性数量约束(minProperties/maxProperties),还处理
dependentRequired(基于某些属性存在强制出现其它属性)和 dependentSchemas(基于某些属性存在需验证的子
schema)两类条件校验;明确描述 mappingNode 参数表示当前 YAML 对象节点、seenProperties
用于跟踪已出现属性、schemaNode 为该对象的 schema 定义、references 用于收集/校验跨表引用;补充对 dependentSchemas
匹配语义(当触发属性存在时应对整个对象应用哪些子 schema)、对无 schema/空 mapping
的边界情况以及失败时如何记录/抛出错误的核心决策与处理方式。
🤖 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.Core.SourceGenerators/AnalyzerReleases.Unshipped.md`:
- Around line 21-31: Remove the GF_ConfigSchema_011 entry from
GFramework.Core.SourceGenerators/AnalyzerReleases.Unshipped.md and add the
identical entry into
GFramework.Game.SourceGenerators/AnalyzerReleases.Unshipped.md immediately after
the GF_ConfigSchema_010 line; the diagnostic GF_ConfigSchema_011 is defined in
GFramework.Game.SourceGenerators (see Diagnostics/ConfigSchemaDiagnostics.cs)
and only the Game project has AdditionalFiles configured for analyzer release
tracking, so ensure the entry is present in that project's
AnalyzerReleases.Unshipped.md and removed from the Core project's file.

In `@GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs`:
- Around line 3451-3453: 在 TryBuildInlineSchemaSummary 方法上为新加入的布尔参数
includeRequiredProperties 补上 XML 注释:在方法的 XML 文档注释里添加 <param
name="includeRequiredProperties">…</param> 描述该参数的作用(例如是否在摘要中包含必需属性),以消除构建时的
analyzer 警告并保持文档完整;确保参数名称准确匹配 includeRequiredProperties。
- Around line 981-995: The current lambda returns success whenever schemaType !=
"object", silently allowing non-object nodes to carry dependentSchemas; change
it to detect if currentElement contains a "dependentSchemas" entry and, when
schemaType is not "object", produce and return a Diagnostic instead of success.
Specifically, inside the lambda that references schemaType, currentElement,
currentFilePath and currentDisplayPath, check currentElement for a
dependentSchemas property (or equivalent key) and if found create a Diagnostic
describing "dependentSchemas only valid on object schemas" (using
currentFilePath/currentDisplayPath for context) and return (false, diagnostic);
otherwise keep returning success for nodes without dependentSchemas. Ensure
TryValidateDependentSchemasMetadata is still used for object schemas.

In `@GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs`:
- Line 13: _rootPath is currently initialized with a null-forgiving null! which
bypasses nullable safety; change its declaration to string? _rootPath and ensure
it's assigned in the test SetUp method (or via fixture) before use, then replace
direct uses with explicit null checks or Assert.NotNull(_rootPath) / throw if
null so callers use a non-null string; update any references in
YamlConfigLoaderDependentSchemasTests (including SetUp and test methods) to
handle the nullable type accordingly and avoid runtime null dereferences.

In `@GFramework.Game/Config/YamlConfigSchemaValidator.cs`:
- Around line 923-934: The code passes the outer references collection into
TryMatchSchemaNode for dependentSchemas which causes duplicate
YamlConfigReferenceUsage entries when the same x-gframework-ref-table is
collected twice; modify the logic around TryMatchSchemaNode (the
dependentSchemas handling) so you either (a) call TryMatchSchemaNode with a
fresh temporary references collection and only merge back the new entries after
deduplicating by yaml path + target table, or (b) merge matchedReferences into
the outer references with a uniqueness filter keyed on the combination of path
and target table (used by ValidateAndCollectReferences/YamlConfigReferenceUsage)
to avoid adding duplicates. Ensure dedup key uses the YAML path and reference
target table and apply it when handling dependentSchemas matching.

---

Nitpick comments:
In `@GFramework.Game/Config/YamlConfigSchemaValidator.cs`:
- Around line 815-833: 更新 ValidateObjectConstraints 的 XML
注释以反映其真实职责:说明该方法不仅校验对象属性数量约束(minProperties/maxProperties),还处理
dependentRequired(基于某些属性存在强制出现其它属性)和 dependentSchemas(基于某些属性存在需验证的子
schema)两类条件校验;明确描述 mappingNode 参数表示当前 YAML 对象节点、seenProperties
用于跟踪已出现属性、schemaNode 为该对象的 schema 定义、references 用于收集/校验跨表引用;补充对 dependentSchemas
匹配语义(当触发属性存在时应对整个对象应用哪些子 schema)、对无 schema/空 mapping
的边界情况以及失败时如何记录/抛出错误的核心决策与处理方式。

In `@tools/gframework-config-tool/src/configValidation.js`:
- Around line 1744-1768: The duplicate dependentSchemas trigger/match loop in
validateObjectNode() and matchesSchemaNodeInternal() should be extracted into a
shared helper to avoid drift; create a function (e.g.,
checkDependentSchemas(schemaNode, yamlNode, displayPath, localizer,
reportedMessages, diagnostics, matchesSchemaNode)) that encapsulates the
iteration over schemaNode.dependentSchemas, the trigger property existence
check, calling the existing matching routine (or an injected matchesSchemaNode
reference), building the localized message via
localizeValidationMessage(ValidationMessageKeys.dependentSchemasViolation, ...),
deduplicating with reportedMessages, and pushing diagnostics; replace the
duplicated blocks in validateObjectNode() and matchesSchemaNodeInternal() with
calls to this helper, passing the appropriate parameters and the matching
function reference so behavior is unchanged.
🪄 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: f60a3660-380b-4df9-bd20-0356fb89d257

📥 Commits

Reviewing files that changed from the base of the PR and between 1d6ff22 and 5185247.

📒 Files selected for processing (13)
  • GFramework.Core.SourceGenerators/AnalyzerReleases.Unshipped.md
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.Game.SourceGenerators/Diagnostics/ConfigSchemaDiagnostics.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • docs/zh-CN/game/config-system.md
  • tools/gframework-config-tool/src/configValidation.js
  • tools/gframework-config-tool/src/extension.js
  • tools/gframework-config-tool/src/localization.js
  • tools/gframework-config-tool/src/localizationKeys.js
  • tools/gframework-config-tool/test/configValidation.test.js
  • tools/gframework-config-tool/test/localization.test.js
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (C#)
  • GitHub Check: Code Quality & Security
🧰 Additional context used
📓 Path-based instructions (3)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as // increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explaining why and when, not just what
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...

Files:

  • GFramework.Game.SourceGenerators/Diagnostics/ConfigSchemaDiagnostics.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
{README.md,docs/**/*}

📄 CodeRabbit inference engine (AGENTS.md)

{README.md,docs/**/*}: Update the relevant README.md or docs/ page when behavior, setup steps, architecture guidance, or user-facing examples change
Keep code samples, package names, and command examples aligned with the current repository state in documentation
Prefer documenting behavior and design intent, not only API surface in documentation
If an existing documentation page no longer reflects the current implementation, fixing the code without fixing the documentation is considered incomplete work

Files:

  • docs/zh-CN/game/config-system.md
docs/zh-CN/**/*

📄 CodeRabbit inference engine (AGENTS.md)

docs/zh-CN/**/*: When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in docs/zh-CN/ in the same change
For integration-oriented features such as the AI-First config system, documentation MUST cover: project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes
Do not rely on "the code is self-explanatory" for framework features that consumers need to adopt; write the adoption path down so future users do not need to rediscover it from source

Files:

  • docs/zh-CN/game/config-system.md
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : For integration-oriented features such as the AI-First config system, documentation MUST cover: project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Game.SourceGenerators/Diagnostics/ConfigSchemaDiagnostics.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation

Applied to files:

  • GFramework.Core.SourceGenerators/AnalyzerReleases.Unshipped.md
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change

Applied to files:

  • tools/gframework-config-tool/src/localization.js
  • docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : For integration-oriented features such as the AI-First config system, documentation MUST cover: project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes

Applied to files:

  • docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
📚 Learning: 2026-04-16T13:25:59.124Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 235
File: GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs:1-3
Timestamp: 2026-04-16T13:25:59.124Z
Learning: In the GeWuYou/GFramework repo, treat `global using NUnit.Framework;` as provided project-wide by `GFramework.SourceGenerators.Tests/GlobalUsings.cs` (via GlobalUsings.cs). Do not require or flag missing per-file `using NUnit.Framework;` directives in test `.cs` files under `GFramework.SourceGenerators.Tests/`, since the project-wide global usings already include NUnit (along with other common namespaces).

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs

Applied to files:

  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
🪛 GitHub Check: Build and Test
GFramework.Game.SourceGenerators/Diagnostics/ConfigSchemaDiagnostics.cs

[warning] 126-126:
Rule 'GF_ConfigSchema_011' is not part of any analyzer release (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)


[warning] 126-126:
Rule 'GF_ConfigSchema_011' is not part of any analyzer release (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs

[warning] 3453-3453:
Parameter 'includeRequiredProperties' has no matching param tag in the XML comment for 'SchemaConfigGenerator.TryBuildInlineSchemaSummary(JsonElement, bool)' (but other parameters do)


[warning] 3453-3453:
Parameter 'includeRequiredProperties' has no matching param tag in the XML comment for 'SchemaConfigGenerator.TryBuildInlineSchemaSummary(JsonElement, bool)' (but other parameters do)

🔇 Additional comments (11)
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs (1)

476-643: dependentSchemas 相关生成器测试覆盖完整,方向正确。

这 3 个新增用例同时覆盖了成功路径(文档输出)和失败路径(GF_ConfigSchema_011GF_ConfigSchema_009),回归保护力度足够。

Based on learnings: Source generator changes MUST be covered by generator tests; Regression fixes should include a test that fails before the fix and passes after it.

tools/gframework-config-tool/src/localizationKeys.js (1)

3-3: 新增校验消息 key 与现有键空间保持一致。

命名和导出方式都与现有 ValidationMessageKeys 设计一致,可直接被本地化与校验流程复用。

GFramework.Game.SourceGenerators/Diagnostics/ConfigSchemaDiagnostics.cs (1)

122-131: 新诊断描述符定义清晰且与现有规则体系一致。

GF_ConfigSchema_011 的标题、消息模板和分类延续了当前配置 schema 诊断的统一风格,便于工具链与测试侧消费。

tools/gframework-config-tool/test/localization.test.js (1)

115-148: 新增本地化测试覆盖面到位。

同一用例里同时验证了 webview.hint.dependentSchemasValidationMessageKeys.dependentSchemasViolation 的中英文文案,回归保护有效。

tools/gframework-config-tool/src/localization.js (1)

124-146: 新增文案键在中英文词典中保持了对称性。

webview.hint.dependentSchemasdependentSchemasViolation 两类文案都已双语补齐,和测试、调用点保持一致。

Also applies to: 248-270

tools/gframework-config-tool/src/extension.js (1)

1578-1620: dependentSchemas 的提示渲染接线完整,且 helper 抽取合理。

内联 schema 摘要由独立函数生成,再在 renderFieldHint 中统一接入,新增能力与现有提示系统融合得比较干净。

Also applies to: 1715-1724

docs/zh-CN/game/config-system.md (1)

15-15: dependentSchemas 的中文用户文档同步及时且覆盖关键接入信息。

能力清单、运行时校验行为、约束语义和 VS Code 工具提示都已补齐,和本次功能改动保持一致。

As per coding guidelines: docs/zh-CN/**/*: When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in docs/zh-CN/ in the same change; For integration-oriented features such as the AI-First config system, documentation MUST cover: project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes.

Also applies to: 728-728, 794-794, 891-891

tools/gframework-config-tool/test/configValidation.test.js (1)

1694-1943: dependentSchemas 的回归覆盖很完整。

这里把解析期的 shape 校验、触发字段缺席、触发后失败/成功几条主路径都补齐了,和 parseDependentSchemasMetadata() / validateParsedConfig() 的新增分支是对齐的。

tools/gframework-config-tool/src/configValidation.js (1)

1137-1147: dependentSchemas 的接线补得很完整。

parseSchemaNode()、元数据解析、本地化消息和 SchemaNode typedef 都一起更新了,新关键字在工具链里的落点比较一致。

Also applies to: 1327-1375, 2294-2295, 2348-2349, 3099-3099

GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs (1)

37-304: 测试场景覆盖面不错。

运行时的触发/不触发/满足约束,以及 schema 解析期的两个拒绝路径都补到了,基本把 dependentSchemas 的主干行为兜住了。

Based on learnings "Public API changes must be covered by unit or integration tests".

GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs (1)

739-760: dependentSchemas 纳入统一递归遍历这点很好。

这样 formatdependentRequireddependentSchemas 都复用同一套 schema 遍历路径,后续扩展关键字时更不容易出现覆盖范围漂移。

Comment thread GFramework.Core.SourceGenerators/AnalyzerReleases.Unshipped.md Outdated
Comment thread GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
Comment thread GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
Comment thread GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs Outdated
Comment thread GFramework.Game/Config/YamlConfigSchemaValidator.cs
- 实现配置架构解析器和验证功能
- 添加YAML解析和注释提取功能
- 创建配置验证诊断规则表格
- 实现批量编辑器支持的字段提取
- 添加字符串格式验证(日期、邮箱、UUID等)
- 创建示例配置YAML生成功能
- 实现表单更新应用到YAML的功能
- 添加常量和枚举值的元数据处理
- 实现精确小数倍数验证算法
- 添加配置模式规范化和比较功能

@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

🤖 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/YamlConfigLoaderDependentSchemasTests.cs`:
- Around line 207-305: Add a new unit test mirroring the existing
dependentSchemas tests that verifies the validator rejects a dependentSchemas
entry whose trigger key is not declared in the sibling "properties";
specifically create a config with reward.itemId, create a schema where
"reward.dependentSchemas" contains a key (e.g. "missingField") that is not
present under "reward.properties", then call
CreateMonsterRewardLoader().LoadAsync(registry) and
Assert.ThrowsAsync<ConfigLoadException> and assert
exception.Diagnostic.FailureKind == ConfigLoadFailureKind.SchemaUnsupported,
exception.Diagnostic.DisplayPath references the dependentSchemas entry (e.g.
"reward[dependentSchemas:missingField]"), the message contains a phrase about
undeclared trigger field, and registry remains empty; this covers the
ParseDependentSchemasConstraints branch that throws when the trigger is not
declared.
🪄 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: 41b71e42-8370-440e-863d-d3d96a324782

📥 Commits

Reviewing files that changed from the base of the PR and between 5185247 and 01a815a.

📒 Files selected for processing (7)
  • GFramework.Game.SourceGenerators/AnalyzerReleases.Unshipped.md
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
  • GFramework.Game.Tests/Config/YamlConfigSchemaValidatorTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • tools/gframework-config-tool/src/configValidation.js
✅ Files skipped from review due to trivial changes (2)
  • GFramework.Game.SourceGenerators/AnalyzerReleases.Unshipped.md
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • GFramework.Game.SourceGenerators/Config/SchemaConfigGenerator.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as // increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explaining why and when, not just what
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...

Files:

  • GFramework.Game.Tests/Config/YamlConfigSchemaValidatorTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : For integration-oriented features such as the AI-First config system, documentation MUST cover: project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigSchemaValidatorTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigSchemaValidatorTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Write null-safe code that respects nullable annotations instead of suppressing warnings by default

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : When a public API defines multiple contract branches, tests MUST cover the meaningful variants, including null, empty, default, and filtered inputs when those branches change behavior

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
🔇 Additional comments (11)
tools/gframework-config-tool/src/configValidation.js (1)

1136-1147: dependentSchemas 的工具链路补全得很完整。

这里把解析、触发筛选、无诊断匹配、用户可见诊断和类型定义一次性补齐了,和 GFramework.Game/Config/YamlConfigSchemaValidator.cs:1761-1828 的运行时约束基本对齐,能明显减少编辑器与运行时语义漂移。

Also applies to: 1327-1375, 1744-1768, 1797-1821, 1897-1901, 2316-2317, 2370-2371, 3121-3121

GFramework.Game.Tests/Config/YamlConfigSchemaValidatorTests.cs (2)

12-12: 测试夹具的可空收口是对的。

_rootPath 改成 string? 之后,TearDown 和辅助方法也同步加了显式保护,能避免初始化中断时把真正的失败原因噪掉。

Also applies to: 30-31, 139-139


74-127: 这条去重回归测试补得很有价值。

它直接钉住了 dependentSchemas 分支里的引用收集去重行为,后续如果遍历逻辑回退成重复追加,这里会第一时间报出来。 Based on learnings: Public API changes must be covered by unit or integration tests.

GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs (2)

13-35: 这组 nullable 收口处理得很稳。

_rootPath 改成可空后,清理逻辑和 helper 入口都一起补上了显式保护,避免了测试夹具在异常路径上的二次空引用。 Based on learnings: Write null-safe code that respects nullable annotations instead of suppressing warnings by default.

Also applies to: 312-345


38-205: 运行时三条主分支已经覆盖到位。

“触发缺失 / 触发但不满足 / 触发且满足” 都有单独断言,而且还顺手校验了 ConfigRegistry 状态,回归保护比较扎实。 Based on learnings: Regression fixes should include a test that fails before the fix and passes after it.

GFramework.Game/Config/YamlConfigSchemaValidator.cs (6)

13-16: 文档更新准确反映了新增的 dependentSchemas 支持。

类级别 XML 文档已正确补充 dependentSchemas 关键字说明,与 PR 目标一致。


935-956: dependentSchemas 校验逻辑正确,引用去重机制已就位。

当前实现将 references 传入 TryMatchSchemaNode,但内部逻辑(第 3133 行)会创建临时 matchedReferences 列表,并通过 AddUniqueReferenceUsages(第 3149 行)以结构化标识去重后回写。此设计有效解决了先前评审中指出的"同一字段被主校验链和条件子 schema 重复采集"的问题。

allowUnknownObjectProperties: true 的使用符合 dependentSchemas 的语义——触发后只需验证条件 schema 声明的属性子集,不要求所有同级字段都在条件 schema 中声明。


1750-1828: ParseDependentSchemasConstraints 实现完整,校验层次分明。

该方法对 dependentSchemas 的解析逻辑严谨:

  1. 第 1773-1781 行:确保关键字值为 JSON 对象。
  2. 第 1786-1794 行:确保触发字段已在当前对象 properties 中声明,避免运行时和工具链对未知键名各自容错。
  3. 第 1796-1804 行:确保每个依赖项的值为对象形式的 schema。
  4. 第 1812-1820 行:确保解析后的 schema 节点类型为 Object,符合 dependentSchemas 应用于整个对象的语义。

错误消息使用 DescribeObjectSchemaTarget / DescribeObjectSchemaTargetInClause 保持诊断文本风格一致。


3161-3203: 引用去重逻辑实现正确,结构化比较覆盖完整。

ContainsReferenceUsage 方法对 YamlConfigReferenceUsage 的六个字段(YamlPathSchemaPathPropertyPathRawValueReferencedTableNameValueType)进行全量比较,确保语义相同的引用不会重复添加。

当前 O(n·m) 的复杂度对于典型配置文件(数十个引用)是可接受的。如果未来遇到大量引用的场景,可以考虑使用 HashSet + 自定义 IEqualityComparer<YamlConfigReferenceUsage> 优化,但目前的实现简洁且易于维护。


3618-3626: 依赖闭包采集已正确扩展至 dependentSchemas

新增的遍历逻辑确保 dependentSchemas 内联子 schema 中声明的 x-gframework-ref-table 引用被纳入依赖表名称集合,保证热重载簿记和依赖推导的完整性。


4219-4265: YamlConfigObjectConstraints 扩展符合预期。

类文档、构造函数参数和新增属性 DependentSchemas 的 XML 注释完整,清晰描述了条件 schema 约束的语义。

- 验证触发字段出现但条件schema未满足时抛出异常
- 验证触发字段缺席时不会误触发dependentSchemas检查
- 验证触发字段出现且条件schema满足时正常加载对象
- 验证非对象dependentSchemas声明在解析阶段被拒绝
- 验证dependentSchemas触发字段必须在同级properties中显式声明
- 验证dependentSchemas只接受object-typed条件子schema
- 实现临时目录创建和清理避免文件堆积
- 提供完整的测试用例覆盖dependentSchemas各种场景

@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.

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

51-78: 可选:提取重复的 schema/YAML 构造以降低维护成本。

当前多个用例内联了高度重复的 JSON/YAML 文本;后续如果消息或字段改名,维护成本会偏高。建议抽一个基础 schema builder + 局部覆写,提高可读性和变更一致性。

可选重构示例(提取公共 schema 构造)
+    private static string BuildMonsterSchema(string rewardPropertiesJson, string dependentSchemasJson)
+    {
+        return $$"""
+        {
+          "type": "object",
+          "required": ["id", "reward"],
+          "properties": {
+            "id": { "type": "integer" },
+            "reward": {
+              "type": "object",
+              "properties": {{rewardPropertiesJson}},
+              "dependentSchemas": {{dependentSchemasJson}}
+            }
+          }
+        }
+        """;
+    }

Also applies to: 109-136, 162-189, 223-238, 271-292, 325-344

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

In `@GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs` around
lines 51 - 78, 测试中多处内联重复的 JSON/YAML schema 增加维护成本;在
YamlConfigLoaderDependentSchemasTests 中将重复构造提取为可复用的构建器(例如一个
BuildBaseMonsterSchema 或 GetBaseRewardSchema 方法)以返回基础 schema(string 或
JObject),然后在每个用例里对该基础 schema 做局部覆写/合并后再传给
CreateSchemaFile,这样只需在一个位置维护公共字段并在各测试中仅应用差异化修改(引用 CreateSchemaFile 和
YamlConfigLoaderDependentSchemasTests 中的构建器名以定位修改点)。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs`:
- Around line 51-78: 测试中多处内联重复的 JSON/YAML schema 增加维护成本;在
YamlConfigLoaderDependentSchemasTests 中将重复构造提取为可复用的构建器(例如一个
BuildBaseMonsterSchema 或 GetBaseRewardSchema 方法)以返回基础 schema(string 或
JObject),然后在每个用例里对该基础 schema 做局部覆写/合并后再传给
CreateSchemaFile,这样只需在一个位置维护公共字段并在各测试中仅应用差异化修改(引用 CreateSchemaFile 和
YamlConfigLoaderDependentSchemasTests 中的构建器名以定位修改点)。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 77218e6a-61ab-4d65-9f79-b03743521eb1

📥 Commits

Reviewing files that changed from the base of the PR and between 01a815a and 2486352.

📒 Files selected for processing (1)
  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as // increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explaining why and when, not just what
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...

Files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : For integration-oriented features such as the AI-First config system, documentation MUST cover: project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Write null-safe code that respects nullable annotations instead of suppressing warnings by default

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : When a public API defines multiple contract branches, tests MUST cover the meaningful variants, including null, empty, default, and filtered inputs when those branches change behavior

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs
🔇 Additional comments (2)
GFramework.Game.Tests/Config/YamlConfigLoaderDependentSchemasTests.cs (2)

38-359: 测试分支覆盖完整,行为断言到位。

这组用例把 dependentSchemas 的主要契约分支都覆盖到了,并且同时校验了 FailureKindDisplayPath 与注册表状态,能有效防回归。

Based on learnings: Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical.


13-37: 空安全与测试隔离实现良好。

_rootPath 的可空处理、使用点显式空检查、以及 SetUp/TearDown 的目录隔离与清理策略都比较稳健。

Based on learnings: Write null-safe code that respects nullable annotations instead of suppressing warnings by default.

Also applies to: 366-404

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 17, 2026
- 实现YAML配置加载器对对象级dependentSchemas约束的运行时行为验证
- 添加dependentSchemas不满足时抛出异常的测试用例
- 添加触发字段缺席时不误触发dependentSchemas检查的测试用例
- 添加dependentSchemas满足时正常加载并保留额外字段的测试用例
- 添加非对象类型dependentSchemas声明时抛出异常的测试用例
- 添加触发字段未在同级properties中声明时的错误处理测试
- 添加dependentSchemas条件子schema非object类型时的验证测试
- 实现临时目录管理以避免不同测试场景间的数据污染
- 提供完整的测试辅助方法包括文件创建、schema构建等功能
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