Skip to content

Fix/analyzer warning reduction batch#301

Merged
GeWuYou merged 10 commits into
mainfrom
fix/analyzer-warning-reduction-batch
Apr 29, 2026
Merged

Fix/analyzer warning reduction batch#301
GeWuYou merged 10 commits into
mainfrom
fix/analyzer-warning-reduction-batch

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

发布说明

  • 代码质量改进

    • 强化异步与并发处理,提升稳定性与性能
    • 减少静态分析告警,改善整体可维护性
  • 配置架构增强

    • 新增并丰富 YAML 配置模型与约束类型,支持更细粒度验证
    • 优化模式验证流程与错误诊断,防止不受控的正则耗时
  • 测试覆盖

    • 扩展中介器及 YAML 配置相关契约与集成测试,提升回归保护性

GeWuYou added 7 commits April 29, 2026 08:16
- 优化 Mediator 架构集成测试的 helper 类型作用域,消除文件名与类型名警告

- 补充异步测试路径的 ConfigureAwait(false),满足 analyzer 要求

- 更新测试集合暴露类型为只读或抽象集合,保留行为不变
- 修复 Mediator 高级测试中的异步等待告警

- 修复 验证请求异常参数名告警

- 优化 测试辅助类型区域的文件名告警处理
- 优化测试 helper 类型作用域以消除文件名匹配告警

- 补充异步等待 ConfigureAwait(false) 以满足 analyzer 约束

- 调整集合抽象、字符串比较器和异常参数名用法
- 修复 schema 正则校验缺少超时边界导致的 analyzer 风险

- 更新字符串等值比较为 ordinal 语义

- 补充 warning reduction 批处理恢复状态与验证结果
- 重构 dependentRequired 与 dependentSchemas 的单项解析流程

- 重构 allOf 与条件 schema 的分支解析流程

- 优化 object-focused 内联 schema 的 properties 与 required 校验拆分
- 拆分 schema model 类型到独立同名文件

- 清理 schema 校验模型的文件命名 analyzer 告警

- 更新 warning reduction 批处理收口状态
- 重构 YamlConfigSchemaValidator 的长方法为语义化 helper,清理剩余 MA0051 warning
- 修复 条件分支 helper 的字符串比较方式,避免新增 MA0006 warning
- 更新 analyzer warning reduction 跟踪与 trace,记录仓库根 clean build 已归零
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@GeWuYou has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 18 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7adb7d1e-a893-4bf5-82f6-7dbd7ee0e4bd

📥 Commits

Reviewing files that changed from the base of the PR and between f5f2c25 and 0ad2ed1.

📒 Files selected for processing (19)
  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
  • GFramework.Game/Config/YamlConfigAllowedValue.cs
  • GFramework.Game/Config/YamlConfigConstantValue.cs
  • GFramework.Game/Config/YamlConfigSchemaPropertyType.cs
  • GFramework.Game/Config/YamlConfigStringFormatKind.cs
  • GFramework.Game/GFramework.Game.csproj
  • ai-plan/public/README.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/todos/analyzer-warning-reduction-history-rp001.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/todos/analyzer-warning-reduction-history-rp002-rp041.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/todos/analyzer-warning-reduction-history-rp042-rp048.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/todos/analyzer-warning-reduction-history-rp074-rp078.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/traces/analyzer-warning-reduction-history-rp001.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/traces/analyzer-warning-reduction-history-rp002-rp041.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/traces/analyzer-warning-reduction-history-rp042-rp048.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/traces/analyzer-warning-reduction-history-rp062-rp071.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/traces/analyzer-warning-reduction-history-rp073-rp078.md
  • ai-plan/public/archive/analyzer-warning-reduction/archive/traces/analyzer-warning-reduction-history-rp083-rp088.md
  • ai-plan/public/archive/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
  • ai-plan/public/archive/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
📝 Walkthrough

Walkthrough

本次变更为 CQRS 测试统一添加 .ConfigureAwait(false),重构并扩展 YAML 配置运行时模型(新增多种 YamlConfig* 类型)与验证器(拆分为多个辅助方法、添加正则超时等),并增加相应单元测试与分析器跟踪文档更新。

Changes

Cohort / File(s) Summary
CQRS 测试异步改进
GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs, GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs, GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
在所有测试异步调用处一致追加 .ConfigureAwait(false),修正若干阻塞等待为异步 Task.Delay(...).ConfigureAwait(false),调整测试 helper 类型/可见性与共享状态原子化访问。
YAML 配置核心模型
GFramework.Game/Config/YamlConfigSchema.cs, GFramework.Game/Config/YamlConfigSchemaNode.cs, GFramework.Game/Config/YamlConfigSchemaPropertyType.cs
新增核心 schema 与节点模型,统一对象/数组/标量节点表示、公开只读属性及工厂/变更方法;添加属性类型枚举。
YAML 配置约束与值模型
GFramework.Game/Config/YamlConfigNumericConstraints.cs, YamlConfigStringConstraints.cs, YamlConfigArrayConstraints.cs, YamlConfigArrayContainsConstraints.cs, YamlConfigObjectConstraints.cs, YamlConfigScalarConstraints.cs, YamlConfigAllowedValue.cs, YamlConfigConstantValue.cs
新增数值/字符串/数组/对象/标量约束容器与允许值/常量表示类,均在构造函数中验证不变量并通过只读属性暴露数据。
YAML 字符串格式与引用
GFramework.Game/Config/YamlConfigStringFormatConstraint.cs, YamlConfigStringFormatKind.cs, YamlConfigReferenceUsage.cs
新增字符串格式约束与格式枚举,以及引用使用追踪类型(包含诊断展示路径)。
架构验证器重构
GFramework.Game/Config/YamlConfigSchemaValidator.cs, GFramework.Game/Config/YamlConfigSchemaValidator.ObjectKeywords.cs
拆分并重构验证逻辑:引入 1s 正则超时,按节点类型分派解析,提取对象关键字/依赖/allOf/条件/数值/字符串等专用私有解析器,移除内嵌模型定义(模型移至独立文件)。
单元测试与追踪文档
GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs, ai-plan/public/analyzer-warning-reduction/.../analyzer-warning-reduction-tracking.md, ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
新增模型契约单元测试覆盖构造器不变量与集合复制语义;更新分析器警告跟踪到新阶段并记录本次改动与验证策略。

Estimated code review effort

🎯 4 (复杂) | ⏱️ ~60 分钟

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.03% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Fix/analyzer warning reduction batch" directly relates to the PR's main objective of reducing analyzer warnings across YAML configuration models and CQRS test classes through systematic refactoring.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/analyzer-warning-reduction-batch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 36 minutes and 18 seconds.

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

@github-actions

Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2169 2169 0 0 0 0 34.9s    ↓3.6s

Test Results

passed 2169 passed

Details

tests 2169 tests
clock 34.9s ↓3.6s
tool nunit
build CI - Build & Test arrow-right build-and-test link #1006
pull-request Fix/analyzer warning reduction batch link #301

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2152 0 4 4.7s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
ILogAppender_Flush_Should_Raise_OnFlushCompleted_Only_Once 46 45 1 2.17    ↓0.05
RegisterMigration_During_Cache_Rebuild_Should_Not_Leave_Stale_Type_Cache 53 52 1 1.89    ↓0.03
Run_Should_Assign_Globally_Unique_Reference_Metadata_Member_Names 54 53 1 1.85    ↓0.04
OnPhase_Should_Not_Throw_When_Registry_Not_Found 54 53 1 1.85    ↓0.04

build-and-test: Run #1006

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2169 2169 0 0 0 0 0 34.9s

🎉 All tests passed!

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 54 4.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 54 2.2s 2.4s
Generates_Scene_Behavior_Boilerplate 54 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 54 1.1s 1.1s
Append_ShouldNotBlock 54 1.0s 1.0s
Context_Caching_Should_Improve_Performance 54 781ms 791ms
PendingCount_ShouldReflectQueuedEntries 54 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 54 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 54 401ms 402ms
Generates_Precise_Assembly_Type_Lookups_For_Inaccessible_External_Protected_Types 54 324ms 354ms

± Comparison with run #1005 at 1c48866 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 54 runs.

Github Test Reporter by CTRF 💚

@github-actions

github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
⚠️ CSHARP dotnet-format yes 1 no 5.71s
✅ REPOSITORY gitleaks yes no no 7.69s
✅ REPOSITORY trufflehog yes no no 6.67s

Detailed Issues

⚠️ CSHARP / dotnet-format - 1 error
Welcome to .NET 9.0!
---------------------
SDK Version: 9.0.114

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception: System.Exception: Restore operation failed.
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
   at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR refactors the YAML schema validator into a cleaner node-tree model (YamlConfigSchemaNode), adds new constraint types (string format, pattern, multipleOf, uniqueItems, contains, dependentRequired, dependentSchemas, allOf, if/then/else), and introduces regex timeouts to prevent catastrophic backtracking.

  • P1 — Unhandled RegexMatchTimeoutException: PatternRegex.IsMatch(rawValue) in ValidateStringScalarConstraints (line 2922) can throw RegexMatchTimeoutException when the 1-second timeout fires on adversarial YAML input. TryMatchSchemaNode's catch block only filters ConfigLoadException, so the timeout propagates as an unhandled exception instead of being translated into a diagnostic error message — the opposite of the PR's stated goal of preventing uncontrolled regex hang.

