Skip to content

docs(config): 添加游戏内容配置系统文档与验证工具#206

Merged
GeWuYou merged 4 commits into
mainfrom
docs/config-system
Apr 10, 2026
Merged

docs(config): 添加游戏内容配置系统文档与验证工具#206
GeWuYou merged 4 commits into
mainfrom
docs/config-system

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 10, 2026

Copy link
Copy Markdown
Owner
  • 新增游戏内容配置系统完整文档,包含 YAML 配置、JSON Schema 结构描述
  • 添加运行时只读查询、Source Generator 类型生成等功能说明
  • 提供推荐目录结构、Schema 示例和 YAML 示例配置模板
  • 添加 VS Code 插件工具支持配置浏览、校验和表单编辑功能
  • 实现跨表引用校验、热重载及批量编辑等高级特性文档
  • 集成 Architecture 模块化接入和运行时校验行为说明
  • 添加配置系统限制说明与独立工具评估结论

Summary by Sourcery

扩展共享配置验证和工具链,在运行时、VS Code 插件、源代码生成器以及文档中支持 JSON Schema 对象属性数量约束。

New Features:

  • 在运行时 YAML 配置验证器中,为对象节点支持 JSON Schema 的 minPropertiesmaxProperties 约束。
  • 在 VS Code 配置工具的验证、诊断以及表单提示中,展示对象层级的 minPropertiesmaxProperties 元数据。
  • 通过源代码生成器,在生成的配置类型 XML 文档中包含对象属性数量约束说明。

Enhancements:

  • 为 schema 中无效或不一致的对象属性数量声明,增加运行时和工具链的错误处理。
  • 将 schema 元数据传递到表单渲染阶段,使对象字段在描述旁边显示约束提示。

Documentation:

  • 更新中文配置系统文档,说明对 minPropertiesmaxProperties 约束的统一支持,以及它们在运行时、工具链和生成器中的行为。

Tests:

  • 为 YAML 加载过程中对象违反 minPropertiesmaxProperties 的情况添加运行时测试。
  • 扩展 VS Code 配置工具测试,用于覆盖对象属性数量约束的解析与验证以及相关诊断。
  • 更新源代码生成器的快照测试,以覆盖对带有 minPropertiesmaxProperties 对象的约束文档输出。
Original summary in English

Summary by Sourcery

Extend the shared config validation and tooling to support JSON Schema object property count constraints across runtime, VS Code plugin, source generator, and documentation.

New Features:

  • Support JSON Schema minProperties and maxProperties constraints for object nodes in the runtime YAML config validator.
  • Surface object-level minProperties and maxProperties metadata in the VS Code config tool validation, diagnostics, and form hints.
  • Include object property count constraints in generated config type XML documentation via the source generator.

Enhancements:

  • Add runtime and tooling error handling for invalid or inconsistent object property count declarations in schemas.
  • Propagate schema metadata into form rendering so object fields display constraint hints alongside descriptions.

Documentation:

  • Update Chinese config system documentation to describe shared support for minProperties and maxProperties constraints and their behavior in runtime, tooling, and generators.

Tests:

  • Add runtime tests for object minProperties and maxProperties violations during YAML loading.
  • Extend VS Code config tool tests to cover parsing and validation of object property-count constraints and related diagnostics.
  • Update source generator snapshot tests to cover emitted constraint documentation for objects with minProperties and maxProperties.

Summary by CodeRabbit

  • 新功能

    • 配置系统、代码生成器与配置工具现支持对象属性数量约束(minProperties / maxProperties),运行时校验、表单提示与生成文档均反映该约束。
  • 更改

    • 生成器对 required 字段名改为区分大小写,影响生成属性命名。
    • 生成器在类型文档中添加约束备注(Remarks)。
    • 表单提示与本地化新增 minProperties/maxProperties 文本与校验消息。
  • 文档

    • 更新说明与 VS Code 表单元数据,列出 minProperties/maxProperties 支持范围。
  • 测试

    • 新增和扩展单元测试与快照,覆盖约束解析、运行时校验、错误定位与本地化输出。

- 新增游戏内容配置系统完整文档,包含 YAML 配置、JSON Schema 结构描述
- 添加运行时只读查询、Source Generator 类型生成等功能说明
- 提供推荐目录结构、Schema 示例和 YAML 示例配置模板
- 添加 VS Code 插件工具支持配置浏览、校验和表单编辑功能
- 实现跨表引用校验、热重载及批量编辑等高级特性文档
- 集成 Architecture 模块化接入和运行时校验行为说明
- 添加配置系统限制说明与独立工具评估结论
@sourcery-ai

sourcery-ai Bot commented Apr 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

扩展共享配置系统,使其在运行时验证器、VS Code 校验/工具以及源码生成器文档中,一致地支持 JSON Schema 对象级属性数量约束(minProperties/maxProperties),并相应更新测试和中文文档。

运行时 minProperties/maxProperties 校验的时序图

sequenceDiagram
    actor Developer
    participant GameRuntime
    participant YamlConfigLoader
    participant YamlConfigSchemaValidator
    participant YamlConfigSchemaNode
    participant ConfigLoadExceptionFactory

    Developer->>GameRuntime: Start game/load configs
    GameRuntime->>YamlConfigLoader: LoadAsync(registry)

    rect rgb(235,235,255)
        note over YamlConfigLoader,YamlConfigSchemaValidator: Schema parsing phase
        YamlConfigLoader->>YamlConfigSchemaValidator: ParseObjectNode(tableName, schemaPath, propertyPath, element)
        YamlConfigSchemaValidator->>YamlConfigSchemaValidator: ParseObjectConstraints(..., element)
        YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: TryParseObjectPropertyCountConstraint(minProperties)
        YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: TryParseObjectPropertyCountConstraint(maxProperties)
        alt minProperties > maxProperties
            YamlConfigSchemaValidator->>ConfigLoadExceptionFactory: Create(SchemaUnsupported,...)
            ConfigLoadExceptionFactory-->>YamlConfigLoader: throw ConfigLoadException
            YamlConfigLoader-->>GameRuntime: Propagate exception
            GameRuntime-->>Developer: Report schema error
            YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: return
        end
        YamlConfigSchemaValidator-->>YamlConfigLoader: YamlConfigSchemaNode.CreateObject(..., objectConstraints,...)
    end

    rect rgb(235,255,235)
        note over YamlConfigLoader,YamlConfigSchemaValidator: YAML validation phase
        YamlConfigLoader->>YamlConfigSchemaValidator: ValidateObjectNode(tableName, yamlPath, displayPath, schemaNode, yamlNode)
        YamlConfigSchemaValidator->>YamlConfigSchemaNode: Read ObjectConstraints and Children
        YamlConfigSchemaNode-->>YamlConfigSchemaValidator: ObjectConstraints
        YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: Count YAML properties
        YamlConfigSchemaValidator->>YamlConfigSchemaValidator: ValidateObjectConstraints(tableName, yamlPath, displayPath, propertyCount, schemaNode)
        alt propertyCount < MinProperties or propertyCount > MaxProperties
            YamlConfigSchemaValidator->>ConfigLoadExceptionFactory: Create(ConstraintViolation,... rawValue=propertyCount)
            ConfigLoadExceptionFactory-->>YamlConfigLoader: throw ConfigLoadException
            YamlConfigLoader-->>GameRuntime: Propagate exception
            GameRuntime-->>Developer: Report constraint violation
        else
            YamlConfigSchemaValidator-->>YamlConfigLoader: Validation success
            YamlConfigLoader-->>GameRuntime: Table registered
            GameRuntime-->>Developer: Game continues normally
        end
    end
