Feat/config schema generator and validation#198
Conversation
- 实现了SchemaConfigGenerator源代码生成器 - 支持根据JSON schema文件自动生成配置类型 - 生成强类型的配置表包装类 - 支持嵌套对象和对象数组的类型生成 - 生成配置表的查询和索引功能 - 添加了跨表引用的元数据支持 - 生成运行时注册和访问辅助代码 - 支持默认值、枚举和约束的文档生成
- 实现了配置模式解析器,支持递归对象/数组/标量树结构 - 添加了可编辑字段收集功能,支持批量编辑标量和数组类型 - 实现了YAML解析器,支持嵌套对象、标量数组和对象数组 - 添加了YAML注释提取功能,将注释映射到逻辑字段路径 - 实现了基于模式的示例YAML配置生成功能 - 添加了扩展端验证诊断功能,支持中英文错误消息 - 实现了表单更新应用功能,支持标量、数组和对象数组更新 - 添加了批处理数组值解析和模式枚举值标准化功能 - 实现了YAML标量格式化和引号移除功能 - 添加了完整的模式节点验证,支持数值约束、长度限制和模式匹配 - 实现了多语言验证消息本地化功能 - 添加了YAML标记化和块解析功能 - 实现了唯一性检查和比较键构建功能
- 介绍面向静态游戏内容的 AI-First 配表方案 - 详细说明 YAML 配置源文件和 JSON Schema 结构描述功能 - 提供推荐目录结构和 Schema 示例配置指南 - 说明 VS Code 插件提供的配置浏览和编辑功能 - 提供运行时接入模板和强类型查询辅助使用方法 - 说明跨表引用和运行时校验行为规范 - 介绍开发期热重载功能和性能优化建议 - 说明当前限制和独立 Config Studio 评估结论
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🧰 Additional context used📓 Path-based instructions (6)**/*.cs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.Tests/**/*.cs📄 CodeRabbit inference engine (AGENTS.md)
Files:
docs/**/*📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{README.md,docs/**}📄 CodeRabbit inference engine (AGENTS.md)
Files:
docs/**/*.md📄 CodeRabbit inference engine (AGENTS.md)
Files:
docs/zh-CN/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (11)📓 Common learnings📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T12:45:43.921ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
📚 Learning: 2026-04-06T10:00:34.101ZApplied to files:
🪛 LanguageTooldocs/zh-CN/game/config-system.md[uncategorized] ~709-~709: 数词与名词之间一般应存在量词,可能缺少量词。 (wa5) [uncategorized] ~709-~709: 您的意思是“"不"进”? (BU) 🔇 Additional comments (16)
📝 WalkthroughWalkthrough为配置系统在运行时与工具链中新增对 JSON Schema 关键字 Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(220,220,235,0.5)
participant User as 用户
participant Loader as YAML 加载器
participant Schema as Schema 解析器
participant Validator as 验证器
participant Reporter as 错误报告
end
User->>Loader: 提交 YAML 配置文件
Loader->>Schema: 解析 schema 元数据(含 multipleOf/uniqueItems/pattern)
Schema->>Validator: 传入节点与约束
Validator->>Validator: 标量验证(pattern, multipleOf 精确/容差路径)
Validator->>Validator: 数组项验证 -> 若项无错则构建归一化可比较键
Validator->>Validator: uniqueItems 检测(发现重复 -> 记录首个与当前索引)
alt multipleOf 违例
Validator->>Reporter: 生成 multipleOf ConstraintViolation (路径/原始值)
Reporter->>User: 返回验证错误
end
alt uniqueItems 违例
Validator->>Reporter: 生成 uniqueItems ConstraintViolation (当前/先前索引)
Reporter->>User: 返回验证错误
end
alt 验证通过
Validator->>Reporter: 返回加载并注册的配置表
Reporter->>User: 加载成功
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR extends the shared configuration schema subset in GFramework's config system to include Key changes:
Confidence Score: 5/5This PR is safe to merge — both previously flagged issues are resolved and no new bugs were found. Both prior review concerns are addressed: the C# tolerance formula now matches JS by using Math.Max(1d, Math.Abs(quotient)), and the JS uniqueItems loop uses continue rather than break to accumulate all duplicates. The BigInteger exact-decimal path correctly handles the zero edge case. Test coverage is thorough across violation, pass, scientific notation, large-decimal precision, and key-collision scenarios. No security issues or data-loss risks identified. No files require special attention.
|
| Filename | Overview |
|---|---|
| GFramework.Game/Config/YamlConfigSchemaValidator.cs | Adds multipleOf (BigInteger exact + quotient-tolerance fallback) and uniqueItems (length-prefixed comparable key + throw-on-first-duplicate) runtime validation. Zero-value edge case in TryParseExactDecimal is correctly guarded. Tolerance formula now matches JS implementation. |
| tools/gframework-config-tool/src/configValidation.js | Adds multipleOf (exact BigInt decimal path + quotient-tolerance fallback) and uniqueItems (accumulates all duplicates via continue) validation. Both exact decimal paths and the tolerance formula are aligned with the C# runtime. |
| GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs | Emits multipleOf and uniqueItems constraints into XML doc remarks for generated config properties; multipleOf only added when value > 0, consistent with schema validation rules. |
| GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs | Adds comprehensive runtime tests for multipleOf violation, large decimal exact step, large non-multiple rejection, uniqueItems violation, and comparable-key collision resistance for nested objects. |
| tools/gframework-config-tool/test/configValidation.test.js | Adds tests for multipleOf and uniqueItems parsing and validation, including multi-duplicate accumulation and comparable-key collision resistance for objects with separator characters. |
| tools/gframework-config-tool/src/extension.js | Adds multipleOf and uniqueItems hint rendering in the form preview panel for both scalar fields and array item fields. |
| tools/gframework-config-tool/src/localization.js | Adds localized strings for multipleOfViolation, uniqueItemsViolation, webview.hint.multipleOf, webview.hint.uniqueItems, and webview.hint.itemMultipleOf in both English and Simplified Chinese. |
| docs/zh-CN/game/config-system.md | Updates documentation to include multipleOf and uniqueItems in the supported schema subset list and error detection list, with a working schema example. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[YAML Config File] --> B[YamlConfigSchemaValidator]
S[JSON Schema File] --> B
B --> C{Array Node?}
C -- Yes --> D[ValidateArrayConstraints minItems / maxItems]
D --> E[ValidateNode per item]
E --> F[ValidateArrayUniqueItemsConstraint BuildComparableNodeValue per item]
C -- No --> G{Scalar Node?}
G -- Yes --> H[ValidateScalarConstraints]
H --> I{multipleOf?}
I -- Yes --> J[TryIsExactDecimalMultiple BigInteger exact path]
J -- fails --> K[Quotient tolerance path 1e-9 x max1 quotient]
J -- succeeds --> L[Return exact result]
F --> M{Duplicate found?}
M -- Yes --> N[throw ConstraintViolation]
M -- No --> O[Add to seenItems map]
Reviews (5): Last reviewed commit: "docs(config): 添加游戏内容配置系统文档和验证工具" | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
tools/gframework-config-tool/test/configValidation.test.js (1)
422-446: 建议再补一条items.multipleOf的运行时校验断言。当前这段只覆盖了 metadata 解析;建议再加
validateParsedConfig的失败用例,避免元素级步进约束回归时漏检。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/gframework-config-tool/test/configValidation.test.js` around lines 422 - 446, Add a runtime validation negative test that ensures the parsed schema's items.multipleOf constraint is enforced by validateParsedConfig: after using parseSchemaContent (parseSchemaContent) to produce schema with properties.dropRates.items.multipleOf = 0.5, call validateParsedConfig with a config containing a dropRates array containing a value that violates the 0.5 step (e.g., 0.3) and assert that validateParsedConfig throws or returns an error; this complements the existing metadata assertions (schema.properties.hp.multipleOf, schema.properties.dropRates.uniqueItems, schema.properties.dropRates.items.multipleOf) by verifying the runtime enforcement path (validateParsedConfig).tools/gframework-config-tool/src/extension.js (1)
1617-1619: 建议把multipleOfhint 条件收紧为“有限且大于 0”。现在只判断
number,会让无效值也进入 UI hint;建议与其他层统一约束语义。♻️ 建议修改
- if (!isArrayField && typeof propertySchema.multipleOf === "number") { + if (!isArrayField && + Number.isFinite(propertySchema.multipleOf) && + propertySchema.multipleOf > 0) { hints.push(escapeHtml(localizer.t("webview.hint.multipleOf", {value: propertySchema.multipleOf}))); } @@ - if (isArrayField && propertySchema.items && typeof propertySchema.items.multipleOf === "number") { + if (isArrayField && + propertySchema.items && + Number.isFinite(propertySchema.items.multipleOf) && + propertySchema.items.multipleOf > 0) { hints.push(escapeHtml(localizer.t("webview.hint.itemMultipleOf", {value: propertySchema.items.multipleOf}))); }Also applies to: 1661-1663
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/gframework-config-tool/src/extension.js` around lines 1617 - 1619, The current check that pushes the multipleOf hint uses only typeof propertySchema.multipleOf === "number", which allows NaN/Infinity/<=0; update the condition around the hints.push call (the block using isArrayField and propertySchema.multipleOf) to require Number.isFinite(propertySchema.multipleOf) && propertySchema.multipleOf > 0 before calling hints.push(escapeHtml(localizer.t(...))); apply the same tightened condition to the duplicate block that also handles multipleOf at the other occurrence referenced (lines ~1661-1663).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/zh-CN/game/config-system.md`:
- Line 810: The doc currently overclaims that `multipleOf / uniqueItems` are
shown in both 表单入口 and 批量编辑入口; update the sentence that lists `title /
description / default / enum / ref-table / multipleOf / uniqueItems` to restrict
`multipleOf` and `uniqueItems` to only the 表单入口 (or explicitly state what subset
is shown in 批量编辑入口), replacing the ambiguous "表单和批量编辑入口中显示" phrasing with a
clear statement that the form entry shows all listed metadata while the
batch-edit entry shows only the specific fields you want to support.
---
Nitpick comments:
In `@tools/gframework-config-tool/src/extension.js`:
- Around line 1617-1619: The current check that pushes the multipleOf hint uses
only typeof propertySchema.multipleOf === "number", which allows
NaN/Infinity/<=0; update the condition around the hints.push call (the block
using isArrayField and propertySchema.multipleOf) to require
Number.isFinite(propertySchema.multipleOf) && propertySchema.multipleOf > 0
before calling hints.push(escapeHtml(localizer.t(...))); apply the same
tightened condition to the duplicate block that also handles multipleOf at the
other occurrence referenced (lines ~1661-1663).
In `@tools/gframework-config-tool/test/configValidation.test.js`:
- Around line 422-446: Add a runtime validation negative test that ensures the
parsed schema's items.multipleOf constraint is enforced by validateParsedConfig:
after using parseSchemaContent (parseSchemaContent) to produce schema with
properties.dropRates.items.multipleOf = 0.5, call validateParsedConfig with a
config containing a dropRates array containing a value that violates the 0.5
step (e.g., 0.3) and assert that validateParsedConfig throws or returns an
error; this complements the existing metadata assertions
(schema.properties.hp.multipleOf, schema.properties.dropRates.uniqueItems,
schema.properties.dropRates.items.multipleOf) by verifying the runtime
enforcement path (validateParsedConfig).
🪄 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: 07ec0ab1-1554-48cd-80a6-4de288a7de19
📒 Files selected for processing (11)
GFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.csGFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txtGFramework.SourceGenerators/Config/SchemaConfigGenerator.csdocs/zh-CN/game/config-system.mdtools/gframework-config-tool/src/configValidation.jstools/gframework-config-tool/src/extension.jstools/gframework-config-tool/src/localization.jstools/gframework-config-tool/src/localizationKeys.jstools/gframework-config-tool/test/configValidation.test.js
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. 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 (6)
**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute
**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with<summary>,<param>,<returns>,<exception>, and<remarks>where applicable in C# code
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 comments
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions
Avoid obvious comments such as// increment iin C# code
Generated logic and source 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 in C# code
Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Missing required documentation is a coding standards violation in C# code
Do not rely on implicit imports in C# code; declare every requiredusingexplicitly
Write null-safe C# code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase ...
Files:
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.csGFramework.SourceGenerators/Config/SchemaConfigGenerator.csGFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
**/*SourceGenerators.Tests/**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*SourceGenerators.Tests/**/*.cs: Source generator changes MUST be covered by generator tests
Preserve snapshot-based verification patterns already used in the repository for source generator tests
Files:
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
**/*SourceGenerators/**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*SourceGenerators/**/*.cs: When source generator behavior changes intentionally, update snapshots together with the implementation
Keep source generators deterministic and free of hidden environment or network dependencies
Files:
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
docs/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Documentation must be located in docs/ directory with Chinese content in docs/zh-CN/
Files:
docs/zh-CN/game/config-system.md
{README.md,docs/**/*.md,docs/zh-CN/**/*.md}
📄 CodeRabbit inference engine (AGENTS.md)
{README.md,docs/**/*.md,docs/zh-CN/**/*.md}: Update the relevantREADME.mdordocs/page when behavior, setup steps, architecture guidance, or user-facing examples change
Keep code samples, package names, and command examples in documentation aligned with the current repository state
Prefer documenting behavior and design intent in documentation, not only API surface
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
Files:
docs/zh-CN/game/config-system.md
docs/zh-CN/**/*.md
📄 CodeRabbit inference engine (AGENTS.md)
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
Files:
docs/zh-CN/game/config-system.md
🧠 Learnings (11)
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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/SchemaConfigGeneratorSnapshotTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*SourceGenerators.Tests/**/*.cs : Source generator changes MUST be covered by generator tests
Applied to files:
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.csGFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*SourceGenerators/**/*.cs : When source generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txtGFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.csGFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : 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/SchemaConfigGeneratorSnapshotTests.csGFramework.Game.Tests/Config/YamlConfigLoaderTests.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.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.csGFramework.SourceGenerators/Config/SchemaConfigGenerator.csGFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs in C#
Applied to files:
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Generated logic and source generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to docs/zh-CN/**/*.md : 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:
docs/zh-CN/game/config-system.md
🪛 LanguageTool
docs/zh-CN/game/config-system.md
[uncategorized] ~709-~709: 您的意思是“"不"进”?
Context: ...和生成代码 XML 文档复用;当前按运行时与 JS 共用的浮点容差策略判断十进制步进 - minLength / maxLength:供运行时校验、VS ...
(BU)
🔇 Additional comments (8)
tools/gframework-config-tool/src/localizationKeys.js (1)
13-18: 新增校验键与调用侧保持一致,没问题。这两个 key 与校验分支和本地化字典的新增项对齐,风险低。
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs (1)
95-103: 测试样例补充了新约束分支,方向正确。把
multipleOf/uniqueItems放进 schema 样本能有效驱动快照验证。GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt (1)
37-48: 快照内容与新约束文档输出一致。
Hp与DropItems的约束文本更新准确,能覆盖本次生成器改动。tools/gframework-config-tool/src/localization.js (1)
112-123: 本地化补充完整且中英文对齐。新增提示文案与诊断文案都已覆盖,参数占位符也匹配调用侧。
Also applies to: 138-142, 216-227, 242-246
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs (1)
9-10: 约束文档生成逻辑更新合理,和快照结果一致。
multipleOf与uniqueItems的输出条件明确,生成侧行为可预期。Also applies to: 2435-2435, 2468-2473, 2506-2511
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs (1)
513-559: 新增回归测试覆盖点完整。这两组测试不仅验证了异常抛出,还把
FailureKind、DisplayPath、RawValue和注册表不变性一起锁住了,能比较稳地防住multipleOf/uniqueItems的回归。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.
Also applies to: 813-865
GFramework.Game/Config/YamlConfigSchemaValidator.cs (2)
928-960:multipleOf的解析、校验和诊断串起来了。这里把 schema 解析、容差比较和
ConstraintViolation诊断闭环补齐了,和现有运行时错误模型衔接得比较干净。Also applies to: 1317-1329, 1575-1589, 2003-2067
609-609:uniqueItems的运行时比较模型设计合理。去重检查放在元素递归校验之后,并且比较键显式规避了对象字段顺序与标量格式差异,这个方向和运行时一致性目标是对的。
Also applies to: 1438-1573, 2089-2121
- 新增游戏内容配置系统完整文档,涵盖 YAML 配置、JSON Schema 结构、目录组织等 - 添加 Schema 示例和 YAML 示例,说明怪物、物品等静态数据配置方式 - 提供推荐接入模板,包括目录结构、csproj 配置和启动代码模板 - 实现官方启动帮助器 GameConfigBootstrap 与 GameConfigModule 集成 - 添加运行时读取模板,提供强类型配置访问入口 - 实现生成查询辅助功能,支持 FindBy* 和 TryFindFirstBy* 查询接口 - 提供 Architecture 推荐接入模板,支持模块化配置管理 - 添加热重载模板,支持开发期配置文件自动刷新 - 实现运行时接入方案,提供只读表形式的配置访问 - 添加运行时校验行为说明,支持跨表引用和数据完整性检查 - 实现开发期热重载功能,支持配置变更自动重载 - 添加生成器接入约定,自动生成配置类型和表包装代码 - 提供 VS Code 工具支持,包括配置浏览、表单编辑和批量更新功能 - 实现配置验证工具,支持 JSON Schema 子集解析和 YAML 校验功能
- 定义了环境能力清单和工具选择规则 - 规定了XML文档注释、内联注释和架构级注释要求 - 明确了代码风格包括命名约定、格式化和C#惯例 - 设立了测试覆盖范围、组织结构和验证命令标准 - 制定了安全规则防止输入验证和敏感数据泄露 - 规范了代码文档、任务跟踪和仓库文档更新流程 - 建立了审查标准确保代码质量和完整性
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tools/gframework-config-tool/src/configValidation.js (1)
933-940: 对象属性排序使用localeCompare与 C# 端存在细微差异。C# 实现使用
string.CompareOrdinal进行排序(见YamlConfigSchemaValidator.cs:1676),而此处使用localeCompare。对于 ASCII 字符集的属性名,两者行为一致;但对于包含非 ASCII 字符或特殊 Unicode 字符的属性名,排序结果可能不同,从而导致生成的比较键不同。鉴于 JSON Schema 属性名通常为 ASCII 标识符,此差异在实际使用中不太可能造成问题。
♻️ 可选:改用字节序比较以完全对齐 C# 行为
return Object.keys(schemaNode.properties) .filter((key) => yamlNode.map.has(key)) - .sort((left, right) => left.localeCompare(right)) + .sort((left, right) => { + if (left < right) return -1; + if (left > right) return 1; + return 0; + }) .map((key) => {🤖 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 933 - 940, The sorting currently uses localeCompare which can differ from C#'s string.CompareOrdinal; change the comparator inside the block that builds the comparison key (the Object.keys(...).sort(...) chain) to use a code-unit (ordinal) comparison instead of localeCompare — e.g., replace .sort((left, right) => left.localeCompare(right)) with a comparator that returns left === right ? 0 : left < right ? -1 : 1 so the ordering matches C#'s ordinal behavior when building the string in buildComparableNodeValue/map handling.GFramework.Game/Config/YamlConfigSchemaValidator.cs (1)
423-429: 把references的可空约定补进这些递归方法的 XML 注释。这里的签名已经允许
references为null,但<param name="references">仍然像是在描述一个始终存在的“已收集引用”集合,和ValidateCore(...)的契约不一致。后续维护时很容易把它误当成非空参数。As per coding guidelines "XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax".
Also applies to: 469-475, 565-571, 623-629
🤖 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 423 - 429, Update the XML doc comments for the recursive validation methods so the <param name="references"> clearly states that the references argument is nullable: when null the method will not collect/populate references, callers must not assume a non-null collection, and behavior matches the contract of ValidateCore(...); apply this change to ValidateNode and the other recursive validation overloads that accept ICollection<YamlConfigReferenceUsage>? references so the documentation explains intent, usage constraints, and nullability rather than restating the signature.
🤖 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/Config/YamlConfigSchemaValidator.cs`:
- Around line 1754-1759: IsMultipleOf currently scales tolerance by the
magnitude of the quotient which lets very large values pass; change it to scale
by the divisor (step) or the remainder scale instead. In IsMultipleOf(double
value, double divisor) compute the nearest integer multiple (e.g., quotient and
nearestInteger as you already do), then compute the remainder as value -
nearestInteger * divisor and set tolerance = 1e-9 * Math.Max(1d,
Math.Abs(divisor)); finally return Math.Abs(remainder) <= tolerance (or also
accept Math.Abs(remainder - divisor) <= tolerance to handle sign), so the
tolerance is tied to the step size rather than the quotient magnitude.
---
Nitpick comments:
In `@GFramework.Game/Config/YamlConfigSchemaValidator.cs`:
- Around line 423-429: Update the XML doc comments for the recursive validation
methods so the <param name="references"> clearly states that the references
argument is nullable: when null the method will not collect/populate references,
callers must not assume a non-null collection, and behavior matches the contract
of ValidateCore(...); apply this change to ValidateNode and the other recursive
validation overloads that accept ICollection<YamlConfigReferenceUsage>?
references so the documentation explains intent, usage constraints, and
nullability rather than restating the signature.
In `@tools/gframework-config-tool/src/configValidation.js`:
- Around line 933-940: The sorting currently uses localeCompare which can differ
from C#'s string.CompareOrdinal; change the comparator inside the block that
builds the comparison key (the Object.keys(...).sort(...) chain) to use a
code-unit (ordinal) comparison instead of localeCompare — e.g., replace
.sort((left, right) => left.localeCompare(right)) with a comparator that returns
left === right ? 0 : left < right ? -1 : 1 so the ordering matches C#'s ordinal
behavior when building the string in buildComparableNodeValue/map handling.
🪄 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: 2ce219b7-43d0-47c2-8ddd-1d78fa60d482
📒 Files selected for processing (6)
AGENTS.mdGFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.csdocs/zh-CN/game/config-system.mdtools/gframework-config-tool/src/configValidation.jstools/gframework-config-tool/test/configValidation.test.js
✅ Files skipped from review due to trivial changes (1)
- AGENTS.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. 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 (5)
**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attributeAll public, protected, and internal types and members MUST include XML documentation comments (
///) with<summary>,<param>,<returns>,<exception>, and<remarks>where applicableXML 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/compatibility constraints, and registration/lifecycle sequencing
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Do not rely on implicit imports; declare every required
usingexplicitlyWrite null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern
GFramework.{Module}.{Feature}with PascalCase segmentsUse PascalCase for types, methods, properties, events, and constants in C#
Use
Iprefix for interface names in C#Use camelCase for parameters and locals in C#
Use
_camelCasefor private fields in C#Use 4 spaces for indentation in C# code; do not use tabs
Use Allman braces in C# code
Keep
usingdirectives at the top of the file and sort them consistently in C#Separate logical b...
Files:
GFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
docs/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Documentation must be located in docs/ directory with Chinese content in docs/zh-CN/
Files:
docs/zh-CN/game/config-system.md
{README.md,docs/**/*.md,docs/zh-CN/**/*.md}
📄 CodeRabbit inference engine (AGENTS.md)
Update the relevant
README.mdordocs/page when behavior, setup steps, architecture guidance, or user-facing examples changeKeep 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
Files:
docs/zh-CN/game/config-system.md
docs/zh-CN/**/*.md
📄 CodeRabbit inference engine (AGENTS.md)
When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create corresponding user-facing integration documentation in
docs/zh-CN/
Files:
docs/zh-CN/game/config-system.md
{docs/**/*.md,docs/zh-CN/**/*.md}
📄 CodeRabbit inference engine (AGENTS.md)
For integration-oriented features, documentation MUST cover: project directory layout and file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes
Do not rely on 'the code is self-explanatory' for framework features that consumers need to adopt; write the adoption path down
Files:
docs/zh-CN/game/config-system.md
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Read `@.ai/environment/tools.ai.yaml` before choosing runtimes or CLI tools
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Prefer Windows Git from WSL (for example `git.exe`) instead of the Linux `git` binary when working in WSL against this repository's Windows-backed worktree
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, component interactions, abstraction rationale, and usage alternatives
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Keep abstractions projects free of implementation details and engine-specific dependencies
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Preserve existing module boundaries; do not introduce new cross-module dependencies without clear architectural need
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Treat Meziantou.Analyzer feedback as part of the coding standard
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Treat SonarQube maintainability rules (especially cognitive complexity and oversized parameter list findings) as part of the coding standard
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Naming must remain compatible with `scripts/validate-csharp-naming.sh`
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Public API changes must be covered by unit or integration tests
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Mirror the source structure in test projects whenever practical
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under `local-plan/todos/` in the same change
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:24:14.769Z
Learning: Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : 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/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia
Applied to files:
GFramework.Game.Tests/Config/YamlConfigLoaderTests.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/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to docs/zh-CN/**/*.md : 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:
docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to {README.md,docs/**/*.md,docs/zh-CN/**/*.md} : Prefer documenting behavior and design intent in documentation, not only API surface
Applied to files:
docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to {README.md,docs/**/*.md,docs/zh-CN/**/*.md} : 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
🪛 LanguageTool
docs/zh-CN/game/config-system.md
[uncategorized] ~709-~709: 您的意思是“"不"进”?
Context: ...和生成代码 XML 文档复用;当前按运行时与 JS 共用的浮点容差策略判断十进制步进 - minLength / maxLength:供运行时校验、VS ...
(BU)
🔇 Additional comments (10)
docs/zh-CN/game/config-system.md (1)
709-714: 文档描述与实现一致,静态分析为误报。"步进"在此处是正确的技术术语,用于描述
multipleOf的数值步进校验行为。该词汇与YamlConfigSchemaValidator.cs中IsMultipleOf方法的实现(使用浮点容差判断商是否为整数)相符。关于
uniqueItems使用"schema 归一化后的结构比较"的描述,也与 context snippet 3-4 中BuildComparableObjectValue的字段排序和长度前缀编码实现一致。tools/gframework-config-tool/test/configValidation.test.js (3)
311-350: 测试覆盖全面,LGTM。新增的测试用例覆盖了关键场景:
multipleOf约束违规检测(hp: 12不满足multipleOf: 5)uniqueItems去重检测,且验证了对象字段顺序不影响重复判定(wave: 1, monsterId: slime与monsterId: slime, wave: 1被正确识别为重复项)
389-418: 元素校验失败时跳过 uniqueItems 检查的逻辑已正确实现。此测试确保当数组元素本身存在类型错误(如
integer[]中放入对象)时,不会额外产生误导性的uniqueItemsViolation诊断。这与之前的 review 反馈一致。
450-479: 可比较键碰撞回归测试覆盖了边界情况。测试用例
{ a: "x|1:b=string:yz" }与{ a: "x", b: "yz" }验证了长度前缀编码能够正确区分这两个不同的对象,避免误报重复。这与 C# 端BuildComparableObjectValue的实现保持一致。GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs (3)
513-559: multipleOf 约束测试覆盖完整,LGTM。测试验证了:
hp: 12不满足multipleOf: 5时抛出ConfigLoadException- 诊断信息包含正确的
FailureKind.ConstraintViolation、DisplayPath: hp和RawValue: 12- 注册表保持为空,未出现部分加载
854-906: uniqueItems 约束测试验证了关键行为。测试确认:
- 重复元素
dropRates: [5, 10, 5]被正确拒绝DisplayPath指向第二个重复项dropRates[2]- 错误消息包含
"unique array items"关键词
908-968: 可比较键归一化回归测试与 JS 端保持一致。此测试用例验证了包含分隔符字符的字符串值(如
"x|1:b=string:yz")不会与结构不同的对象({ a: "x", b: "yz" })产生键碰撞。这确保了运行时与工具端的uniqueItems行为一致。tools/gframework-config-tool/src/configValidation.js (3)
9-11: 正则表达式常量抽取提升了可维护性。将
IntegerScalarPattern、NumberScalarPattern、BooleanScalarPattern提取为模块级常量,避免了每次调用isScalarCompatible和formatYamlScalar时重复创建正则对象。NumberScalarPattern正确支持科学计数法格式。
683-717: uniqueItems 校验逻辑已正确实现跳过无效元素的行为。通过在子项校验后检查
diagnostics.length是否变化(lines 685-697),只有校验通过的元素才会参与去重比较。这避免了类型错误的元素被压成同一个比较键后误报uniqueItemsViolation。此实现与之前的 review 反馈一致。
484-494: multipleOf 校验使用与运行时一致的浮点容差策略。容差公式
1e-9 * Math.max(1, Math.abs(quotient))与YamlConfigSchemaValidator.cs:1757-1760中的 C# 实现完全一致,确保了工具端与运行时对边界情况的判定行为相同。
- 定义了环境能力清单和工具选择规则 - 规定了XML文档注释、内联注释和架构级注释要求 - 明确了代码风格包括命名规范、格式化和C#约定 - 设立了测试覆盖范围、组织结构和验证命令标准 - 制定了安全输入验证、依赖管理和权限控制规则 - 确立了文档更新、任务跟踪和审查完成标准 - 更新了浮点数比较算法中的容差计算方式 - 优化了数值精度验证逻辑以避免十进制步进误差
There was a problem hiding this comment.
🧹 Nitpick comments (3)
AGENTS.md (1)
125-133: 详细且可操作的复杂度治理指导新增的 SonarQube 可维护性规则建立了清晰的重构策略:
- 按语义阶段(解析、规范化、验证、诊断)提取方法来降低认知复杂度
- 针对参数数量问题选择合适的重构方式(值对象、参数对象、命名工厂)
- 严格限制抑制告警,除非有外部约束并记录原因
这些指导具体且实用,适合高质量框架项目的标准。
📋 可选建议:补充 SonarQube 工具使用说明
文档在"Validation Commands"部分(第 164 行起)中可以考虑补充如何在本地检查 SonarQube 合规性的说明,或明确说明 SonarQube 在 CI 中运行,开发者应关注 CI 反馈。这样可以让贡献者更清楚如何验证是否符合新增的可维护性标准。
例如:
# Check SonarQube maintainability rules (if configured locally) # Note: SonarQube analysis runs in CI; review CI feedback for compliance🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@AGENTS.md` around lines 125 - 133, Summary: The PR adds detailed, actionable SonarQube maintainability guidance but also suggests optionally documenting how to locally verify those rules; update the doc accordingly. Edit the "SonarQube maintainability rules" section to explicitly list the recommended refactor strategies (extract helpers by semantic phase: parsing/normalization/validation/diagnostics; prefer domain value objects or parameter objects for long parameter lists; use named factory methods for different creation modes; avoid suppressions unless externally required and documented) and make the language prescriptive and concise; additionally, under the "Validation Commands" heading add a short note showing how to check SonarQube maintainability rules locally (or state that analysis runs in CI and developers should review CI results) so contributors know how to validate compliance.GFramework.Game/Config/YamlConfigSchemaValidator.cs (2)
1307-1325: 建议为正则表达式添加超时保护。当前
Regex创建未设置MatchTimeout,若 schema 中包含恶意或复杂正则模式,可能导致 ReDoS。虽然 schema 文件通常可信,但添加超时是更安全的防御性做法。♻️ 可选:添加正则超时
private static YamlConfigStringConstraints? CreateStringScalarConstraints( int? minLength, int? maxLength, string? pattern) { return !minLength.HasValue && !maxLength.HasValue && pattern is null ? null : new YamlConfigStringConstraints( minLength, maxLength, pattern, pattern is null ? null : new Regex( pattern, - SupportedPatternRegexOptions)); + SupportedPatternRegexOptions, + TimeSpan.FromSeconds(1))); }🤖 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 1307 - 1325, The Regex constructed in CreateStringScalarConstraints lacks a match timeout, risking ReDoS for complex patterns; update CreateStringScalarConstraints to pass a sensible MatchTimeout when instantiating new Regex (use the Regex(TimeSpan) overload) and surface that timeout into the YamlConfigStringConstraints (or add a private constant like PatternMatchTimeout) so callers use the bounded Regex; update the Regex creation site in CreateStringScalarConstraints and the YamlConfigStringConstraints constructor/signature as needed to accept and store the timeout-protected Regex while keeping SupportedPatternRegexOptions unchanged.
1-13: 文件长度超出建议上限。当前文件约 2558 行,显著超出编码规范建议的 800-1000 行上限。考虑将模型类(
YamlConfigSchema、YamlConfigSchemaNode、约束类等)拆分到独立文件如YamlConfigSchemaModels.cs,保持验证器逻辑的聚焦。As per coding guidelines: "Keep a single source file under roughly 800-1000 lines; if it grows beyond that range, stop and check whether responsibilities should be split before continuing."
🤖 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 1 - 13, The file YamlConfigSchemaValidator.cs is too large (~2558 lines); split model and constraint types out of it so the validator stays focused: move classes like YamlConfigSchema, YamlConfigSchemaNode and any constraint/model types into a new file (e.g., YamlConfigSchemaModels.cs) or multiple files, keep YamlConfigSchemaValidator as the logic-only class, preserve namespaces and internal accessibility, update using/imports and remove duplicate usings, and ensure all references in methods of YamlConfigSchemaValidator still point to the moved types and compile (run tests/build to verify).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@AGENTS.md`:
- Around line 125-133: Summary: The PR adds detailed, actionable SonarQube
maintainability guidance but also suggests optionally documenting how to locally
verify those rules; update the doc accordingly. Edit the "SonarQube
maintainability rules" section to explicitly list the recommended refactor
strategies (extract helpers by semantic phase:
parsing/normalization/validation/diagnostics; prefer domain value objects or
parameter objects for long parameter lists; use named factory methods for
different creation modes; avoid suppressions unless externally required and
documented) and make the language prescriptive and concise; additionally, under
the "Validation Commands" heading add a short note showing how to check
SonarQube maintainability rules locally (or state that analysis runs in CI and
developers should review CI results) so contributors know how to validate
compliance.
In `@GFramework.Game/Config/YamlConfigSchemaValidator.cs`:
- Around line 1307-1325: The Regex constructed in CreateStringScalarConstraints
lacks a match timeout, risking ReDoS for complex patterns; update
CreateStringScalarConstraints to pass a sensible MatchTimeout when instantiating
new Regex (use the Regex(TimeSpan) overload) and surface that timeout into the
YamlConfigStringConstraints (or add a private constant like PatternMatchTimeout)
so callers use the bounded Regex; update the Regex creation site in
CreateStringScalarConstraints and the YamlConfigStringConstraints
constructor/signature as needed to accept and store the timeout-protected Regex
while keeping SupportedPatternRegexOptions unchanged.
- Around line 1-13: The file YamlConfigSchemaValidator.cs is too large (~2558
lines); split model and constraint types out of it so the validator stays
focused: move classes like YamlConfigSchema, YamlConfigSchemaNode and any
constraint/model types into a new file (e.g., YamlConfigSchemaModels.cs) or
multiple files, keep YamlConfigSchemaValidator as the logic-only class, preserve
namespaces and internal accessibility, update using/imports and remove duplicate
usings, and ensure all references in methods of YamlConfigSchemaValidator still
point to the moved types and compile (run tests/build to verify).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4399994b-74b4-4340-8d55-eea9d94a3965
📒 Files selected for processing (2)
AGENTS.mdGFramework.Game/Config/YamlConfigSchemaValidator.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. 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 (CLAUDE.md)
**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attributeAll public, protected, and internal types and members MUST include XML documentation comments (
///) with<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicableAdd inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
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 include comments explaining what is generated, why it is generated, 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
Do not rely on implicit imports; declare every required
usingexplicitly, following the repository defaults ofImplicitUsingsdisabledWrite null-safe code that respects nullable annotations instead of suppressing warnings by default, following the repository default of
NullableenabledUse the namespace pattern
GFramework.{Module}.{Feature}with PascalCase segmentsFollow standard C# naming: types, methods, properties, events, and consta...
Files:
GFramework.Game/Config/YamlConfigSchemaValidator.cs
🧠 Learnings (25)
📓 Common learnings
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Before choosing runtimes or CLI tools, read `@.ai/environment/tools.ai.yaml` to verify tool availability before using them
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Prefer Windows Git from WSL (e.g., `git.exe`) instead of the Linux `git` binary when working in WSL against a Windows-backed worktree
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Public API changes must be covered by unit or integration tests
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: 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
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Regression fixes should include a test that fails before the fix and passes after it
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Mirror the source structure in test projects whenever practical
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Keep tests focused on observable behavior, not implementation trivia
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: When generator behavior changes intentionally, update snapshots together with the implementation
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Validate external or user-controlled input before it reaches file system, serialization, reflection, code generation, or process boundaries
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Do not build command strings, file paths, type names, or generated code from untrusted input without strict validation or allow-listing
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Avoid logging secrets, tokens, credentials, or machine-specific sensitive data
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Keep source generators deterministic and free of hidden environment or network dependencies
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Prefer least-privilege behavior for file, process, and environment access
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Do not introduce unsafe deserialization, broad reflection-based activation, or dynamic code execution unless it is explicitly required and tightly constrained
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Minimize new package dependencies; add them only when necessary and keep scope narrow
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Keep abstractions projects free of implementation details and engine-specific dependencies
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:44:13.350Z
Learning: Preserve existing module boundaries; do not introduce new cross-module dependencies without clear architectural need
📚 Learning: 2026-04-05T15:30:46.211Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Follow all coding rules defined in AGENTS.md
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to {README.md,docs/**/*.md,docs/zh-CN/**/*.md} : 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:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Use `@.ai/environment/tools.raw.yaml` only when needing full collected facts behind AI-facing hints
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Read `@.ai/environment/tools.ai.yaml` before choosing runtimes or CLI tools
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Prefer project-relevant tools listed in environment inventory instead of assuming every installed system tool is available
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Keep line length readable in C# code; around 120 characters is the preferred upper bound
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Keep `using` directives at the top of C# files and sort them consistently
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Separate logical blocks with blank lines in C# code when it improves readability
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Prefer one primary type per C# file unless the surrounding project already uses a different local pattern
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Prefer explicit, readable code over clever shorthand in C# framework internals
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Follow standard C# naming: Types, methods, properties, events, constants in PascalCase; interfaces with `I` prefix; parameters and locals in camelCase; private fields in `_camelCase`
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling in C# code
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Missing required documentation is a coding standards violation in C# code
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Do not rely on implicit imports in C# code; declare every required `using` explicitly
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : The repository uses `Meziantou.Analyzer`; treat analyzer feedback as part of the coding standard in C#
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : When adding analyzers or suppressions in C#, keep them minimal and justify them in code comments if the reason is not obvious
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Naming must remain compatible with `scripts/validate-csharp-naming.sh`
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : 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:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests
Applied to files:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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:
AGENTS.md
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Generated logic and source generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
AGENTS.md
📚 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/Config/YamlConfigSchemaValidator.cs
🔇 Additional comments (11)
AGENTS.md (2)
13-16: 实用的 WSL Git 配置指导这条新增的指导清晰地解决了 WSL 环境下使用 Windows 后端工作树的路径转换问题,提供了明确的回退策略。建议合理且可操作。
107-110: 合理的文件大小可维护性指导新增的 800-1000 行软性限制是合理的可维护性实践。措辞恰当地保持了灵活性("roughly"、"clear and documented reason"),同时明确将超大文件视为设计问题的信号,有助于保持代码库的可维护性。
GFramework.Game/Config/YamlConfigSchemaValidator.cs (9)
10-11: LGTM!类级别文档更新准确反映了新增的
multipleOf与uniqueItems约束支持。
132-154: 重构合理,避免重复解析。将
ValidateCore抽取为共享入口,Validate路径传null避免不必要的列表分配,ValidateAndCollectReferences按需收集引用。逻辑清晰,符合 DRY 原则。
919-952: LGTM!
TryParseMultipleOfConstraint正确校验multipleOf必须为正数,符合 JSON Schema 规范。复用TryParseNumericConstraint避免代码重复。
1099-1130: LGTM!
TryParseUniqueItemsConstraint正确解析布尔型uniqueItems约束,未声明时返回false作为默认值。
1575-1621: LGTM!
ValidateArrayUniqueItemsConstraint实现正确:
- 使用字典记录已见元素及其索引,O(n) 时间复杂度
- 错误信息同时报告重复项索引和先前出现的索引,便于定位问题
StringComparer.Ordinal确保一致的比较行为
1651-1681: 规范化键设计合理。
BuildComparableObjectValue按属性名排序忽略 YAML 字段顺序,使用长度前缀编码 ({keyLen}:{key}={valueLen}:{value}) 避免分隔符冲突。递归构建确保嵌套对象也能正确比较。
1746-1761: 先前评审问题已修复。
IsMultipleOf现在正确地将容差绑定到步进量级 (divisor) 而非商值 (quotient),并通过Math.Abs(value - (nearestInteger * divisor))比较实际余数。这避免了大数值误判为合法倍数的问题。
2074-2165: 重构改善了内聚性和参数数量。将
YamlConfigSchemaNode拆分为NodeChildren(结构信息)和NodeValidation(校验约束)两个嵌套类:
- 静态工厂方法 (
CreateObject/CreateArray/CreateScalar) 使创建意图更清晰- 私有构造函数强制使用工厂方法
None静态实例避免重复分配空状态- 符合 SonarQube 参数数量限制的编码规范
2316-2368: LGTM!
YamlConfigNumericConstraints将数值约束(区间与步进)从标量约束中独立出来,避免字符串字段暴露不相关成员,符合单一职责原则。
- 验证YAML文件扫描和注册表写入功能 - 测试带schema校验的配置表注册选项对象支持 - 验证空配置表注册选项的异常处理 - 测试配置目录不存在时的错误抛出 - 验证配置表加载失败时注册表状态回滚 - 测试非法YAML文件的反序列化错误处理 - 验证schema校验对必填字段缺失的检查 - 测试schema校验对类型不匹配的检查 - 验证schema校验对枚举值限制的支持 - 测试数值范围约束的校验功能 - 验证数值exclusive min/max约束 - 测试multipleOf约束校验 - 验证大数值和科学计数法支持 - 测试字符串长度和正则模式约束 - 验证数组元素数量和唯一性约束 - 测试未知字段检测和错误处理 - 验证嵌套对象和数组的递归校验 - 测试跨表引用校验功能
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
GFramework.Game/Config/YamlConfigSchemaValidator.cs (1)
1746-1760:⚠️ Potential issue | 🟠 Major
multipleOf的容差仍然按商值放大,会把明显非法的大数判成合法。这里的容差跟
|value / divisor|绑定,值越大,允许误差就越大。结果是multipleOf: 1这类最严格的步进,在大数量级下也会放过诸如1000000000000.4这样的非法值。容差应该绑定到“步进/余数”的尺度,而不是绑定到商值本身。🛠️ 可行修正
private static bool IsMultipleOf(double value, double divisor) { var quotient = value / divisor; var nearestInteger = Math.Round(quotient); - var tolerance = 1e-9 * Math.Max(1d, Math.Abs(quotient)); - return Math.Abs(quotient - nearestInteger) <= tolerance; + var remainder = value - (nearestInteger * divisor); + var tolerance = 1e-9 * Math.Max(1d, Math.Abs(divisor)); + return Math.Abs(remainder) <= tolerance; }🤖 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 1746 - 1760, IsMultipleOf currently scales tolerance with the quotient which allows large values to slip through; change it to measure remainder against a tolerance tied to the divisor (step) instead. In IsMultipleOf(double value, double divisor) compute the nearest integer as now, then compute remainder = Math.Abs(value - nearestInteger * divisor) and set tolerance = 1e-9 * Math.Max(1d, Math.Abs(divisor)) (so tolerance scales with step, not quotient), and return remainder <= tolerance; keep the same rounding logic to find nearestInteger so behavior for fractional steps remains consistent.
🤖 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/YamlConfigLoaderTests.cs`:
- Around line 513-644: Add a regression test named like
LoadAsync_Should_Reject_Large_Decimal_Number_When_Not_MultipleOf that mirrors
the other cases but uses a very large non-integer value (e.g. dropRate:
1000000000000.4) with a schema containing "multipleOf": 1; instantiate
YamlConfigLoader, RegisterTable<int, MonsterNumberConfigStub>("monster", ...
"schemas/monster.schema.json", ...), call loader.LoadAsync against a new
ConfigRegistry and Assert.ThrowsAsync<ConfigLoadException>, then verify
exception.Diagnostic.FailureKind == ConfigLoadFailureKind.ConstraintViolation,
Diagnostic.DisplayPath == "dropRate", Diagnostic.RawValue contains the large
value and registry.Count == 0 so this fails before the fix and passes after.
---
Duplicate comments:
In `@GFramework.Game/Config/YamlConfigSchemaValidator.cs`:
- Around line 1746-1760: IsMultipleOf currently scales tolerance with the
quotient which allows large values to slip through; change it to measure
remainder against a tolerance tied to the divisor (step) instead. In
IsMultipleOf(double value, double divisor) compute the nearest integer as now,
then compute remainder = Math.Abs(value - nearestInteger * divisor) and set
tolerance = 1e-9 * Math.Max(1d, Math.Abs(divisor)) (so tolerance scales with
step, not quotient), and return remainder <= tolerance; keep the same rounding
logic to find nearestInteger so behavior for fractional steps remains
consistent.
🪄 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: edfc6bd9-a8e3-4581-8783-ea8e292e7198
📒 Files selected for processing (2)
GFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. 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 (2)
**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attributeAll public, protected, and internal types and members MUST include XML documentation comments (
///) with<summary>,<param>,<returns>,<exception>, and<remarks>where applicableAdd inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, and registration order/lifecycle sequencing
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, why the abstraction exists, and when to use it
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Declare every required
usingexplicitly; do not rely on implicit importsWrite null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern
GFramework.{Module}.{Feature}with PascalCase segmentsFollow C# naming conventions: Types/methods/properties/events/constants in PascalCase, interfaces with
Iprefix, parameters/locals in camelCase, private fields in_camelCaseUse 4 spaces for indentation, not tabs, and use Allman braces
Keep
usingdirectives at the top of the file and sort them consistentlyPrefer one primary type per file unless the surrounding project already uses a different local pattern
Keep a single source file under roughly 800-1000 lines; if a file grows ...
Files:
GFramework.Game.Tests/Config/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
**/*.Tests/**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
Reuse existing architecture test infrastructure when relevant: ArchitectureTestsBase, SyncTestArchitecture, AsyncTestArchitecture
Files:
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Keep abstractions projects free of implementation details and engine-specific dependencies
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Preserve existing module boundaries; do not introduce new cross-module dependencies without clear architectural need
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Public API changes must be covered by unit or integration tests
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: When a public API defines multiple contract branches, tests MUST cover meaningful variants including null, empty, default, and filtered inputs when those branches change behavior
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Regression fixes should include a test that fails before the fix and passes after it
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Mirror the source structure in test projects whenever practical
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Keep tests focused on observable behavior, not implementation trivia
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Validate external or user-controlled input before it reaches file system, serialization, reflection, code generation, or process boundaries
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Do not build command strings, file paths, type names, or generated code from untrusted input without strict validation or allow-listing
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Avoid logging secrets, tokens, credentials, or machine-specific sensitive data
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Prefer least-privilege behavior for file, process, and environment access
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Do not introduce unsafe deserialization, broad reflection-based activation, or dynamic code execution unless it is explicitly required and tightly constrained
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Minimize new package dependencies and add them only when necessary with narrow scope
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under `local-plan/todos/` in the same change
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Do not rely on 'the code is self-explanatory' for framework features that consumers need to adopt; write the adoption path down
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: Before choosing runtimes or CLI tools, read `@.ai/environment/tools.ai.yaml` and prefer project-relevant tools listed there
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: When working in WSL against this repository's Windows-backed worktree, prefer Windows Git from WSL (e.g., `git.exe`) instead of the Linux `git` binary
Learnt from: CR
URL:
File: AGENTS.md:undefined-undefined
Timestamp: 2026-04-09T11:59:42.535Z
Learning: If a Git command in WSL fails with a worktree-style 'not a git repository' path translation error, rerun it with the Windows Git executable
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : 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/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.Game.Tests/Config/YamlConfigLoaderTests.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/YamlConfigLoaderTests.csGFramework.Game/Config/YamlConfigSchemaValidator.cs
- 新增游戏内容配置系统完整文档,涵盖 YAML 配置、JSON Schema 结构、目录组织等 - 实现运行时只读查询、Source Generator 类型生成、VS Code 插件等功能 - 提供配置浏览、raw 编辑、schema 打开、递归校验和嵌套对象表单入口 - 添加配置系统接入模板,包括 csproj 模板、启动帮助器、运行时读取模板 - 实现热重载功能支持开发期配置文件自动刷新 - 提供完整的 schema 示例和 YAML 示例配置 - 添加跨表引用、索引查询辅助、批量编辑等高级功能支持 - 实现配置验证工具,支持类型校验、约束检查、注释提取等特性
Summary by CodeRabbit
新功能
文档
测试