Confidence Score: 4/5

Safe to merge after the RegexMatchTimeoutException handling gap is addressed.

One P1 finding: the regex timeout exception is not caught in the string-constraint validation path, meaning adversarial YAML input could surface a raw uncaught exception instead of a clean diagnostic. All other changes (new node model, new constraint types, test coverage) look correct and well-structured.

GFramework.Game/Config/YamlConfigSchemaValidator.cs — specifically the ValidateStringScalarConstraints method around line 2922.

Important Files Changed

Filename Overview
GFramework.Game/Config/YamlConfigSchemaValidator.cs Major refactor adding regex timeouts, pattern constraints, format validation, and complex schema keywords (allOf, dependentSchemas, if/then/else). RegexMatchTimeoutException is not caught when pattern matching times out on YAML values.
GFramework.Game/Config/YamlConfigSchemaNode.cs New internal node model cleanly separating NodeChildren and NodeValidation sub-records; immutable wither methods are well-structured.
GFramework.Game/Config/YamlConfigSchemaValidator.ObjectKeywords.cs Partial class adding object-keyword parsing (dependentRequired, dependentSchemas, allOf, if/then/else). Logic is consistent and well-guarded.
GFramework.Game/Config/YamlConfigStringConstraints.cs New immutable record for string constraints; correct paired-null guard for pattern/patternRegex.
GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs New test file covering contract behavior of new YAML config model classes; good regression coverage.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[LoadAsync / Load] --> B[ParseLoadedSchema]
    B --> C[ParseNode]
    C --> D{type?}
    D -->|object| E[ParseObjectNode\nParseObjectConstraints]
    D -->|array| F[ParseArrayNode\nParseArrayConstraints]
    D -->|scalar| G[CreateScalarNode\nParseScalarConstraints]
    E --> H[dependentRequired\ndependentSchemas\nallOf\nif/then/else]
    F --> I[minItems/maxItems\nuniqueItems\ncontains]
    G --> J[min/maxLength\npattern\u2190compiled Regex\nformat\nnumeric bounds]
    K[Validate / ValidateAndCollectReferences] --> L[ValidateNode]
    L --> M{NodeType}
    M -->|Object| N[ValidateObjectNode\nValidateObjectConstraints]
    M -->|Array| O[ValidateArrayNode\nValidateArrayConstraints]
    M -->|Scalar| P[ValidateScalarNode\nValidateStringScalarConstraints]
    N --> Q[TryMatchSchemaNode\nfor dependentSchemas/allOf/if-then-else]
    O --> Q
    P --> R[PatternRegex.IsMatch\nRegexMatchTimeoutException not caught]
    Q -->|catches ConfigLoadException only| S[return false]
    R -->|timeout fires| T[Unhandled exception]
Loading

Comments Outside Diff (1)

  1. GFramework.Game/Config/YamlConfigSchemaValidator.cs, line 2922-2934 (link)

    P1 RegexMatchTimeoutException not caught in pattern validation path

    PatternRegex.IsMatch(rawValue) at line 2922 can throw RegexMatchTimeoutException when the 1-second timeout fires on adversarial input. TryMatchSchemaNode's catch block only filters ConfigLoadException, so the timeout propagates as an unhandled exception instead of being translated into a diagnostic ConfigLoadException. The PR explicitly adds regex timeouts to prevent runaway matching, but the timeout exception itself escapes both the trial-match path and the direct validation path.

    if (constraints.PatternRegex is not null)
    {
        bool isMatch;
        try
        {
            isMatch = constraints.PatternRegex.IsMatch(rawValue);
        }
        catch (RegexMatchTimeoutException)
        {
            throw ConfigLoadExceptionFactory.Create(
                ConfigLoadFailureKind.ConstraintViolation,
                tableName,
                $"Property '{displayPath}' in config file '{yamlPath}' pattern '{constraints.Pattern}' timed out while matching value '{rawValue}'.",
                yamlPath: yamlPath,
                schemaPath: schemaNode.SchemaPathHint,
                displayPath: GetDiagnosticPath(displayPath),
                rawValue: rawValue);
        }
        if (!isMatch)
        {
            throw ConfigLoadExceptionFactory.Create(...);
        }
    }
    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: GFramework.Game/Config/YamlConfigSchemaValidator.cs
    Line: 2922-2934
    
    Comment:
    **`RegexMatchTimeoutException` not caught in pattern validation path**
    
    `PatternRegex.IsMatch(rawValue)` at line 2922 can throw `RegexMatchTimeoutException` when the 1-second timeout fires on adversarial input. `TryMatchSchemaNode`'s catch block only filters `ConfigLoadException`, so the timeout propagates as an unhandled exception instead of being translated into a diagnostic `ConfigLoadException`. The PR explicitly adds regex timeouts to prevent runaway matching, but the timeout exception itself escapes both the trial-match path and the direct validation path.
    
    ```csharp
    if (constraints.PatternRegex is not null)
    {
        bool isMatch;
        try
        {
            isMatch = constraints.PatternRegex.IsMatch(rawValue);
        }
        catch (RegexMatchTimeoutException)
        {
            throw ConfigLoadExceptionFactory.Create(
                ConfigLoadFailureKind.ConstraintViolation,
                tableName,
                $"Property '{displayPath}' in config file '{yamlPath}' pattern '{constraints.Pattern}' timed out while matching value '{rawValue}'.",
                yamlPath: yamlPath,
                schemaPath: schemaNode.SchemaPathHint,
                displayPath: GetDiagnosticPath(displayPath),
                rawValue: rawValue);
        }
        if (!isMatch)
        {
            throw ConfigLoadExceptionFactory.Create(...);
        }
    }
    ```
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: GFramework.Game/Config/YamlConfigSchemaValidator.cs
Line: 2922-2934

Comment:
**`RegexMatchTimeoutException` not caught in pattern validation path**

`PatternRegex.IsMatch(rawValue)` at line 2922 can throw `RegexMatchTimeoutException` when the 1-second timeout fires on adversarial input. `TryMatchSchemaNode`'s catch block only filters `ConfigLoadException`, so the timeout propagates as an unhandled exception instead of being translated into a diagnostic `ConfigLoadException`. The PR explicitly adds regex timeouts to prevent runaway matching, but the timeout exception itself escapes both the trial-match path and the direct validation path.

```csharp
if (constraints.PatternRegex is not null)
{
    bool isMatch;
    try
    {
        isMatch = constraints.PatternRegex.IsMatch(rawValue);
    }
    catch (RegexMatchTimeoutException)
    {
        throw ConfigLoadExceptionFactory.Create(
            ConfigLoadFailureKind.ConstraintViolation,
            tableName,
            $"Property '{displayPath}' in config file '{yamlPath}' pattern '{constraints.Pattern}' timed out while matching value '{rawValue}'.",
            yamlPath: yamlPath,
            schemaPath: schemaNode.SchemaPathHint,
            displayPath: GetDiagnosticPath(displayPath),
            rawValue: rawValue);
    }
    if (!isMatch)
    {
        throw ConfigLoadExceptionFactory.Create(...);
    }
}
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: GFramework.Game/Config/YamlConfigSchemaValidator.cs
Line: 2186-2203

Comment:
**Regex compiled twice per `pattern` field**

`TryParsePatternConstraint` (around line 2189) constructs a temporary `Regex` only to validate the pattern syntax, then discards it. A second `Regex` is compiled and stored in `CreateStringScalarConstraints` (around line 2659). For schemas with many `pattern` constraints, this doubles compilation cost at load time. The simplest fix is to return the compiled regex directly from `TryParsePatternConstraint` instead of the raw string, letting `CreateStringScalarConstraints` consume it directly.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (4): Last reviewed commit: "fix(game): 修复空对象配置比较键并归档 warning reducti..." | Re-trigger Greptile

Comment thread GFramework.Game/Config/YamlConfigAllowedValue.cs
Comment thread GFramework.Game/Config/YamlConfigReferenceUsage.cs

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

🧹 Nitpick comments (11)
GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs (3)

402-419: 静态缓存字典缺少线程安全保护

_cache 是一个静态字典,在并发访问时可能会出现问题。虽然当前测试是顺序执行的,但如果测试并行运行或重用此处理器,可能会导致意外行为。

此外,这里也使用了 Task.Delay().Wait() 阻塞调用,建议与上一个处理器一样改为 async 方法。

💡 建议的改进
 public sealed class TestCachedRequestHandler : IRequestHandler<TestCachedRequest, int>
 {
-    private static readonly Dictionary<int, int> _cache = new();
+    private static readonly ConcurrentDictionary<int, int> _cache = new();

-    public ValueTask<int> Handle(TestCachedRequest request, CancellationToken cancellationToken)
+    public async ValueTask<int> Handle(TestCachedRequest request, CancellationToken cancellationToken)
     {
         if (_cache.TryGetValue(request.Id, out var cachedValue))
         {
-            return new ValueTask<int>(cachedValue);
+            return cachedValue;
         }

         // 模拟处理时间
-        Task.Delay(10, cancellationToken).Wait(cancellationToken);
-        var newValue = request.Id;
-        _cache[request.Id] = newValue;
-        return new ValueTask<int>(newValue);
+        await Task.Delay(10, cancellationToken).ConfigureAwait(false);
+        _cache[request.Id] = request.Id;
+        return request.Id;
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`
around lines 402 - 419, Replace the non-thread-safe static Dictionary and
blocking Wait in TestCachedRequestHandler: change the static field _cache to a
thread-safe collection (e.g., ConcurrentDictionary<int,int>) and make the Handle
method async so you can await Task.Delay instead of calling
Task.Delay(...).Wait(...); update references inside Handle to use the concurrent
dictionary's TryGetValue or GetOrAdd patterns to safely read/update cache.