Loading

YAML 对象属性数量约束的类图

classDiagram
    direction LR

    class YamlConfigSchemaValidator {
        <<static>>
        ParseObjectNode(tableName string, schemaPath string, propertyPath string, element JsonElement) YamlConfigSchemaNode
        ValidateObjectNode(tableName string, yamlPath string, displayPath string, schemaNode YamlConfigSchemaNode, yamlNode object)
        ValidateObjectConstraints(tableName string, yamlPath string, displayPath string, propertyCount int, schemaNode YamlConfigSchemaNode)
        ParseObjectConstraints(tableName string, schemaPath string, propertyPath string, element JsonElement) YamlConfigObjectConstraints
        TryParseObjectPropertyCountConstraint(tableName string, schemaPath string, propertyPath string, element JsonElement, keywordName string) int?
    }

    class YamlConfigSchemaNode {
        +YamlConfigSchemaPropertyType PropertyType
        +NodeChildren Children
        +string? ReferenceTableName
        +IReadOnlyCollection~string~? AllowedValues
        +YamlConfigScalarConstraints? Constraints
        +YamlConfigArrayConstraints? ArrayConstraints
        +YamlConfigObjectConstraints? ObjectConstraints
        +string SchemaPathHint
        +CreateObject(properties IReadOnlyDictionary~string,YamlConfigSchemaNode~?, requiredProperties IReadOnlyCollection~string~?, objectConstraints YamlConfigObjectConstraints?, schemaPathHint string) YamlConfigSchemaNode
        +CreateArray(itemNode YamlConfigSchemaNode, arrayConstraints YamlConfigArrayConstraints?, schemaPathHint string) YamlConfigSchemaNode
        +CreateScalar(propertyType YamlConfigSchemaPropertyType, referenceTableName string?, allowedValues IReadOnlyCollection~string~?, constraints YamlConfigScalarConstraints?, schemaPathHint string) YamlConfigSchemaNode
    }

    class NodeValidation {
        +string? ReferenceTableName
        +IReadOnlyCollection~string~? AllowedValues
        +YamlConfigScalarConstraints? Constraints
        +YamlConfigArrayConstraints? ArrayConstraints
        +YamlConfigObjectConstraints? ObjectConstraints
        +WithReferenceTable(referenceTableName string) NodeValidation
    }

    class YamlConfigObjectConstraints {
        +int? MinProperties
        +int? MaxProperties
        +YamlConfigObjectConstraints(minProperties int?, maxProperties int?)
    }

    class YamlConfigArrayConstraints {
        +int? MinItems
        +int? MaxItems
        +bool UniqueItems
    }

    class YamlConfigScalarConstraints {
        +double? Minimum
        +double? Maximum
        +double? ExclusiveMinimum
        +double? ExclusiveMaximum
        +double? MultipleOf
        +int? MinLength
        +int? MaxLength
        +string? Pattern
    }

    YamlConfigSchemaNode o-- NodeValidation : wraps
    YamlConfigSchemaNode o-- YamlConfigScalarConstraints : uses
    YamlConfigSchemaNode o-- YamlConfigArrayConstraints : uses
    YamlConfigSchemaNode o-- YamlConfigObjectConstraints : uses

    NodeValidation *-- YamlConfigScalarConstraints : aggregates
    NodeValidation *-- YamlConfigArrayConstraints : aggregates
    NodeValidation *-- YamlConfigObjectConstraints : aggregates

    YamlConfigSchemaValidator --> YamlConfigSchemaNode : creates/reads
    YamlConfigSchemaValidator --> YamlConfigObjectConstraints : parses/validates
Loading

文件级改动

Change Details Files
为 YAML 配置验证添加对 JSON Schema 对象级 minProperties/maxProperties 约束的运行时支持。
  • 从对象 schema 节点中解析 minProperties/maxProperties 到新的 YamlConfigObjectConstraints 模型中,并通过 YamlConfigSchemaNode 进行验证串联。
  • 在加载时校验对象属性数量,当约束被违背或声明不合法时抛出带有详细诊断信息的 ConfigLoadException。
  • 扩展 YamlConfigSchemaValidator 上的 XML 注释,记录新的受支持约束子集。
GFramework.Game/Config/YamlConfigSchemaValidator.cs
为对象级属性数量验证行为添加测试覆盖率。
  • 添加测试,确保违反 minProperties 或 maxProperties 的 YAML 对象会产生 ConstraintViolation 失败,并具有预期的诊断路径、消息和注册表状态。
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
让 Node.js 配置验证工具能够解析、验证并展示对象级 minProperties/maxProperties 约束,包括本地化的诊断和提示。
  • 扩展 schema 解析元数据以捕获 minProperties/maxProperties,并将其传播到 SchemaNode/对象模型中。
  • 在 validateObjectNode 中验证对象属性数量,并为根对象和嵌套对象发出新的 minPropertiesViolation/maxPropertiesViolation 诊断,附带本地化消息。
  • 添加辅助方法 formatObjectPropertyCountMessage,以及新的 ValidationMessageKeys,并为验证与元数据捕获同时添加测试。
  • 在公共 schema 类型定义和 VS Code webview 提示中暴露 minProperties/maxProperties,并将 schema 元数据串联到收集的表单字段中。
tools/gframework-config-tool/src/configValidation.js
tools/gframework-config-tool/test/configValidation.test.js
tools/gframework-config-tool/src/localization.js
tools/gframework-config-tool/src/localizationKeys.js
tools/gframework-config-tool/src/extension.js
在基于 schema 的配置类型的生成代码文档中包含对象级属性数量约束。
  • 通过 schemaType 为 "object" 的 TryBuildConstraintDocumentation 捕获对象 schema 规范的约束文档。
  • 在生成的对象类型上输出 部分,总结适用的约束,包括存在时的 minProperties/maxProperties。
  • 更新 SchemaObjectSpec 记录和生成器快照,以适配新的约束文档字段以及示例 Monster schema 中的示例约束。
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt
更新中文配置系统文档,描述在运行时、生成器和工具之间共享的新的 minProperties/maxProperties 支持。
  • 在共享约束列表和运行时约束违规行为列表中记录 minProperties/maxProperties。
  • 解释 minProperties/maxProperties 如何在运行时验证器、VS Code 验证/表单提示以及生成的 XML 文档之间复用,包括其对根对象和嵌套对象的适用性。
  • 在 VS Code 表单 UI 能力列表中提及新的元数据。
docs/zh-CN/game/config-system.md

Tips and commands

Interacting with Sourcery

  • 触发新评审: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 通过回复某条评审评论,请求 Sourcery 从该评论创建一个 issue。你也可以在评审评论下回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在该位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成 Reviewer's Guide: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成 reviewer's guide。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可标记解决所有 Sourcery 评论。如果你已经处理了所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 评审: 在 pull request 中评论 @sourcery-ai dismiss,即可撤销所有现有的 Sourcery 评审。若你希望从一个全新的评审开始,这尤其有用——别忘了随后评论 @sourcery-ai review 来触发新的评审!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用评审特性,例如 Sourcery 自动生成的 pull request 摘要、reviewer's guide 等。
  • 更改评审语言。
  • 添加、删除或编辑自定义评审指令。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Extend the shared config system to support JSON Schema object-level property-count constraints (minProperties/maxProperties) consistently across runtime validator, VS Code validation/tooling, and source generator docs, with tests and Chinese docs updated accordingly.

Sequence diagram for runtime minProperties/maxProperties validation

sequenceDiagram
    actor Developer
    participant GameRuntime
    participant YamlConfigLoader
    participant YamlConfigSchemaValidator
    participant YamlConfigSchemaNode
    participant ConfigLoadExceptionFactory

    Developer->>GameRuntime: Start game/load configs
    GameRuntime->>YamlConfigLoader: LoadAsync(registry)

    rect rgb(235,235,255)
        note over YamlConfigLoader,YamlConfigSchemaValidator: Schema parsing phase
        YamlConfigLoader->>YamlConfigSchemaValidator: ParseObjectNode(tableName, schemaPath, propertyPath, element)
        YamlConfigSchemaValidator->>YamlConfigSchemaValidator: ParseObjectConstraints(..., element)
        YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: TryParseObjectPropertyCountConstraint(minProperties)
        YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: TryParseObjectPropertyCountConstraint(maxProperties)
        alt minProperties > maxProperties
            YamlConfigSchemaValidator->>ConfigLoadExceptionFactory: Create(SchemaUnsupported,...)
            ConfigLoadExceptionFactory-->>YamlConfigLoader: throw ConfigLoadException
            YamlConfigLoader-->>GameRuntime: Propagate exception
            GameRuntime-->>Developer: Report schema error
            YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: return
        end
        YamlConfigSchemaValidator-->>YamlConfigLoader: YamlConfigSchemaNode.CreateObject(..., objectConstraints,...)
    end

    rect rgb(235,255,235)
        note over YamlConfigLoader,YamlConfigSchemaValidator: YAML validation phase
        YamlConfigLoader->>YamlConfigSchemaValidator: ValidateObjectNode(tableName, yamlPath, displayPath, schemaNode, yamlNode)
        YamlConfigSchemaValidator->>YamlConfigSchemaNode: Read ObjectConstraints and Children
        YamlConfigSchemaNode-->>YamlConfigSchemaValidator: ObjectConstraints
        YamlConfigSchemaValidator-->>YamlConfigSchemaValidator: Count YAML properties
        YamlConfigSchemaValidator->>YamlConfigSchemaValidator: ValidateObjectConstraints(tableName, yamlPath, displayPath, propertyCount, schemaNode)
        alt propertyCount < MinProperties or propertyCount > MaxProperties
            YamlConfigSchemaValidator->>ConfigLoadExceptionFactory: Create(ConstraintViolation,... rawValue=propertyCount)
            ConfigLoadExceptionFactory-->>YamlConfigLoader: throw ConfigLoadException
            YamlConfigLoader-->>GameRuntime: Propagate exception
            GameRuntime-->>Developer: Report constraint violation
        else
            YamlConfigSchemaValidator-->>YamlConfigLoader: Validation success
            YamlConfigLoader-->>GameRuntime: Table registered
            GameRuntime-->>Developer: Game continues normally
        end
    end
Loading

Class diagram for YAML object property-count constraints

classDiagram
    direction LR

    class YamlConfigSchemaValidator {
        <<static>>
        ParseObjectNode(tableName string, schemaPath string, propertyPath string, element JsonElement) YamlConfigSchemaNode
        ValidateObjectNode(tableName string, yamlPath string, displayPath string, schemaNode YamlConfigSchemaNode, yamlNode object)
        ValidateObjectConstraints(tableName string, yamlPath string, displayPath string, propertyCount int, schemaNode YamlConfigSchemaNode)
        ParseObjectConstraints(tableName string, schemaPath string, propertyPath string, element JsonElement) YamlConfigObjectConstraints
        TryParseObjectPropertyCountConstraint(tableName string, schemaPath string, propertyPath string, element JsonElement, keywordName string) int?
    }

    class YamlConfigSchemaNode {
        +YamlConfigSchemaPropertyType PropertyType
        +NodeChildren Children
        +string? ReferenceTableName
        +IReadOnlyCollection~string~? AllowedValues
        +YamlConfigScalarConstraints? Constraints
        +YamlConfigArrayConstraints? ArrayConstraints
        +YamlConfigObjectConstraints? ObjectConstraints
        +string SchemaPathHint
        +CreateObject(properties IReadOnlyDictionary~string,YamlConfigSchemaNode~?, requiredProperties IReadOnlyCollection~string~?, objectConstraints YamlConfigObjectConstraints?, schemaPathHint string) YamlConfigSchemaNode
        +CreateArray(itemNode YamlConfigSchemaNode, arrayConstraints YamlConfigArrayConstraints?, schemaPathHint string) YamlConfigSchemaNode
        +CreateScalar(propertyType YamlConfigSchemaPropertyType, referenceTableName string?, allowedValues IReadOnlyCollection~string~?, constraints YamlConfigScalarConstraints?, schemaPathHint string) YamlConfigSchemaNode
    }

    class NodeValidation {
        +string? ReferenceTableName
        +IReadOnlyCollection~string~? AllowedValues
        +YamlConfigScalarConstraints? Constraints
        +YamlConfigArrayConstraints? ArrayConstraints
        +YamlConfigObjectConstraints? ObjectConstraints
        +WithReferenceTable(referenceTableName string) NodeValidation
    }

    class YamlConfigObjectConstraints {
        +int? MinProperties
        +int? MaxProperties
        +YamlConfigObjectConstraints(minProperties int?, maxProperties int?)
    }

    class YamlConfigArrayConstraints {
        +int? MinItems
        +int? MaxItems
        +bool UniqueItems
    }

    class YamlConfigScalarConstraints {
        +double? Minimum
        +double? Maximum
        +double? ExclusiveMinimum
        +double? ExclusiveMaximum
        +double? MultipleOf
        +int? MinLength
        +int? MaxLength
        +string? Pattern
    }

    YamlConfigSchemaNode o-- NodeValidation : wraps
    YamlConfigSchemaNode o-- YamlConfigScalarConstraints : uses
    YamlConfigSchemaNode o-- YamlConfigArrayConstraints : uses
    YamlConfigSchemaNode o-- YamlConfigObjectConstraints : uses

    NodeValidation *-- YamlConfigScalarConstraints : aggregates
    NodeValidation *-- YamlConfigArrayConstraints : aggregates
    NodeValidation *-- YamlConfigObjectConstraints : aggregates

    YamlConfigSchemaValidator --> YamlConfigSchemaNode : creates/reads
    YamlConfigSchemaValidator --> YamlConfigObjectConstraints : parses/validates
Loading

File-Level Changes

Change Details Files
Add runtime support for JSON Schema object-level minProperties/maxProperties constraints in YAML config validation.
  • Parse minProperties/maxProperties from object schema nodes into a new YamlConfigObjectConstraints model with validation wiring on YamlConfigSchemaNode.
  • Validate object property counts at load time, throwing ConfigLoadException with detailed diagnostics when constraints are violated or misdeclared.
  • Extend XML comments on YamlConfigSchemaValidator to document the new supported constraint subset.