392-400: Task.Delay().Wait() 是阻塞调用

使用 Task.Delay(5, cancellationToken).Wait(cancellationToken) 会阻塞当前线程。虽然在测试代码中模拟延迟是可接受的,但更好的做法是将方法改为 async 并使用 await

💡 建议的改进
 public sealed class TestUncachedRequestHandler : IRequestHandler<TestUncachedRequest, int>
 {
-    public ValueTask<int> Handle(TestUncachedRequest request, CancellationToken cancellationToken)
+    public async ValueTask<int> Handle(TestUncachedRequest request, CancellationToken cancellationToken)
     {
         // 模拟一些处理时间
-        Task.Delay(5, cancellationToken).Wait(cancellationToken);
-        return new ValueTask<int>(request.Id);
+        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
+        return request.Id;
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`
around lines 392 - 400, The Handle implementation in TestUncachedRequestHandler
blocks the thread by calling Task.Delay(...).Wait(...); change the method to be
async and await the delay instead: make Handle an async ValueTask<int> (or
Task<int> if preferred), replace Task.Delay(5,
cancellationToken).Wait(cancellationToken) with await Task.Delay(5,
cancellationToken), and return request.Id directly; this preserves cancellation
support and avoids blocking in TestUncachedRequestHandler.Handle.

329-343: TestNestedRequestHandler 中存在冗余的条件逻辑

当前实现中,无论 request.Depth >= 1 条件是否成立,都返回相同的结果字符串。这使得 if 块变得冗余。

💡 建议简化代码
 public sealed class TestNestedRequestHandler : IRequestHandler<TestNestedRequest, string>
 {
     public ValueTask<string> Handle(TestNestedRequest request, CancellationToken cancellationToken)
     {
         TestNestedRequestHandler2.ExecutionCount++;
-
-        if (request.Depth >= 1) // 简化条件
-        {
-            // 模拟嵌套调用
-            return new ValueTask<string>($"Nested execution completed at depth {request.Depth}");
-        }
-
+        // 模拟嵌套调用
         return new ValueTask<string>($"Nested execution completed at depth {request.Depth}");
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`
around lines 329 - 343, The Handle method in TestNestedRequestHandler contains a
redundant if that returns the same string regardless of request.Depth; remove
the conditional and simply increment TestNestedRequestHandler2.ExecutionCount
then return the result once (keep the ValueTask<string> return and use
request.Depth in the interpolated message) so the behavior is unchanged but the
unnecessary branching is eliminated.
GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs (1)

239-240: 建议为 MA0048 抑制添加注释说明

根据编码规范,当添加分析器抑制时,如果原因不明显,应在代码注释中说明理由。建议添加简短注释解释为什么需要抑制此规则。

💡 建议的改进
-#pragma warning disable MA0048
+#pragma warning disable MA0048 // File name must match type name - test helper classes are intentionally co-located
 `#region` Advanced Test Classes

As per coding guidelines: "When adding C# analyzers or suppressions, keep them minimal and justify them in code comments if the reason is not obvious"

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

In `@GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs` around lines
239 - 240, Add a short explanatory comment immediately above the pragma
disabling MA0048 (the line with "#pragma warning disable MA0048" in
MediatorAdvancedFeaturesTests.cs / the "Advanced Test Classes" region) that
states why the analyzer is suppressed for these test classes (e.g., tests
require internal access or naming prevents refactor), so the suppression is
justified and discoverable; keep the comment concise and specific to MA0048 and
the Advanced Test Classes region.
GFramework.Game/Config/YamlConfigConstantValue.cs (1)

14-20: 建议同时拒绝空白 comparableValue,避免产生“空比较键”

displayValue 已做空白校验,但 comparableValue 目前允许空白字符串,后续匹配语义可能变得不明确。

可选修改
 public YamlConfigConstantValue(string comparableValue, string displayValue)
 {
-    ArgumentNullException.ThrowIfNull(comparableValue);
+    ArgumentException.ThrowIfNullOrWhiteSpace(comparableValue);
     ArgumentException.ThrowIfNullOrWhiteSpace(displayValue);

     ComparableValue = comparableValue;
     DisplayValue = displayValue;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game/Config/YamlConfigConstantValue.cs` around lines 14 - 20, The
constructor YamlConfigConstantValue currently only null-checks comparableValue
but allows empty/whitespace, so change the validation to reject blank
comparableValue as well (use ArgumentException.ThrowIfNullOrWhiteSpace or
equivalent) to mirror the displayValue check and ensure ComparableValue is never
an empty/whitespace string; keep setting ComparableValue and DisplayValue as
before.
GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs (1)

15-25: 建议在构造时校验 minContains/maxContains 边界,防止无效约束进入模型

当前允许负值和 minContains > maxContains,会把非法状态带到后续校验流程。

可选修改
 public YamlConfigArrayContainsConstraints(
     YamlConfigSchemaNode containsNode,
     int? minContains,
     int? maxContains)
 {
     ArgumentNullException.ThrowIfNull(containsNode);
+    if (minContains.HasValue && minContains.Value < 0)
+    {
+        throw new ArgumentOutOfRangeException(nameof(minContains));
+    }
+    if (maxContains.HasValue && maxContains.Value < 0)
+    {
+        throw new ArgumentOutOfRangeException(nameof(maxContains));
+    }
+    if (minContains.HasValue && maxContains.HasValue && minContains.Value > maxContains.Value)
+    {
+        throw new ArgumentException("minContains 不能大于 maxContains。");
+    }

     ContainsNode = containsNode;
     MinContains = minContains;
     MaxContains = maxContains;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs` around lines 15
- 25, The constructor of YamlConfigArrayContainsConstraints allows negative
values and minContains > maxContains; add validation in the constructor
(YamlConfigArrayContainsConstraints) to throw when MinContains or MaxContains
are negative and to throw when both MinContains and MaxContains are non-null but
MinContains > MaxContains; use ArgumentOutOfRangeException for negative values
and ArgumentException for the min>max case, and keep assigning ContainsNode,
MinContains and MaxContains only after validation.
GFramework.Game/Config/YamlConfigArrayConstraints.cs (1)

16-26: 建议约束 minItems/maxItems 的取值范围与大小关系

建议在构造函数内阻止负数和 minItems > maxItems,避免出现不可解释的数组约束状态。

可选修改
 public YamlConfigArrayConstraints(
     int? minItems,
     int? maxItems,
     bool uniqueItems,
     YamlConfigArrayContainsConstraints? containsConstraints)
 {
+    if (minItems.HasValue && minItems.Value < 0)
+    {
+        throw new ArgumentOutOfRangeException(nameof(minItems));
+    }
+    if (maxItems.HasValue && maxItems.Value < 0)
+    {
+        throw new ArgumentOutOfRangeException(nameof(maxItems));
+    }
+    if (minItems.HasValue && maxItems.HasValue && minItems.Value > maxItems.Value)
+    {
+        throw new ArgumentException("minItems 不能大于 maxItems。");
+    }
+
     MinItems = minItems;
     MaxItems = maxItems;
     UniqueItems = uniqueItems;
     ContainsConstraints = containsConstraints;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game/Config/YamlConfigArrayConstraints.cs` around lines 16 - 26, 在
YamlConfigArrayConstraints 构造函数中添加对 minItems 和 maxItems 的验证:如果 minItems 或
maxItems 为负值则抛出 ArgumentOutOfRangeException(或类似异常),并且当两者都不为 null 时确保 minItems <=
maxItems,否则抛出 ArgumentException;更新构造函数(YamlConfigArrayConstraints(...))在赋值
MinItems/MaxItems 之前进行这些检查,以避免产生不可解释的数组约束状态(参照
MinItems、MaxItems、UniqueItems、ContainsConstraints 字段/属性来定位修改点)。
GFramework.Game/Config/YamlConfigObjectConstraints.cs (1)

18-32: 建议补充 minProperties/maxProperties 的合法性校验

建议在构造时拦截负数与 minProperties > maxProperties,避免对象约束进入无效状态。

可选修改
 public YamlConfigObjectConstraints(
     int? minProperties,
     int? maxProperties,
     IReadOnlyDictionary<string, IReadOnlyList<string>>? dependentRequired,
     IReadOnlyDictionary<string, YamlConfigSchemaNode>? dependentSchemas,
     IReadOnlyList<YamlConfigSchemaNode>? allOfSchemas,
     YamlConfigConditionalSchemas? conditionalSchemas)
 {
+    if (minProperties.HasValue && minProperties.Value < 0)
+    {
+        throw new ArgumentOutOfRangeException(nameof(minProperties));
+    }
+    if (maxProperties.HasValue && maxProperties.Value < 0)
+    {
+        throw new ArgumentOutOfRangeException(nameof(maxProperties));
+    }
+    if (minProperties.HasValue && maxProperties.HasValue && minProperties.Value > maxProperties.Value)
+    {
+        throw new ArgumentException("minProperties 不能大于 maxProperties。");
+    }
+
     MinProperties = minProperties;
     MaxProperties = maxProperties;
     DependentRequired = dependentRequired;
     DependentSchemas = dependentSchemas;
     AllOfSchemas = allOfSchemas;
     ConditionalSchemas = conditionalSchemas;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game/Config/YamlConfigObjectConstraints.cs` around lines 18 - 32,
在 YamlConfigObjectConstraints 的构造函数中添加对 MinProperties/MaxProperties 的合法性校验:确保传入的
minProperties 和 maxProperties 非负且当两者都不为 null 时满足 minProperties <=
maxProperties,否则在构造时抛出合适的异常(如 ArgumentOutOfRangeException 或
ArgumentException);更新构造函数(YamlConfigObjectConstraints(...))以在赋值前执行这些检查并保留现有属性赋值逻辑(MinProperties、MaxProperties、DependentRequired、DependentSchemas、AllOfSchemas、ConditionalSchemas)。
GFramework.Game/Config/YamlConfigStringConstraints.cs (1)

20-31: 建议在构造器中强制 PatternPatternRegex 成对一致

这两个字段语义绑定很强,建议在模型层加约束,避免后续调用方传出不一致状态。

可选修改
 public YamlConfigStringConstraints(
     int? minLength,
     int? maxLength,
     string? pattern,
     Regex? patternRegex,
     YamlConfigStringFormatConstraint? formatConstraint)
 {
+    if ((pattern is null) != (patternRegex is null))
+    {
+        throw new ArgumentException("pattern 与 patternRegex 需要同时为空或同时非空。");
+    }
+
     MinLength = minLength;
     MaxLength = maxLength;
     Pattern = pattern;
     PatternRegex = patternRegex;
     FormatConstraint = formatConstraint;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game/Config/YamlConfigStringConstraints.cs` around lines 20 - 31,
The constructor for YamlConfigStringConstraints allows Pattern and PatternRegex
to be set inconsistently; enforce they are paired by validating in the
constructor (either both null or both non-null) or by deriving one from the
other (e.g., if Pattern is provided and PatternRegex is null, compile Pattern
into PatternRegex); if inconsistency is detected throw an ArgumentException with
a clear message. Update the YamlConfigStringConstraints constructor to perform
this validation/derivation referencing the constructor itself and the Pattern
and PatternRegex properties so callers cannot create an inconsistent instance.
GFramework.Game/Config/YamlConfigSchema.cs (1)

15-27: 建议对 referencedTableNames 做一次拷贝,强化不可变语义

当前是直接引用传入集合;若未来调用方传入可变集合并在外部继续修改,会影响模型内部状态。

可选修改
     SchemaPath = schemaPath;
     RootNode = rootNode;
-    ReferencedTableNames = referencedTableNames;
+    ReferencedTableNames = referencedTableNames.ToArray();
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game/Config/YamlConfigSchema.cs` around lines 15 - 27, The
constructor YamlConfigSchema currently assigns the passed referencedTableNames
directly to the ReferencedTableNames property; make a defensive copy instead to
preserve immutability of the model (e.g., create a new list/collection from
referencedTableNames and assign a read-only wrapper or an immutable collection).
Update the YamlConfigSchema constructor to set ReferencedTableNames to a copied,
read-only/immutable collection (created from the referencedTableNames parameter)
rather than storing the original reference.
GFramework.Game/Config/YamlConfigSchemaNode.cs (1)

283-290: 移除未使用的 NodeValidation.None 静态属性。

代码搜索确认 NodeValidation.None 在整个仓库中未被引用。此静态属性未提供任何功能,应删除以避免死代码。

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

In `@GFramework.Game/Config/YamlConfigSchemaNode.cs` around lines 283 - 290,
Remove the unused static property NodeValidation.None by deleting its
declaration (the public static NodeValidation None { get; } = new(...)
initializer) from the NodeValidation type; ensure no remaining references to
NodeValidation.None exist (search the repo), run the build/tests to confirm
nothing breaks, and remove any related XML docs or using directives made
redundant by its deletion.
🤖 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.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`:
- Around line 434-441: The handler TestStateModificationRequestHandler's Handle
method mutates request.SharedState.Counter using a non-atomic "Counter +=
request.Increment" which introduces a race under concurrency; change the
mutation to an atomic update (e.g., use Interlocked.Add(ref
request.SharedState.Counter, request.Increment) or protect the operation with a
dedicated lock) so increments can't be lost; apply the same fix to the other
similar handler referenced by the review (the handler at the second occurrence
where Counter is updated) so both use atomic updates or locking around
SharedState.Counter.

In `@GFramework.Game/Config/YamlConfigAllowedValue.cs`:
- Around line 9-21: The constructor YamlConfigAllowedValue(string
comparableValue, string displayValue) throws ArgumentNullException for
comparableValue and ArgumentException (via ThrowIfNullOrWhiteSpace) for
displayValue but the XML docs lack <exception> tags; update the XML
documentation on the YamlConfigAllowedValue ctor to add <exception
cref="System.ArgumentNullException"> describing when comparableValue is null and
<exception cref="System.ArgumentException"> describing when displayValue is null
or whitespace, keeping the existing <summary> and <param> tags for
comparableValue and displayValue.

In `@GFramework.Game/Config/YamlConfigConditionalSchemas.cs`:
- Around line 9-20: The constructor YamlConfigConditionalSchemas currently
throws ArgumentNullException for a null ifSchema but the XML doc comments lack
an <exception> tag; update the XML documentation for the constructor to include
an <exception cref="System.ArgumentNullException"> describing that ifSchema is
null (and mention which parameter causes it), and ensure the existing <summary>
and <param name="ifSchema">, <param name="thenSchema">, <param
name="elseSchema"> remain accurate to match the thrown behavior in the
constructor.

In `@GFramework.Game/Config/YamlConfigSchemaPropertyType.cs`:
- Around line 6-37: Add the [GenerateEnumExtensions] attribute to the
YamlConfigSchemaPropertyType enum so code generation will produce the standard
enum extension methods; update the enum declaration to be annotated with
[GenerateEnumExtensions] (ensure the attribute's namespace is imported or
referenced, e.g., GenerateEnumExtensionsAttribute) and keep the enum name and
members unchanged so the generated extensions target
YamlConfigSchemaPropertyType.

In `@GFramework.Game/Config/YamlConfigStringFormatConstraint.cs`:
- Around line 9-22: The constructor YamlConfigStringFormatConstraint performs
argument validation on parameter schemaName and can throw ArgumentException;
update the XML documentation for the constructor
(YamlConfigStringFormatConstraint(string schemaName, YamlConfigStringFormatKind
kind)) to include an <exception> entry documenting that an ArgumentException is
thrown when schemaName is null, empty, or whitespace, and ensure the existing
<summary> and <param> tags remain accurate.

In `@GFramework.Game/Config/YamlConfigStringFormatKind.cs`:
- Around line 6-42: The enum YamlConfigStringFormatKind is missing the required
[GenerateEnumExtensions] attribute; add the [GenerateEnumExtensions] attribute
decoration to the YamlConfigStringFormatKind declaration so the enum extension
methods are generated consistently (apply the attribute directly above the
internal enum YamlConfigStringFormatKind definition).

---

Nitpick comments:
In `@GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs`:
- Around line 239-240: Add a short explanatory comment immediately above the
pragma disabling MA0048 (the line with "#pragma warning disable MA0048" in
MediatorAdvancedFeaturesTests.cs / the "Advanced Test Classes" region) that
states why the analyzer is suppressed for these test classes (e.g., tests
require internal access or naming prevents refactor), so the suppression is
justified and discoverable; keep the comment concise and specific to MA0048 and
the Advanced Test Classes region.

In `@GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`:
- Around line 402-419: Replace the non-thread-safe static Dictionary and
blocking Wait in TestCachedRequestHandler: change the static field _cache to a
thread-safe collection (e.g., ConcurrentDictionary<int,int>) and make the Handle
method async so you can await Task.Delay instead of calling
Task.Delay(...).Wait(...); update references inside Handle to use the concurrent
dictionary's TryGetValue or GetOrAdd patterns to safely read/update cache.
- Around line 392-400: The Handle implementation in TestUncachedRequestHandler
blocks the thread by calling Task.Delay(...).Wait(...); change the method to be
async and await the delay instead: make Handle an async ValueTask<int> (or
Task<int> if preferred), replace Task.Delay(5,
cancellationToken).Wait(cancellationToken) with await Task.Delay(5,
cancellationToken), and return request.Id directly; this preserves cancellation
support and avoids blocking in TestUncachedRequestHandler.Handle.
- Around line 329-343: The Handle method in TestNestedRequestHandler contains a
redundant if that returns the same string regardless of request.Depth; remove
the conditional and simply increment TestNestedRequestHandler2.ExecutionCount
then return the result once (keep the ValueTask<string> return and use
request.Depth in the interpolated message) so the behavior is unchanged but the
unnecessary branching is eliminated.

In `@GFramework.Game/Config/YamlConfigArrayConstraints.cs`:
- Around line 16-26: 在 YamlConfigArrayConstraints 构造函数中添加对 minItems 和 maxItems
的验证:如果 minItems 或 maxItems 为负值则抛出 ArgumentOutOfRangeException(或类似异常),并且当两者都不为
null 时确保 minItems <= maxItems,否则抛出
ArgumentException;更新构造函数(YamlConfigArrayConstraints(...))在赋值 MinItems/MaxItems
之前进行这些检查,以避免产生不可解释的数组约束状态(参照 MinItems、MaxItems、UniqueItems、ContainsConstraints
字段/属性来定位修改点)。

In `@GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs`:
- Around line 15-25: The constructor of YamlConfigArrayContainsConstraints
allows negative values and minContains > maxContains; add validation in the
constructor (YamlConfigArrayContainsConstraints) to throw when MinContains or
MaxContains are negative and to throw when both MinContains and MaxContains are
non-null but MinContains > MaxContains; use ArgumentOutOfRangeException for
negative values and ArgumentException for the min>max case, and keep assigning
ContainsNode, MinContains and MaxContains only after validation.

In `@GFramework.Game/Config/YamlConfigConstantValue.cs`:
- Around line 14-20: The constructor YamlConfigConstantValue currently only
null-checks comparableValue but allows empty/whitespace, so change the
validation to reject blank comparableValue as well (use
ArgumentException.ThrowIfNullOrWhiteSpace or equivalent) to mirror the
displayValue check and ensure ComparableValue is never an empty/whitespace
string; keep setting ComparableValue and DisplayValue as before.

In `@GFramework.Game/Config/YamlConfigObjectConstraints.cs`:
- Around line 18-32: 在 YamlConfigObjectConstraints 的构造函数中添加对
MinProperties/MaxProperties 的合法性校验:确保传入的 minProperties 和 maxProperties 非负且当两者都不为
null 时满足 minProperties <= maxProperties,否则在构造时抛出合适的异常(如
ArgumentOutOfRangeException 或
ArgumentException);更新构造函数(YamlConfigObjectConstraints(...))以在赋值前执行这些检查并保留现有属性赋值逻辑(MinProperties、MaxProperties、DependentRequired、DependentSchemas、AllOfSchemas、ConditionalSchemas)。

In `@GFramework.Game/Config/YamlConfigSchema.cs`:
- Around line 15-27: The constructor YamlConfigSchema currently assigns the
passed referencedTableNames directly to the ReferencedTableNames property; make
a defensive copy instead to preserve immutability of the model (e.g., create a
new list/collection from referencedTableNames and assign a read-only wrapper or
an immutable collection). Update the YamlConfigSchema constructor to set
ReferencedTableNames to a copied, read-only/immutable collection (created from
the referencedTableNames parameter) rather than storing the original reference.

In `@GFramework.Game/Config/YamlConfigSchemaNode.cs`:
- Around line 283-290: Remove the unused static property NodeValidation.None by
deleting its declaration (the public static NodeValidation None { get; } =
new(...) initializer) from the NodeValidation type; ensure no remaining
references to NodeValidation.None exist (search the repo), run the build/tests
to confirm nothing breaks, and remove any related XML docs or using directives
made redundant by its deletion.

In `@GFramework.Game/Config/YamlConfigStringConstraints.cs`:
- Around line 20-31: The constructor for YamlConfigStringConstraints allows
Pattern and PatternRegex to be set inconsistently; enforce they are paired by
validating in the constructor (either both null or both non-null) or by deriving
one from the other (e.g., if Pattern is provided and PatternRegex is null,
compile Pattern into PatternRegex); if inconsistency is detected throw an
ArgumentException with a clear message. Update the YamlConfigStringConstraints
constructor to perform this validation/derivation referencing the constructor
itself and the Pattern and PatternRegex properties so callers cannot create an
inconsistent instance.
🪄 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: ccecfb79-1bb5-42d9-ac1e-d47d675dccd3

📥 Commits

Reviewing files that changed from the base of the PR and between 0e32dab and 7da9859.

📒 Files selected for processing (22)
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
  • GFramework.Game/Config/YamlConfigAllowedValue.cs
  • GFramework.Game/Config/YamlConfigArrayConstraints.cs
  • GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs
  • GFramework.Game/Config/YamlConfigConditionalSchemas.cs
  • GFramework.Game/Config/YamlConfigConstantValue.cs
  • GFramework.Game/Config/YamlConfigNumericConstraints.cs
  • GFramework.Game/Config/YamlConfigObjectConstraints.cs
  • GFramework.Game/Config/YamlConfigReferenceUsage.cs
  • GFramework.Game/Config/YamlConfigScalarConstraints.cs
  • GFramework.Game/Config/YamlConfigSchema.cs
  • GFramework.Game/Config/YamlConfigSchemaNode.cs
  • GFramework.Game/Config/YamlConfigSchemaPropertyType.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.ObjectKeywords.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.Game/Config/YamlConfigStringConstraints.cs
  • GFramework.Game/Config/YamlConfigStringFormatConstraint.cs
  • GFramework.Game/Config/YamlConfigStringFormatKind.cs
  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (C#)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Build and Test
🧰 Additional context used
📓 Path-based instructions (3)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: Apply [Log] attribute for automatic logging field and logging helper method generation
Apply [Priority] attribute for automatic priority comparison implementation generation
Apply [GenerateEnumExtensions] attribute to generate enumeration extension capabilities
Apply [ContextAware] attribute to automatically implement IContextAware boilerplate logic

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, 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, interactions, why the abstraction exists, and when to use it
Generated logic and generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments in C# files
Follow standard C# naming: types/methods/properties/events/constants in PascalCase, interfaces with I prefix, parameters and locals in camelCase, private fields in _camelCase
Use 4 spaces for indentation in C# files; do not use tabs
Use Allman braces in C# files
Keep using directives at the top of C# files and sort them consistently
Prefer one primary type per C# file unless the surrounding project already uses a different local pattern
Keep...

Files:

  • GFramework.Game/Config/YamlConfigSchemaPropertyType.cs
  • GFramework.Game/Config/YamlConfigScalarConstraints.cs
  • GFramework.Game/Config/YamlConfigAllowedValue.cs
  • GFramework.Game/Config/YamlConfigStringFormatConstraint.cs
  • GFramework.Game/Config/YamlConfigStringFormatKind.cs
  • GFramework.Game/Config/YamlConfigNumericConstraints.cs
  • GFramework.Game/Config/YamlConfigConstantValue.cs
  • GFramework.Game/Config/YamlConfigReferenceUsage.cs
  • GFramework.Game/Config/YamlConfigConditionalSchemas.cs
  • GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs
  • GFramework.Game/Config/YamlConfigStringConstraints.cs
  • GFramework.Game/Config/YamlConfigSchemaNode.cs
  • GFramework.Game/Config/YamlConfigSchema.cs
  • GFramework.Game/Config/YamlConfigArrayConstraints.cs
  • GFramework.Game/Config/YamlConfigObjectConstraints.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.ObjectKeywords.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
ai-plan/public/*/traces/**

📄 CodeRabbit inference engine (AGENTS.md)

Contributors MUST maintain a matching execution trace under ai-plan/public/<topic>/traces/ for complex work, recording the current date, key decisions, validation milestones, and the immediate next step

Files:

  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
ai-plan/public/*/todos/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/public/*/todos/**: When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under ai-plan/public/<topic>/todos/ in the same change
Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point
Active tracking and trace files are recovery entrypoints, not append-only changelogs; they MUST stay concise enough for boot to locate the current recovery point quickly
Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely
When completed and validated stages begin to accumulate, contributors MUST archive their detailed history out of the active todos/ and traces/ entry files in the same change, keeping only the current recovery point, active facts, active risks, immediate next step, and pointers to archive files
When a task spans multiple commits or is likely to exceed a single agent context window, update both the recovery document and the trace at each meaningful milestone before pausing or handing work off
If subagents are used on a complex task, the main agent MUST capture the delegated scope and any accepted findings in the active recovery document or trace before continuing implementation

Files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
🧠 Learnings (15)
📚 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/YamlConfigSchemaPropertyType.cs
  • GFramework.Game/Config/YamlConfigScalarConstraints.cs
  • GFramework.Game/Config/YamlConfigAllowedValue.cs
  • GFramework.Game/Config/YamlConfigStringFormatConstraint.cs
  • GFramework.Game/Config/YamlConfigStringFormatKind.cs
  • GFramework.Game/Config/YamlConfigNumericConstraints.cs
  • GFramework.Game/Config/YamlConfigConstantValue.cs
  • GFramework.Game/Config/YamlConfigReferenceUsage.cs
  • GFramework.Game/Config/YamlConfigConditionalSchemas.cs
  • GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs
  • GFramework.Game/Config/YamlConfigStringConstraints.cs
  • GFramework.Game/Config/YamlConfigSchemaNode.cs
  • GFramework.Game/Config/YamlConfigSchema.cs
  • GFramework.Game/Config/YamlConfigArrayConstraints.cs
  • GFramework.Game/Config/YamlConfigObjectConstraints.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.ObjectKeywords.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
📚 Learning: 2026-04-17T11:35:08.762Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-17T11:35:08.762Z
Learning: Applies to **/Cqrs/**/*.cs : Use CQRS (Command Query Responsibility Segregation) pattern with the Cqrs naming entry point instead of the historical Mediator alias

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.cs : Public API changes must be covered by unit or integration tests in C#

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : When a public C# 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.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: When the goal is to inspect or reduce warnings, establish the warning baseline by running `dotnet clean` and then `dotnet build`, not repeated incremental builds

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under `ai-plan/public/<topic>/todos/` in the same change

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: For any multi-step refactor, migration, or cross-module task, contributors MUST create or adopt a dedicated recovery document under `ai-plan/public/<topic>/todos/` before making substantive code changes

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : When completed and validated stages begin to accumulate, contributors MUST archive their detailed history out of the active `todos/` and `traces/` entry files in the same change, keeping only the current recovery point, active facts, active risks, immediate next step, and pointers to archive files

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.cs : Match existing async patterns and naming conventions with `Async` suffix for asynchronous methods in C#

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs
🪛 LanguageTool
ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md

[grammar] ~49-~49: Ensure spelling is correct
Context: ... errors - 已接受的 worker 范围: - ed269d4:`GFramework.Cqrs.Tests/Mediator/MediatorArchitectureInte...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~50-~50: Ensure spelling is correct
Context: ...48/MA0004/MA0016 -121df44GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeatures...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~51-~51: Ensure spelling is correct
Context: ...48/MA0004/MA0015 -9109eecGFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTes...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (24)
GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs (2)

49-237: 测试方法中 .ConfigureAwait(false) 的一致性应用看起来不错!

在测试代码中统一添加 .ConfigureAwait(false) 是一个良好的实践,可以避免不必要的同步上下文捕获,特别是在这些测试可能在各种测试运行器环境中执行时。这些更改在整个文件中保持了一致性。


382-385: ArgumentException 参数名称更改的考量

将参数名从 nameof(request.Value) 改为 nameof(request) 在技术上是正确的,因为 request 是方法的实际参数。但是,由于验证针对的是 request.Value,使用 nameof(request.Value)(解析为 "Value")可能会为调用者提供更精确的错误定位信息。

这两种方式都是可接受的,当前的更改与整个 PR 中的统一风格保持一致。

GFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTests.cs (4)

86-426: 测试方法中的异步调用更新看起来很好!

在整个测试文件中一致地添加 .ConfigureAwait(false) 是一个合理的改进,包括:

  • SendRequestAsyncPublishAsyncSendAsync 调用
  • Task.WhenAllTask.Delay 调用
  • await foreach 异步枚举

这确保了测试在不同的执行环境中表现一致。


494-498: 良好的改进:使用 StringComparer.Ordinal

Cache 字典添加 StringComparer.Ordinal 是一个好的实践,确保了字符串键的大小写敏感比较行为一致且高效。同时使用 IDictionary<string, string> 接口类型也提供了更好的抽象。


521-530: ReceivedMessages 类型更改为 ICollection<string> 是合适的

将类型从 List<string> 改为 ICollection<string> 提供了更好的接口抽象。测试代码通过局部变量 receivedOrder(类型为 List<string>)访问索引器,因此不会受到此更改的影响。


585-596: ArgumentException 参数名称更改与其他文件保持一致

MediatorAdvancedFeaturesTests.cs 中的更改类似,使用 nameof(request) 是可接受的,保持了整个 PR 中的一致性。

GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs (2)

58-308: 测试方法中的 .ConfigureAwait(false) 添加看起来不错!

在所有异步调用上一致地添加 .ConfigureAwait(false) 是一个合理的改进,与其他测试文件保持一致。


463-496: TestPerDispatchContextAwareHandler 的实现结构良好

使用 IReadOnlyList<T> 属性公开内部跟踪列表是一个良好的封装实践。Reset() 方法在 SetUp 中调用,确保测试之间的隔离。

ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md (1)

9-75: 恢复文档信息完整且真值收口清晰

本次更新已覆盖恢复点、阶段、验证结果、风险与下一步,且 active 内容保持精简,适合作为继续执行的恢复入口。

Based on learnings: "Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point".

ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md (1)

3-82: Trace 记录维度完整,阶段衔接明确

新增 RP-094 / RP-093 段落都包含日期、关键决策、验证里程碑与立即下一步,便于后续继续接力。

As per coding guidelines: "Contributors MUST maintain a matching execution trace under ai-plan/public/<topic>/traces/ for complex work, recording the current date, key decisions, validation milestones, and the immediate next step".

GFramework.Game/Config/YamlConfigScalarConstraints.cs (1)

3-31: 结构清晰,职责边界合理

将数值/字符串约束聚合为只读包装模型的做法可读性好,也便于后续按语义扩展。

GFramework.Game/Config/YamlConfigNumericConstraints.cs (1)

3-55: 数值约束模型设计简洁且一致

字段语义明确、不可变属性清晰,作为 schema 约束载体实现是稳妥的。

GFramework.Game/Config/YamlConfigReferenceUsage.cs (1)

18-74: 实现清晰,数据模型职责单一

参数防御和只读属性设计都很稳健,当前改动没有看到功能性风险。

GFramework.Game/Config/YamlConfigSchemaValidator.ObjectKeywords.cs (1)

1-893: 代码重构结构清晰,符合规范。

该文件将对象级 schema 关键字(dependentRequireddependentSchemasallOfif/then/else)的解析逻辑拆分为独立的辅助方法,有效降低了认知复杂度。XML 文档完整,错误处理一致,符合编码规范。

GFramework.Game/Config/YamlConfigSchemaNode.cs (1)

1-330: 模型设计良好,不可变模式实现正确。

YamlConfigSchemaNode 采用私有构造函数配合工厂方法的不可变设计模式,With* 方法通过复用内部状态实现高效的部分更新。嵌套类封装了实现细节,整体结构清晰。

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

25-60: 正则超时设置是良好的安全实践。

添加 1 秒的正则超时(SupportedFormatRegexTimeout)可有效防止 ReDoS(正则表达式拒绝服务)攻击,特别是当处理用户提供的 schema 模式时。所有预编译的正则实例都已正确应用此超时。


317-337: 重构后的 ParseNode 结构清晰。

将节点解析拆分为类型解析、对象专属关键字验证、类型分派创建三个阶段,职责明确,便于维护和测试。


770-802: 对象验证重构合理,职责分离清晰。

将对象验证拆分为映射节点获取、属性遍历、必填属性检查、约束验证等阶段,每个阶段职责单一。seenProperties 集合在各阶段间正确传递,确保依赖关系验证的一致性。


1397-1419: 标量验证流水线设计良好。

将标量验证重构为节点类型检查 → 值提取 → 类型验证 → 约束规范化/验证 → 跨表引用收集的阶段化流程,逻辑清晰,便于定位问题。


2698-2834: 数值约束验证拆分合理。

将数值区间和步进约束的验证拆分为下界检查、上界检查、multipleOf 检查三个独立方法,符合单一职责原则,降低了主方法的复杂度。


2186-2203: 模式正则验证正确应用超时。

在解析 pattern 约束时创建临时正则对象来验证模式合法性,正确应用了超时参数。实际用于运行时匹配的编译正则在 CreateStringScalarConstraints 中创建,同样应用了超时。


1223-1319: 条件 schema 验证逻辑正确。

if/then/else 的实现遵循 JSON Schema 语义:先评估 if 条件,根据结果选择验证 thenelse 分支。ValidateConditionalSchemaBranch 辅助方法提供了统一的分支验证和错误报告机制。


3078-3081: 字符串比较一致使用序数比较。

整个文件中的字符串比较都正确使用了 StringComparison.Ordinal,确保跨环境的一致行为。


1-4023: 重构有效降低了分析器警告。

该文件通过以下方式成功减少复杂度:

  1. 添加正则超时防止 ReDoS
  2. 将大型方法拆分为语义明确的辅助方法
  3. 一致使用 StringComparison.Ordinal 进行字符串比较
  4. 将对象/标量/数值约束验证分离为独立流程

虽然文件行数较多,但作为 partial class 的一部分,且每个方法的认知复杂度已控制在合理范围内。

Comment thread GFramework.Game/Config/YamlConfigAllowedValue.cs
Comment thread GFramework.Game/Config/YamlConfigConditionalSchemas.cs
Comment thread GFramework.Game/Config/YamlConfigSchemaPropertyType.cs
Comment thread GFramework.Game/Config/YamlConfigStringFormatConstraint.cs
Comment thread GFramework.Game/Config/YamlConfigStringFormatKind.cs
- 修复 Mediator 集成测试中的阻塞等待、缓存竞态与共享状态原子性问题

- 补充 YamlConfig 运行时模型的构造期约束与 exception XML 文档

- 新增 模型契约回归测试并更新 analyzer warning reduction 恢复文档
@github-actions

Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2176    ↑7 2175    ↑6 1    ↑1 0 0 0 37.7s    ↑2.8s

Test Results

failed 1 failed ↑1
passed 2175 passed ↑6

Details

tests 2176 tests ↑7
clock 37.7s ↑2.8s
tool nunit
build CI - Build & Test arrow-right build-and-test link #1007
pull-request Fix/analyzer warning reduction batch link #301

Failed Tests

YamlConfigLoaderTests arrow-right LoadAsync_Should_Accept_Empty_Object_Schema_Const

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2153 0 5 4.7s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
ILogAppender_Flush_Should_Raise_OnFlushCompleted_Only_Once 47 46 1 2.13    ↓0.04
RegisterMigration_During_Cache_Rebuild_Should_Not_Leave_Stale_Type_Cache 54 53 1 1.85    ↓0.04
Run_Should_Assign_Globally_Unique_Reference_Metadata_Member_Names 55 54 1 1.82    ↓0.03
LoadAsync_Should_Accept_Empty_Object_Schema_Const 55 54 1 1.82    ↑1.82
OnPhase_Should_Not_Throw_When_Registry_Not_Found 55 54 1 1.82    ↓0.03

build-and-test: Run #1007

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2176 2175 1 0 0 0 0 37.7s

Some tests failed!

Name Failure Message
❌ LoadAsync_Should_Accept_Empty_Object_Schema_Const System.ArgumentException : The value cannot be an empty string or composed entirely of whitespace. (Parameter 'comparableValue')

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 55 4.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 55 2.2s 2.4s
Generates_Scene_Behavior_Boilerplate 55 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 55 1.1s 1.1s
Append_ShouldNotBlock 55 1.0s 1.0s
Context_Caching_Should_Improve_Performance 55 781ms 791ms
PendingCount_ShouldReflectQueuedEntries 55 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 55 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 55 401ms 402ms
Generates_Precise_Assembly_Type_Lookups_For_Inaccessible_External_Protected_Types 55 324ms 354ms

± Comparison with run #1006 at bf1da2d | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 55 runs.

Github Test Reporter by CTRF 💚

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs (1)

456-489: 静态跟踪列表在顺序测试场景下可接受,但建议添加注释说明。

TrackedContextsTrackedInstanceIds 是普通 List<>,依赖于 SetUp 中调用 Reset() 和测试顺序执行来保证正确性。建议添加简短注释说明这些静态字段的线程安全假设。

💡 建议添加注释说明线程安全假设
     public sealed class TestPerDispatchContextAwareHandler : ContextAwareBase,
         IRequestHandler<TestPerDispatchContextAwareRequest, int>
     {
         private static int _nextInstanceId;
+        // 以下静态列表仅在顺序测试场景下使用,SetUp 会调用 Reset() 重置状态。
         private static readonly List<IArchitectureContext?> TrackedContexts = [];
         private static readonly List<int> TrackedInstanceIds = [];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`
around lines 456 - 489, Add a brief comment to
TestPerDispatchContextAwareHandler clarifying that the static lists
TrackedContexts and TrackedInstanceIds are intentionally non-thread-safe and
rely on tests running sequentially with Reset() called in SetUp; mention the
expectation that no concurrent test execution or parallel handler invocations
will mutate these lists so readers understand the thread-safety assumption and
where Reset() is used to clear state.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs`:
- Around line 456-489: Add a brief comment to TestPerDispatchContextAwareHandler
clarifying that the static lists TrackedContexts and TrackedInstanceIds are
intentionally non-thread-safe and rely on tests running sequentially with
Reset() called in SetUp; mention the expectation that no concurrent test
execution or parallel handler invocations will mutate these lists so readers
understand the thread-safety assumption and where Reset() is used to clear
state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc60f8b3-d579-4e30-bc39-9569960c51c8

📥 Commits

Reviewing files that changed from the base of the PR and between 7da9859 and f5f2c25.

📒 Files selected for processing (15)
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
  • GFramework.Game/Config/YamlConfigAllowedValue.cs
  • GFramework.Game/Config/YamlConfigArrayConstraints.cs
  • GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs
  • GFramework.Game/Config/YamlConfigConditionalSchemas.cs
  • GFramework.Game/Config/YamlConfigConstantValue.cs
  • GFramework.Game/Config/YamlConfigObjectConstraints.cs
  • GFramework.Game/Config/YamlConfigSchema.cs
  • GFramework.Game/Config/YamlConfigSchemaNode.cs
  • GFramework.Game/Config/YamlConfigStringConstraints.cs
  • GFramework.Game/Config/YamlConfigStringFormatConstraint.cs
  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
✅ Files skipped from review due to trivial changes (3)
  • GFramework.Game/Config/YamlConfigStringFormatConstraint.cs
  • GFramework.Game/Config/YamlConfigConditionalSchemas.cs
  • GFramework.Game/Config/YamlConfigConstantValue.cs
🚧 Files skipped from review as they are similar to previous changes (4)
  • GFramework.Game/Config/YamlConfigAllowedValue.cs
  • GFramework.Game/Config/YamlConfigSchema.cs
  • GFramework.Game/Config/YamlConfigArrayConstraints.cs
  • GFramework.Game/Config/YamlConfigStringConstraints.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Build and Test
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: Apply [Log] attribute for automatic logging field and logging helper method generation
Apply [Priority] attribute for automatic priority comparison implementation generation
Apply [GenerateEnumExtensions] attribute to generate enumeration extension capabilities
Apply [ContextAware] attribute to automatically implement IContextAware boilerplate logic

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, 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, interactions, why the abstraction exists, and when to use it
Generated logic and generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments in C# files
Follow standard C# naming: types/methods/properties/events/constants in PascalCase, interfaces with I prefix, parameters and locals in camelCase, private fields in _camelCase
Use 4 spaces for indentation in C# files; do not use tabs
Use Allman braces in C# files
Keep using directives at the top of C# files and sort them consistently
Prefer one primary type per C# file unless the surrounding project already uses a different local pattern
Keep...

Files:

  • GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs
  • GFramework.Game/Config/YamlConfigObjectConstraints.cs
  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
  • GFramework.Game/Config/YamlConfigSchemaNode.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
ai-plan/public/*/traces/**

📄 CodeRabbit inference engine (AGENTS.md)

Contributors MUST maintain a matching execution trace under ai-plan/public/<topic>/traces/ for complex work, recording the current date, key decisions, validation milestones, and the immediate next step

Files:

  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
ai-plan/public/*/todos/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/public/*/todos/**: When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under ai-plan/public/<topic>/todos/ in the same change
Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point
Active tracking and trace files are recovery entrypoints, not append-only changelogs; they MUST stay concise enough for boot to locate the current recovery point quickly
Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely
When completed and validated stages begin to accumulate, contributors MUST archive their detailed history out of the active todos/ and traces/ entry files in the same change, keeping only the current recovery point, active facts, active risks, immediate next step, and pointers to archive files
When a task spans multiple commits or is likely to exceed a single agent context window, update both the recovery document and the trace at each meaningful milestone before pausing or handing work off
If subagents are used on a complex task, the main agent MUST capture the delegated scope and any accepted findings in the active recovery document or trace before continuing implementation

Files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
🧠 Learnings (13)
📚 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/YamlConfigArrayContainsConstraints.cs
  • GFramework.Game/Config/YamlConfigObjectConstraints.cs
  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
  • GFramework.Game/Config/YamlConfigSchemaNode.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/traces/** : Contributors MUST maintain a matching execution trace under `ai-plan/public/<topic>/traces/` for complex work, recording the current date, key decisions, validation milestones, and the immediate next step

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : When a public C# 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/YamlConfigModelContractTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
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/YamlConfigModelContractTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.cs : Public API changes must be covered by unit or integration tests in C#

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.Game.Tests/Config/YamlConfigModelContractTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under `ai-plan/public/<topic>/todos/` in the same change

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to ai-plan/public/*/todos/** : Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely

Applied to files:

  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
📚 Learning: 2026-04-17T11:35:08.762Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-17T11:35:08.762Z
Learning: Applies to **/Cqrs/**/*.cs : Use CQRS (Command Query Responsibility Segregation) pattern with the Cqrs naming entry point instead of the historical Mediator alias

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs
  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
📚 Learning: 2026-04-26T03:16:48.230Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-26T03:16:48.230Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs
🪛 LanguageTool
ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md

[grammar] ~82-~82: Ensure spelling is correct
Context: ... errors - 已接受的 worker 范围: - ed269d4:`GFramework.Cqrs.Tests/Mediator/MediatorArchitectureInte...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~83-~83: Ensure spelling is correct
Context: ...48/MA0004/MA0016 -121df44GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeatures...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~84-~84: Ensure spelling is correct
Context: ...48/MA0004/MA0015 -9109eecGFramework.Cqrs.Tests/Mediator/MediatorComprehensiveTes...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md

[grammar] ~31-~31: Ensure spelling is correct
Context: ...ontractTests.cs作为模型契约回归覆盖 - 本轮修复集中在GFramework.Cqrs.TestsGFramework.Game` 两个最新 review ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (14)
ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md (1)

3-35: 追踪文档结构完整,符合规范。

RP-095 条目准确记录了触发背景、triage 结论(接受/延后/驳回)、主线程实施、验证里程碑和下一步,满足 ai-plan/public/*/traces/** 的追踪要求。

GFramework.Cqrs.Tests/Mediator/MediatorArchitectureIntegrationTests.cs (3)

561-571: 竞态条件修复正确。

SharedState 现在使用 Interlocked.Add 进行原子更新,解决了先前 review 中指出的 Counter += request.Increment 非原子操作问题。这确保了并发测试 Context_State_Should_Remain_Consistent_Under_Concurrency 的稳定性。


397-412: 缓存实现改进合理。

使用 ConcurrentDictionary 替代普通 Dictionary 并配合 GetOrAdd 是正确的线程安全缓存模式。


66-70: .ConfigureAwait(false) 统一应用正确。

所有 SendRequestAsync 调用都已添加 .ConfigureAwait(false),符合测试代码中避免同步上下文捕获的最佳实践。

Also applies to: 78-82, 90-94, 103-108

GFramework.Cqrs.Tests/Mediator/MediatorAdvancedFeaturesTests.cs (2)

239-241: MA0048 抑制已附带原因注释,符合规范。

注释 "这些高级特性测试需要把一组仅供当前文件使用的辅助类型共置,避免拆成多个噪声文件" 清晰说明了抑制理由,满足 coding guidelines 中关于 analyzer suppressions 需要注释的要求。

Also applies to: 509-510


383-386: ArgumentException 参数名称调整合理。

nameof(request.Value) 改为 nameof(request) 更准确地反映了异常的语义——问题在于请求对象的整体状态(Value 字段为负数),而不仅仅是 Value 属性本身。

GFramework.Game/Config/YamlConfigObjectConstraints.cs (1)

1-86: 对象约束模型设计良好。

构造函数契约校验(拒绝负数、拒绝 min > max)、<exception> XML 文档、只读属性设计都符合框架规范。不可变模型确保了运行时状态一致性。

GFramework.Game/Config/YamlConfigSchemaNode.cs (2)

7-36: Schema 节点模型设计合理。

私有构造函数配合静态工厂方法(CreateObjectCreateArrayCreateScalar)清晰区分了不同节点类型的创建路径,同时 With* 方法提供了不可变更新能力。ArgumentNullException.ThrowIfNull 确保了必需参数的契约。


242-261: NodeChildren.None 静态实例是良好的空对象模式。

为标量节点提供预分配的空 children 实例,避免了重复分配。

GFramework.Game/Config/YamlConfigArrayContainsConstraints.cs (1)

1-60: 数组 contains 约束模型契约完整。

构造函数校验逻辑(非空 containsNode、非负边界、min <= max)与其他约束模型保持一致,<exception> 文档准确描述了抛出条件。

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

10-125: 契约测试覆盖全面。

测试用例涵盖了所有关键契约场景:

  • 空白值拒绝(AllowedValueConstantValue
  • 负值和反向区间拒绝(ArrayContainsConstraintsArrayConstraintsObjectConstraints
  • 成对约束(pattern/patternRegex
  • 防御性复制(ReferencedTableNames

Assert.Multiple 的使用确保了分组断言都能执行并报告。


93-94: Regex 超时设置符合 MA0009 规范。

测试中的 new Regex("value", RegexOptions.None, TimeSpan.FromSeconds(1)) 正确添加了超时参数,避免潜在的 ReDoS 风险。

ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md (2)

9-15: 恢复点文档更新完整。

RP-095 记录了当前阶段、焦点、已完成修复和 triage 结论(接受/延后/驳回),符合恢复文档规范。


37-42: 风险与缓解措施记录清晰。

文档正确识别了两个当前风险(PR 线程状态、仓库级 warning 真值未重采样)并提供了具体缓解措施,便于后续恢复工作。

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 29, 2026
@github-actions

Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2176 2175 1 0 0 0 35.5s    ↓2.2s

Test Results

failed 1 failed
passed 2175 passed

Details

tests 2176 tests
clock 35.5s ↓2.2s
tool nunit
build CI - Build & Test arrow-right build-and-test link #1008
pull-request Fix/analyzer warning reduction batch link #301

Failed Tests

YamlConfigLoaderTests arrow-right LoadAsync_Should_Accept_Empty_Object_Schema_Const

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2153 0 6 4.7s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
LoadAsync_Should_Accept_Empty_Object_Schema_Const 56 54 2 3.57    ↑1.75
ILogAppender_Flush_Should_Raise_OnFlushCompleted_Only_Once 48 47 1 2.08    ↓0.05
RegisterMigration_During_Cache_Rebuild_Should_Not_Leave_Stale_Type_Cache 55 54 1 1.82    ↓0.03
Run_Should_Assign_Globally_Unique_Reference_Metadata_Member_Names 56 55 1 1.79    ↓0.03
OnPhase_Should_Not_Throw_When_Registry_Not_Found 56 55 1 1.79    ↓0.03

build-and-test: Run #1008

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2176 2175 1 0 0 0 0 35.5s

Some tests failed!

Name Failure Message
❌ LoadAsync_Should_Accept_Empty_Object_Schema_Const System.ArgumentException : The value cannot be an empty string or composed entirely of whitespace. (Parameter 'comparableValue')

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 56 4.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 56 2.2s 2.4s
Generates_Scene_Behavior_Boilerplate 56 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 56 1.1s 1.1s
Append_ShouldNotBlock 56 1.0s 1.0s
Context_Caching_Should_Improve_Performance 56 781ms 792ms
PendingCount_ShouldReflectQueuedEntries 56 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 56 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 56 401ms 402ms
Generates_Precise_Assembly_Type_Lookups_For_Inaccessible_External_Protected_Types 56 324ms 354ms

± Comparison with run #1007 at 4cf15b9 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 56 runs.

Github Test Reporter by CTRF 💚

- 修复 YamlConfigAllowedValue 与 YamlConfigConstantValue 对空对象 const 或 enum 比较键的误判,同时继续拒绝非空纯空白输入
- 补充 YamlConfigModelContractTests 对空比较键与纯空白比较键的回归覆盖,并验证空对象 const 场景
- 更新 ai-plan 公共索引并归档 analyzer-warning-reduction 主题,保留最终 PR review 结论与验证记录
@github-actions

Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2178    ↑2 2178    ↑3 0    ↓1 0 0 0 37.3s    ↑1.9s

Test Results

passed 2178 passed ↑3

Details

tests 2178 tests ↑2
clock 37.3s ↑1.9s
tool nunit
build CI - Build & Test arrow-right build-and-test link #1009
pull-request Fix/analyzer warning reduction batch link #301

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2154 0 6 4.7s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
LoadAsync_Should_Accept_Empty_Object_Schema_Const 57 55 2 3.51    ↓0.06
ILogAppender_Flush_Should_Raise_OnFlushCompleted_Only_Once 49 48 1 2.04    ↓0.04
RegisterMigration_During_Cache_Rebuild_Should_Not_Leave_Stale_Type_Cache 56 55 1 1.79    ↓0.03
Run_Should_Assign_Globally_Unique_Reference_Metadata_Member_Names 57 56 1 1.75    ↓0.04
OnPhase_Should_Not_Throw_When_Registry_Not_Found 57 56 1 1.75    ↓0.04

build-and-test: Run #1009

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2178 2178 0 0 0 0 0 37.3s

🎉 All tests passed!

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 57 4.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 57 2.2s 2.4s
Generates_Scene_Behavior_Boilerplate 57 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 57 1.1s 1.1s
Append_ShouldNotBlock 57 1.0s 1.0s
Context_Caching_Should_Improve_Performance 57 781ms 792ms
PendingCount_ShouldReflectQueuedEntries 57 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 57 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 57 401ms 402ms
Generates_Precise_Assembly_Type_Lookups_For_Inaccessible_External_Protected_Types 57 324ms 354ms

± Comparison with run #1008 at dbcebf5 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 57 runs.

Github Test Reporter by CTRF 💚

@GeWuYou GeWuYou merged commit 4557dde into main Apr 29, 2026
7 checks passed
@GeWuYou GeWuYou deleted the fix/analyzer-warning-reduction-batch branch April 29, 2026 03:14
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