GFramework.Game/Config/YamlConfigSchemaValidator.cs
Add test coverage for object-level property-count validation behavior.
  • Add tests ensuring YAML objects that violate minProperties or maxProperties produce ConstraintViolation failures with expected diagnostic paths, messages, and registry state.
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
Teach the Node.js config validation tool to parse, validate, and surface object-level minProperties/maxProperties constraints, including localized diagnostics and hints.
  • Extend schema parsing metadata to capture minProperties/maxProperties and propagate them into SchemaNode/object models.
  • Validate object property counts in validateObjectNode and emit new minPropertiesViolation/maxPropertiesViolation diagnostics with localized messages for root and nested objects.
  • Add helper formatObjectPropertyCountMessage plus new ValidationMessageKeys and tests for both validation and metadata capture.
  • Expose minProperties/maxProperties in public schema typings and VS Code webview hints, and thread schema metadata into collected form fields.
tools/gframework-config-tool/src/configValidation.js
tools/gframework-config-tool/test/configValidation.test.js
tools/gframework-config-tool/src/localization.js
tools/gframework-config-tool/src/localizationKeys.js
tools/gframework-config-tool/src/extension.js
Include object-level property-count constraints in generated code documentation for schema-driven config types.
  • Capture constraint documentation for object schema specs via TryBuildConstraintDocumentation with schemaType "object".
  • Emit sections on generated object types summarizing applicable constraints, including minProperties/maxProperties when present.
  • Update SchemaObjectSpec record and generator snapshots to account for the new constraint documentation field and example constraints in the sample Monster schema.
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt
Update Chinese configuration system documentation to describe the new shared minProperties/maxProperties support across runtime, generator, and tooling.
  • Document minProperties/maxProperties in the shared constraint list and in the behavior list for runtime constraint violations.
  • Explain how minProperties/maxProperties are reused across runtime validator, VS Code validation/form hints, and generated XML docs, including applicability to root and nested objects.
  • Mention the new metadata in the VS Code form UI capabilities list.
docs/zh-CN/game/config-system.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Apr 10, 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: ed66aa18-8138-4e79-b6a7-f76fad50c6c6

📥 Commits

Reviewing files that changed from the base of the PR and between 1a50d7a and a49c99c.

📒 Files selected for processing (3)
  • tools/gframework-config-tool/src/configValidation.js
  • tools/gframework-config-tool/src/localization.js
  • tools/gframework-config-tool/test/localization.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/gframework-config-tool/src/localization.js
📜 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)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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
🔇 Additional comments (8)
tools/gframework-config-tool/test/localization.test.js (1)

39-59: LGTM!

新增的测试用例完整覆盖了 minPropertiesViolationmaxPropertiesViolation 在英文和简体中文两种语言下的本地化输出,与 configValidation.js 中的实际调用方式和 localization.js 中的模板定义保持一致。

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

20-26: LGTM!

JSDoc 返回类型正确地添加了 minPropertiesmaxProperties 可选字段。


644-671: LGTM!

Schema 解析逻辑正确使用 normalizeSchemaNonNegativeInteger 验证 minPropertiesmaxProperties,符合 JSON Schema 规范要求(非负整数),并在返回的对象节点中正确包含这些约束。


970-974: LGTM!

属性计数逻辑已正确修复:优先使用 yamlNode.map.size 获取唯一属性数量,避免了重复键被多次计数的问题。


1006-1026: LGTM!

验证逻辑正确检查 minPropertiesmaxProperties 约束,与文件中其他约束验证(如 minItemsmaxItems)的模式保持一致。


1089-1115: LGTM!

本地化消息处理逻辑设计合理:当 displayPath 为空(根对象)时,回退到 formatObjectPropertyCountMessage 处理根对象的特殊文案("Root object..." / "根对象..."),而非空路径则使用 localizer.t() 生成标准属性路径消息。


1202-1254: LGTM!

新增的格式化函数 formatExpectedObjectMessageformatObjectPropertyCountMessage 实现完善:

  • 正确处理根对象与嵌套对象的不同文案
  • 支持 min/max 两种模式
  • 中英文消息语法正确

1883-1922: LGTM!

SchemaNode 类型定义已正确更新,在对象类型分支中添加了 minPropertiesmaxProperties 可选字段。


📝 Walkthrough

Walkthrough

在运行时、源生成器与工具链中新增对 JSON Schema 对象级关键字 minProperties / maxProperties 的解析、文档化与验证;包含运行时/工具链验证、生成器注释输出、测试、快照与本地化更新。

Changes

Cohort / File(s) Summary
核心运行时验证
GFramework.Game/Config/YamlConfigSchemaValidator.cs
新增 YamlConfigObjectConstraintsminProperties/maxProperties),将其保存在 YamlConfigSchemaNode.ObjectConstraintsCreateObject 与节点验证管线携带该约束;ValidateObjectNode 根据实际映射条目数抛出 ConstraintViolation
运行时测试
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
新增五个单元测试,覆盖运行时违反/解析时非法 minProperties/maxProperties(负值、非整数、上下界颠倒)并断言抛出 ConfigLoadException、诊断字段与注册表为空。
源生成器与快照
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs, GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs, GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt, GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
将对象级 minProperties/maxProperties 纳入 TryBuildConstraintDocumentation 并保存到 SchemaObjectSpec.ConstraintDocumentation;生成器在类型 XML 注释(<remarks>)中输出 Constraints;更新测试 schema 与快照;将 required 比较由不区分大小写改为区分大小写并增加相应测试。
工具链:模式解析与验证(JS)
tools/gframework-config-tool/src/configValidation.js, tools/gframework-config-tool/test/configValidation.test.js
解析时捕获对象级 minProperties/maxProperties;对象验证计算属性数并生成 minPropertiesViolation/maxPropertiesViolation 诊断;重构本地化消息格式化;新增覆盖顶层/嵌套/重复键与中文本地化的单元测试。
工具链:VS Code UI 扩展
tools/gframework-config-tool/src/extension.js
将 schema 元数据附加到 section/array/objectArray 字段描述;renderFieldHint 增加 includeDescription 参数并显示对象级 minProperties/maxProperties 提示。
工具链:本地化键与文案
tools/gframework-config-tool/src/localizationKeys.js, tools/gframework-config-tool/src/localization.js
新增 minPropertiesViolation / maxPropertiesViolation 本地化键及中/英文文案;移除 expectedObject 验证模板并调整消息模板处理。
文档
docs/zh-CN/game/config-system.md
文档中列出对 minProperties/maxProperties 的支持、运行时验证行为与表单提示元数据更新。

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer / Generator
  participant Generator as SchemaConfigGenerator
  participant Tool as ConfigTool (JS)
  participant Loader as YamlConfigLoader
  participant Validator as YamlConfigSchemaValidator
  participant Registry as ConfigRegistry

  Dev->>Generator: 生成带 minProperties/maxProperties 的约束文档
  Generator->>Tool: 输出架构元数据(包含约束)
  Tool->>Tool: 解析 schema,附加 minProperties/maxProperties 到节点
  Loader->>Validator: 加载 YAML 并传入对应 schema 节点
  Validator->>Validator: 计数对象属性,校验 min/max
  Validator-->>Loader: 若违规,抛出 ConstraintViolation(含 DisplayPath/RawValue)
  Loader->>Registry: 成功时注册表项(违规则不注册)
Loading

Estimated code review effort

🎯 3 (中等) | ⏱️ ~20 分钟

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning PR 标题仅涉及文档与验证工具,但实际变更包含了运行时校验逻辑、源代码生成器更新、类型签名修改等多项功能实现,标题严重低估了变更范围。 更新标题以反映完整变更范围,如:'feat(config): 实现 minProperties/maxProperties 约束支持与相关文档',更准确地描述核心功能实现。
✅ 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 92.11% 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 docs/config-system

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并留下了一些整体性的反馈:

  • 在 VS Code 工具链中,localizeValidationMessage 现在通过 formatObjectPropertyCountMessageminProperties/maxProperties 做了特殊处理,而同样的键也在 enMessages/zhCnMessages 中定义;建议要么移除这些已不再使用的字典条目,要么改为全部通过字典进行路由,以避免出现重复/相互竞争的消息定义。
  • ValidateObjectConstraints 中,诊断消息使用了自定义的 subject 字符串,但仍然传入了 GetDiagnosticPath(displayPath);如果对于根对象 displayPath 为空,请仔细确认这种组合是否生成了预期的诊断路径格式,并且不会在工具中显示空白路径。
面向 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- In the VS Code tooling, `localizeValidationMessage` now special-cases `minProperties`/`maxProperties` via `formatObjectPropertyCountMessage` while the same keys are also defined in `enMessages`/`zhCnMessages`; consider removing the now-unused dictionary entries or routing everything through the dictionary to avoid duplicated/competing message definitions.
- In `ValidateObjectConstraints` the diagnostic messages use a custom `subject` string but still pass `GetDiagnosticPath(displayPath)`; if `displayPath` is empty for root objects, double-check that this combination produces the intended diagnostic path formatting and doesn’t show a blank path in tools.

## Individual Comments

### Comment 1
<location path="GFramework.Game/Config/YamlConfigSchemaValidator.cs" line_range="965-973" />
<code_context>
+        if (minProperties.HasValue && maxProperties.HasValue && minProperties.Value > maxProperties.Value)
+        {
+            throw ConfigLoadExceptionFactory.Create(
+                ConfigLoadFailureKind.SchemaUnsupported,
+                tableName,
+                $"Property '{propertyPath}' in schema file '{schemaPath}' declares 'minProperties' greater than 'maxProperties'.",
+                schemaPath: schemaPath,
+                displayPath: GetDiagnosticPath(propertyPath));
</code_context>
<issue_to_address>
**suggestion:** Error message for invalid min/max properties can be awkward when `propertyPath` is empty (root object).

When this validation runs on the root schema object, `propertyPath` may be empty, yielding a message like `Property '' in schema file ... declares ...`. Please either special‑case the root (e.g., `Root object in schema file ...`) or rely on `GetDiagnosticPath(propertyPath)` for the message text so we don’t surface an empty property name to users.

```suggestion
        if (minProperties.HasValue && maxProperties.HasValue && minProperties.Value > maxProperties.Value)
        {
            var targetDescription = string.IsNullOrEmpty(propertyPath)
                ? "Root object"
                : $"Property '{propertyPath}'";

            throw ConfigLoadExceptionFactory.Create(
                ConfigLoadFailureKind.SchemaUnsupported,
                tableName,
                $"{targetDescription} in schema file '{schemaPath}' declares 'minProperties' greater than 'maxProperties'.",
                schemaPath: schemaPath,
                displayPath: GetDiagnosticPath(propertyPath));
        }
```
</issue_to_address>

Sourcery 对开源项目免费使用——如果你觉得我们的代码审查有帮助,请考虑分享给他人 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续的审查建议。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In the VS Code tooling, localizeValidationMessage now special-cases minProperties/maxProperties via formatObjectPropertyCountMessage while the same keys are also defined in enMessages/zhCnMessages; consider removing the now-unused dictionary entries or routing everything through the dictionary to avoid duplicated/competing message definitions.
  • In ValidateObjectConstraints the diagnostic messages use a custom subject string but still pass GetDiagnosticPath(displayPath); if displayPath is empty for root objects, double-check that this combination produces the intended diagnostic path formatting and doesn’t show a blank path in tools.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the VS Code tooling, `localizeValidationMessage` now special-cases `minProperties`/`maxProperties` via `formatObjectPropertyCountMessage` while the same keys are also defined in `enMessages`/`zhCnMessages`; consider removing the now-unused dictionary entries or routing everything through the dictionary to avoid duplicated/competing message definitions.
- In `ValidateObjectConstraints` the diagnostic messages use a custom `subject` string but still pass `GetDiagnosticPath(displayPath)`; if `displayPath` is empty for root objects, double-check that this combination produces the intended diagnostic path formatting and doesn’t show a blank path in tools.

## Individual Comments

### Comment 1
<location path="GFramework.Game/Config/YamlConfigSchemaValidator.cs" line_range="965-973" />
<code_context>
+        if (minProperties.HasValue && maxProperties.HasValue && minProperties.Value > maxProperties.Value)
+        {
+            throw ConfigLoadExceptionFactory.Create(
+                ConfigLoadFailureKind.SchemaUnsupported,
+                tableName,
+                $"Property '{propertyPath}' in schema file '{schemaPath}' declares 'minProperties' greater than 'maxProperties'.",
+                schemaPath: schemaPath,
+                displayPath: GetDiagnosticPath(propertyPath));
</code_context>
<issue_to_address>
**suggestion:** Error message for invalid min/max properties can be awkward when `propertyPath` is empty (root object).

When this validation runs on the root schema object, `propertyPath` may be empty, yielding a message like `Property '' in schema file ... declares ...`. Please either special‑case the root (e.g., `Root object in schema file ...`) or rely on `GetDiagnosticPath(propertyPath)` for the message text so we don’t surface an empty property name to users.

```suggestion
        if (minProperties.HasValue && maxProperties.HasValue && minProperties.Value > maxProperties.Value)
        {
            var targetDescription = string.IsNullOrEmpty(propertyPath)
                ? "Root object"
                : $"Property '{propertyPath}'";

            throw ConfigLoadExceptionFactory.Create(
                ConfigLoadFailureKind.SchemaUnsupported,
                tableName,
                $"{targetDescription} in schema file '{schemaPath}' declares 'minProperties' greater than 'maxProperties'.",
                schemaPath: schemaPath,
                displayPath: GetDiagnosticPath(propertyPath));
        }
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread GFramework.Game/Config/YamlConfigSchemaValidator.cs
@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extends the shared config validation subset (minProperties / maxProperties) across three layers: the C# runtime YAML schema validator, the VS Code config tool (validation diagnostics, form hints, localization), and the Roslyn source generator (XML doc output). It also corrects required-field lookup in the source generator to use StringComparer.Ordinal, aligning it with JSON Schema's case-sensitive property name semantics and the runtime validator.

Key changes:

  • Runtime (YamlConfigSchemaValidator.cs): ParseObjectConstraints extracts and validates both constraints at schema-load time (non-negative integer, and minProperties ≤ maxProperties); ValidateObjectConstraints checks actual YAML property counts with precise diagnostic messages and test coverage for all failure modes.
  • VS Code tool (configValidation.js, extension.js): Parses minProperties/maxProperties into the schema node tree, validates them in validateObjectNode, and surfaces them as form hints via the existing renderFieldHint path.
  • Localization (localization.js, localizationKeys.js): Both violation keys are now registered in ValidationMessageKeys and have corresponding dictionary entries in enMessages/zhCnMessages, resolving the concern raised in a prior review thread.
  • Source generator (SchemaConfigGenerator.cs): TryBuildConstraintDocumentation emits minProperties = N, maxProperties = M in the class-level <remarks> for object types; snapshot updated accordingly.
  • Tests: C# tests cover all five runtime error paths (violation, invalid value, non-integer, inconsistent range); JS tests cover parsing and validation diagnostics; localization tests confirm both keys resolve correctly through localizer.t().

One asymmetry remains: the JS tool silently accepts a schema where minProperties > maxProperties (both values pass normalizeSchemaNonNegativeInteger independently), while the C# runtime rejects such schemas with an explicit exception. This can produce misleading YAML-level diagnostics instead of a schema-level error in the tool.

Confidence Score: 4/5

Safe to merge; all layers are correctly implemented with good test coverage, and the previous thread concern about missing localization entries is resolved.

The implementation is solid and consistent across C# runtime, source generator, and VS Code tool. The localization entries are now present. One P2 asymmetry remains: the JS tool does not warn when a schema declares minProperties > maxProperties (the C# runtime rejects such schemas at load time), which can produce confusing YAML-level diagnostics instead of a schema-level error. This does not affect correctness of well-formed schemas and does not block merging.

tools/gframework-config-tool/src/configValidation.js — missing minProperties > maxProperties consistency check at schema-parse time.

Important Files Changed

Filename Overview
tools/gframework-config-tool/src/configValidation.js Parses and validates minProperties/maxProperties for object nodes; individual invalid values are silently dropped via normalizeSchemaNonNegativeInteger, but no explicit diagnostic is emitted when minProperties > maxProperties (unlike the C# runtime which throws at schema load time).
GFramework.Game/Config/YamlConfigSchemaValidator.cs Adds ParseObjectConstraints and ValidateObjectConstraints for minProperties/maxProperties; correctly validates at schema-parse time (rejects minProperties > maxProperties, non-integer, negative) and at YAML validation time using seenProperties.Count.
tools/gframework-config-tool/src/localization.js Adds minPropertiesViolation and maxPropertiesViolation localization entries to both enMessages and zhCnMessages, resolving the previous thread's concern about missing dictionary entries.
tools/gframework-config-tool/src/localizationKeys.js Adds maxPropertiesViolation and minPropertiesViolation keys to the frozen ValidationMessageKeys object; both now have matching entries in localization.js.
tools/gframework-config-tool/src/extension.js Adds form hint rendering for minProperties/maxProperties on object fields using the correct localizer keys; gated on propertySchema.type === "object" which prevents these from appearing on non-object schema nodes.
GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs Extends TryBuildConstraintDocumentation to include minProperties/maxProperties in generated XML docs; also changes required-field lookup to StringComparer.Ordinal (case-sensitive), aligning with JSON Schema spec and the runtime validator.
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs Adds five new test methods covering minProperties/maxProperties violations, invalid constraint declarations (negative, non-integer), and minProperties > maxProperties rejection at schema-load time.
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs Adds minProperties/maxProperties to the snapshot schema; snapshot output correctly shows Constraints: minProperties = N, maxProperties = M. in the generated class XML docs.
GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt Updated snapshot correctly shows minProperties/maxProperties constraint documentation on root class and nested RewardConfig class.
GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs Existing diagnostic tests unchanged; no new tests specifically for minProperties/maxProperties in the source generator, which is acceptable since the generator only writes docs.
tools/gframework-config-tool/test/configValidation.test.js Adds tests for parsing minProperties/maxProperties on both root and nested objects, and for validation failures when property counts violate either constraint.
tools/gframework-config-tool/test/localization.test.js Adds tests confirming that localizer.t() correctly resolves minPropertiesViolation and maxPropertiesViolation keys in both English and Simplified Chinese via the localization dictionary.
docs/zh-CN/game/config-system.md Documentation updated to list minProperties/maxProperties in the shared constraint support table, runtime validation bullet list, and VS Code form metadata section.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Schema JSON file] --> B{Parse schema}
    B -->|C# runtime| C[ParseObjectConstraints]
    B -->|JS tool| D[parseSchemaNode / normalizeSchemaNonNegativeInteger]
    C --> E{minProperties > maxProperties?}
    E -->|Yes| F[Throw ConfigLoadException\nSchemaUnsupported]
    E -->|No| G[YamlConfigObjectConstraints stored]
    D --> H[minProperties + maxProperties stored\nno cross-check]
    G --> I[ValidateObjectNode]
    H --> J[validateObjectNode]
    I --> K{seenProperties.Count\nviolates min or max?}
    J --> L{propertyCount\nviolates min or max?}
    K -->|Yes| M[Throw ConfigLoadException\nConstraintViolation]
    L -->|Yes| N[Push diagnostic via\nlocalizeValidationMessage]
    N --> O{displayPath empty?}
    O -->|Yes - root object| P[formatObjectPropertyCountMessage\nhardcoded root text]
    O -->|No - nested| Q[localizer.t via\nlocalization dictionary]
    G --> R[SchemaConfigGenerator\nXML doc output:\nConstraints: minProperties = N]
Loading

Reviews (4): Last reviewed commit: "feat(config): 添加配置验证功能模块" | Re-trigger Greptile

@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: 2

🤖 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 1251-1358: Add regression tests in YamlConfigLoaderTests to cover
invalid-schema parsing branches: create new tests (e.g.,
LoadAsync_Should_Throw_When_MinProperties_Is_Negative,
LoadAsync_Should_Throw_When_MaxProperties_Is_Negative,
LoadAsync_Should_Throw_When_MinGreaterThanMax) that mirror the existing
LoadAsync_Should_Throw_When_Object_Violates_MinProperties/MaxProperties setup
but write schemas where "minProperties" or "maxProperties" are negative or where
minProperties > maxProperties, then call loader.LoadAsync(registry) and
Assert.ThrowsAsync<ConfigLoadException> and assert
exception.Diagnostic.FailureKind == ConfigLoadFailureKind.SchemaUnsupported (and
appropriate Diagnostic.DisplayPath/Message as needed); place these tests
alongside the existing ones in the YamlConfigLoaderTests class so parsing
failures of bad schemas are asserted.

In `@tools/gframework-config-tool/src/configValidation.js`:
- Line 978: propertyCount is incorrectly computed from yamlNode.entries which
counts duplicate keys; change it to use the node's map semantics instead (derive
the property count from yamlNode.map—e.g. count map items or unique map keys) so
duplicate keys aren't double-counted; update the assignment that sets
propertyCount (currently referencing yamlNode.entries) to read from yamlNode.map
(or compute unique keys from yamlNode.map) and leave minProperties/maxProperties
checks 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: 69078e87-04c8-4f43-a2d4-a15dcf1ebfa1

📥 Commits

Reviewing files that changed from the base of the PR and between 5722b2a and 06d048f.

📒 Files selected for processing (11)
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt
  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.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
📜 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 (7)
**/*.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> tags where applicable
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, or edge cases in C# code
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, 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
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 in C# files
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments in C# code
Follow standard C# naming: Types, methods, properties, events, and constants use PascalCase; Interfaces use I prefix; Parameters and locals use camelCase; Private fields use _camelCase
Use 4 spaces for i...

Files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
**/*.Tests/**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.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
Public API changes must be covered by unit or integration tests
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
Regression fixes should include a test that fails before the fix and passes after it
Mirror the source structure in test projects whenever practical
Reuse existing architecture test infrastructure when relevant: ArchitectureTestsBase<T>, SyncTestArchitecture, AsyncTestArchitecture
Keep tests focused on observable behavior, not implementation trivia

Files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.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
When generator behavior changes intentionally, update snapshots together with the implementation in source generator tests

Files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.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}

📄 CodeRabbit inference engine (AGENTS.md)

Update the relevant README.md or docs/ page when behavior, setup steps, architecture guidance, or user-facing examples change

Files:

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

📄 CodeRabbit inference engine (AGENTS.md)

docs/**/*.md: Keep code samples, package names, and command examples in documentation aligned with the current repository state
Prefer documenting behavior and design intent, not only API surface, in repository documentation
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
If an existing documentation page no longer reflects the current implementation, updating the documentation is part of fixing the code and cannot be deferred
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
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)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt
  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to **/*.SourceGenerators.Tests/**/*.cs : When generator behavior changes intentionally, update snapshots together with the implementation in source generator tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to **/*.SourceGenerators.Tests/**/*.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to **/*.Tests/**/*.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • 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.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs
  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to docs/**/*.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
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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
🔇 Additional comments (8)
tools/gframework-config-tool/src/localizationKeys.js (1)

12-12: 新增校验键定义清晰且与语义对齐。

Line 12 和 Line 17 的 key 粒度准确,适配对象属性数量约束场景,整体实现可直接合并。

Also applies to: 17-17

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

127-128: 双语提示与校验文案同步完整。

新增的 minProperties/maxProperties 在 English/简中两套字典都已覆盖,且与 validation key 一一对应,避免了本地化缺失。

Also applies to: 139-144, 235-236, 247-252

GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorSnapshotTests.cs (1)

72-73: 快照测试输入覆盖范围合理。

这里同时覆盖了根对象和嵌套对象的属性数量约束,能有效支撑本次生成器输出变更验证。

Also applies to: 118-119

GFramework.SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfig.g.txt (1)

10-12: 快照输出已正确反映对象约束文档。

MonsterConfigRewardConfig<remarks> 约束说明已同步到快照,和预期生成行为一致。

Also applies to: 80-82

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

15-15: 文档更新与功能变更保持一致。

新增内容把 minProperties/maxProperties 在能力列表、运行时校验、轻量元数据和 VS Code 表单入口全部串联起来了,集成说明完整。

Also applies to: 660-660, 715-715, 812-812

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

262-263: 对象约束文档生成链路实现完整。

从 schema 解析到 SchemaObjectSpec 持有,再到 AppendObjectType 输出 <remarks>,这次改动闭环清晰,行为一致。

Also applies to: 1881-1887, 2523-2533, 2679-2687

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

311-344: 新增测试覆盖面到位。

这两组用例把 minProperties/maxProperties 的“解析正确性 + 校验诊断”都补齐了,并且覆盖了嵌套对象场景。

Also applies to: 653-676

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

1098-1098: 表单对象区块的约束提示接入实现正确。

schema 透传 + renderFieldHint 扩展后,minProperties/maxProperties 可以在 section 级别稳定展示,同时通过 includeDescription 避免了重复文案。

Also applies to: 1306-1306, 1473-1473, 1580-1585, 1588-1589, 1637-1643

Comment thread GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
Comment thread tools/gframework-config-tool/src/configValidation.js Outdated
- 实现了JSON schema解析器和验证器
- 添加了YAML文档解析和注释提取功能
- 创建了配置验证诊断系统支持中英文本地化
- 实现了批量编辑器可编辑字段收集功能
- 添加了配置文件示例生成功能
- 实现了表单更新应用到YAML的功能
- 添加了精确十进制算术运算支持multipleOf约束检查
- 实现了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.

♻️ Duplicate comments (1)
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs (1)

1360-1410: ⚠️ Potential issue | 🟡 Minor

建议补齐 maxProperties 为负数的解析失败分支

Line 1361-1365 当前只覆盖了 minProperties = -1,但同类分支里 maxProperties = -1 还未单独验证,SchemaUnsupported 的另一条路径仍有回归盲区。

📌 可选补丁(新增一个对称用例)
+    [Test]
+    public void LoadAsync_Should_Throw_When_Object_MaxProperties_Is_Negative()
+    {
+        CreateConfigFile(
+            "monster/slime.yaml",
+            """
+            id: 1
+            name: Slime
+            reward:
+              gold: 10
+            """);
+        CreateSchemaFile(
+            "schemas/monster.schema.json",
+            """
+            {
+              "type": "object",
+              "required": ["id", "name", "reward"],
+              "properties": {
+                "id": { "type": "integer" },
+                "name": { "type": "string" },
+                "reward": {
+                  "type": "object",
+                  "maxProperties": -1,
+                  "properties": {
+                    "gold": { "type": "integer" }
+                  }
+                }
+              }
+            }
+            """);
+
+        var loader = new YamlConfigLoader(_rootPath)
+            .RegisterTable<int, MonsterNestedConfigStub>("monster", "monster", "schemas/monster.schema.json",
+                static config => config.Id);
+        var registry = new ConfigRegistry();
+
+        var exception = Assert.ThrowsAsync<ConfigLoadException>(async () => await loader.LoadAsync(registry));
+
+        Assert.Multiple(() =>
+        {
+            Assert.That(exception, Is.Not.Null);
+            Assert.That(exception!.Diagnostic.FailureKind, Is.EqualTo(ConfigLoadFailureKind.SchemaUnsupported));
+            Assert.That(exception.Message, Does.Contain("maxProperties"));
+            Assert.That(exception.Message, Does.Contain("non-negative integer"));
+            Assert.That(registry.Count, Is.EqualTo(0));
+        });
+    }

Based on learnings: 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.

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

In `@GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs` around lines 1360 -
1410, Add a symmetric test to cover the negative maxProperties path: create a
new test mirroring
LoadAsync_Should_Throw_When_Object_Property_Count_Constraint_Is_Not_NonNegative_Integer
that writes a schema with "maxProperties": -1 for the "reward" property,
registers the table via YamlConfigLoader, calls loader.LoadAsync(registry) and
asserts a ConfigLoadException is thrown with Diagnostic.FailureKind ==
ConfigLoadFailureKind.SchemaUnsupported, Diagnostic.DisplayPath == "reward", the
exception message contains "maxProperties" and "non-negative integer", and that
registry.Count remains 0; use the same helpers (CreateConfigFile,
CreateSchemaFile) and the same MonsterNestedConfigStub registration to keep the
case symmetric.
🧹 Nitpick comments (1)
tools/gframework-config-tool/src/configValidation.js (1)

644-667: 可选改进:考虑在解析阶段验证 schema 约束一致性。

当前实现未验证 minProperties > maxProperties 这类不一致的 schema 声明。如果 schema 声明了 minProperties: 5, maxProperties: 3,配置验证阶段可能会对同一对象同时报告最小和最大约束违规,导致诊断信息令人困惑。

可以考虑在 parseSchemaNode 中添加一致性检查,在解析阶段就抛出错误:

♻️ 可选的改进方案
 return {
     type: "object",
     displayPath,
     required,
     properties,
     minProperties: metadata.minProperties,
     maxProperties: metadata.maxProperties,
+    // 可在此处或调用方添加一致性检查
     title: metadata.title,
     description: metadata.description,
     defaultValue: metadata.defaultValue
 };

或在返回前添加:

if (typeof metadata.minProperties === "number" &&
    typeof metadata.maxProperties === "number" &&
    metadata.minProperties > metadata.maxProperties) {
    throw new Error(`Schema property '${displayPath}' declares minProperties (${metadata.minProperties}) greater than maxProperties (${metadata.maxProperties}).`);
}
🤖 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 644 - 667,
Add a consistency check in parseSchemaNode after computing metadata
(minProperties/maxProperties) and before returning the object: if both
metadata.minProperties and metadata.maxProperties are numbers and
metadata.minProperties > metadata.maxProperties, throw an Error that includes
displayPath and both values; this prevents downstream confusing validation by
failing fast when a schema declares minProperties greater than maxProperties.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs`:
- Around line 1360-1410: Add a symmetric test to cover the negative
maxProperties path: create a new test mirroring
LoadAsync_Should_Throw_When_Object_Property_Count_Constraint_Is_Not_NonNegative_Integer
that writes a schema with "maxProperties": -1 for the "reward" property,
registers the table via YamlConfigLoader, calls loader.LoadAsync(registry) and
asserts a ConfigLoadException is thrown with Diagnostic.FailureKind ==
ConfigLoadFailureKind.SchemaUnsupported, Diagnostic.DisplayPath == "reward", the
exception message contains "maxProperties" and "non-negative integer", and that
registry.Count remains 0; use the same helpers (CreateConfigFile,
CreateSchemaFile) and the same MonsterNestedConfigStub registration to keep the
case symmetric.

---

Nitpick comments:
In `@tools/gframework-config-tool/src/configValidation.js`:
- Around line 644-667: Add a consistency check in parseSchemaNode after
computing metadata (minProperties/maxProperties) and before returning the
object: if both metadata.minProperties and metadata.maxProperties are numbers
and metadata.minProperties > metadata.maxProperties, throw an Error that
includes displayPath and both values; this prevents downstream confusing
validation by failing fast when a schema declares minProperties greater than
maxProperties.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b0e1054f-2cbe-43ff-b5ae-dbc094b98ef6

📥 Commits

Reviewing files that changed from the base of the PR and between 06d048f and 7931b41.

📒 Files selected for processing (7)
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • tools/gframework-config-tool/src/configValidation.js
  • tools/gframework-config-tool/src/localization.js
  • tools/gframework-config-tool/test/configValidation.test.js
✅ Files skipped from review due to trivial changes (1)
  • tools/gframework-config-tool/test/configValidation.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • tools/gframework-config-tool/src/localization.js
  • GFramework.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 (3)
**/*.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> tags where applicable
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, or edge cases in C# code
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, 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
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 in C# files
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments in C# code
Follow standard C# naming: Types, methods, properties, events, and constants use PascalCase; Interfaces use I prefix; Parameters and locals use camelCase; Private fields use _camelCase
Use 4 spaces for i...

Files:

  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
**/*.Tests/**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.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
Public API changes must be covered by unit or integration tests
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
Regression fixes should include a test that fails before the fix and passes after it
Mirror the source structure in test projects whenever practical
Reuse existing architecture test infrastructure when relevant: ArchitectureTestsBase<T>, SyncTestArchitecture, AsyncTestArchitecture
Keep tests focused on observable behavior, not implementation trivia

Files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.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
When generator behavior changes intentionally, update snapshots together with the implementation in source generator tests

Files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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.SourceGenerators/Config/SchemaConfigGenerator.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to **/*.SourceGenerators.Tests/**/*.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to **/*.SourceGenerators.Tests/**/*.cs : When generator behavior changes intentionally, update snapshots together with the implementation in source generator tests

Applied to files:

  • GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.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/Config/SchemaConfigGenerator.cs
  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
Learning: Applies to **/*.Tests/**/*.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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
  • GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs
📚 Learning: 2026-04-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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-09T12:37:37.585Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-09T12:37:37.585Z
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/YamlConfigLoaderTests.cs
🔇 Additional comments (12)
GFramework.Game.Tests/Config/YamlConfigLoaderTests.cs (2)

1251-1358: minProperties/maxProperties 运行时回归覆盖做得很好

这两组用例同时校验了 FailureKindDisplayPathRawValueregistry 不变性,回归信号很清晰。


1412-1465: minProperties > maxProperties 的反向约束回归用例有效

该用例把 SchemaUnsupported 与路径/消息断言串起来了,能稳定防回退。

GFramework.SourceGenerators/Config/SchemaConfigGenerator.cs (2)

223-223: required 改为大小写敏感匹配是正确收敛

这里改成 StringComparer.Ordinal 能避免生成器与运行时在字段名大小写上的契约分歧。


257-263: 对象约束文档链路已完整打通

minProperties / maxProperties 已从解析阶段进入 SchemaObjectSpec,并最终落到生成类型的 <remarks>,实现和文档输出一致。

Also applies to: 1881-1887, 2523-2533, 2679-2687

GFramework.SourceGenerators.Tests/Config/SchemaConfigGeneratorTests.cs (1)

317-357: 新增大小写敏感回归测试很到位

这个用例能直接锁定 required 名称比较语义,和本次生成器行为调整保持一致。

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

23-26: LGTM!

JSDoc 返回类型正确更新,新增了 minPropertiesmaxProperties 可选字段。


644-645: LGTM!

解析逻辑正确使用 normalizeSchemaNonNegativeInteger,与 minItems/maxItems 等同类约束的处理方式一致。

Also applies to: 666-667


970-974: LGTM!

属性计数逻辑已正确修复,使用 yamlNode.map.size 获取去重后的属性数量,与运行时验证器行为保持一致。


1089-1107: LGTM!

消息本地化路由逻辑清晰,将对象相关的验证消息委托给专用格式化函数,提升了代码的可维护性。


1194-1246: LGTM!

格式化辅助函数实现完善:

  • 正确区分根对象与嵌套对象场景
  • 中英文消息表述准确
  • mode 参数清晰区分最小/最大约束

1881-1882: LGTM!

SchemaNode 类型定义正确更新,与实现保持一致。


1005-1026: 验证逻辑完全正确,无需进一步修改。

minPropertiesmaxProperties 验证逻辑实现正确,与其他约束检查风格一致。必要的消息键 ValidationMessageKeys.minPropertiesViolationValidationMessageKeys.maxPropertiesViolation 均已在 localizationKeys.js 中正确定义。

- 验证 YAML 文件扫描和注册功能
- 测试配置表注册选项对象支持
- 验证空选项对象异常处理
- 测试配置目录不存在时的错误处理
- 验证部分加载失败时的回滚机制
- 测试非法 YAML 文件的错误处理
- 验证 schema 校验功能包括必填字段检查
- 测试类型不匹配的字段校验
- 验证标量 enum 限制校验
- 测试数值范围约束校验包括最小值最大值
- 验证数值特殊约束如 exclusiveMinimum/exclusiveMaximum
- 测试 multipleOf 约束校验
- 验证大数值和科学计数法处理
- 测试字符串长度和正则模式校验
- 验证数组元素数量和唯一性校验
- 测试未知字段检测
- 验证嵌套对象和对象属性数量校验
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 10, 2026
Comment thread tools/gframework-config-tool/src/localizationKeys.js
- 实现配置架构解析器,支持对象、数组和标量类型的递归解析
- 添加 YAML 配置文件解析和注释提取功能
- 实现配置验证诊断系统,支持多种数据类型的校验
- 添加表单更新应用功能,支持标量和数组值的批量编辑
- 实现配置示例生成功能,包含架构描述作为 YAML 注释
- 添加国际化支持,提供中英文验证消息本地化
- 实现精确十进制运算,确保数值约束验证的准确性
- 添加批处理数组值解析和枚举值标准化功能
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