From 358b1e9cca40ec9597f2641cef1d2a42c8fbdd17 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Tue, 21 Apr 2026 08:42:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(cqrs):=20=E4=BF=AE=E5=A4=8D=20PR=20?= =?UTF-8?q?=E5=AE=A1=E6=9F=A5=E9=81=97=E7=95=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 CqrsHandlerRegistrar generated registry 激活路径的可空 out 契约并移除 null! 抑制 - 更新 analyzer warning reduction 跟踪与 trace,记录 PR #263 review follow-up 和编译验证结果 --- .../Internal/CqrsHandlerRegistrar.cs | 9 +++++---- .../analyzer-warning-reduction-tracking.md | 14 ++++++++++---- .../analyzer-warning-reduction-trace.md | 19 +++++++++++++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs b/GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs index 33332ea5..1bef8ef0 100644 --- a/GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs +++ b/GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs @@ -1,6 +1,7 @@ using GFramework.Core.Abstractions.Ioc; using GFramework.Core.Abstractions.Logging; using GFramework.Cqrs.Abstractions.Cqrs; +using System.Diagnostics.CodeAnalysis; using System.Reflection.Emit; namespace GFramework.Cqrs.Internal; @@ -185,7 +186,7 @@ internal static class CqrsHandlerRegistrar Type registryType, string assemblyName, ILogger logger, - out ICqrsHandlerRegistry registry) + [NotNullWhen(true)] out ICqrsHandlerRegistry? registry) { var activationMetadata = RegistryActivationMetadataCache.GetOrAdd( registryType, @@ -195,7 +196,7 @@ internal static class CqrsHandlerRegistrar { logger.Warn( $"Ignoring generated CQRS handler registry {registryType.FullName} in assembly {assemblyName} because it does not implement {typeof(ICqrsHandlerRegistry).FullName}."); - registry = null!; + registry = null; return false; } @@ -203,7 +204,7 @@ internal static class CqrsHandlerRegistrar { logger.Warn( $"Ignoring generated CQRS handler registry {registryType.FullName} in assembly {assemblyName} because it is abstract."); - registry = null!; + registry = null; return false; } @@ -211,7 +212,7 @@ internal static class CqrsHandlerRegistrar { logger.Warn( $"Ignoring generated CQRS handler registry {registryType.FullName} in assembly {assemblyName} because it does not expose an accessible parameterless constructor."); - registry = null!; + registry = null; return false; } diff --git a/ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md b/ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md index 6a8e1f4d..4586470a 100644 --- a/ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md +++ b/ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md @@ -7,11 +7,13 @@ ## 当前恢复点 -- 恢复点编号:`ANALYZER-WARNING-REDUCTION-RP-003` -- 当前阶段:`Phase 3` +- 恢复点编号:`ANALYZER-WARNING-REDUCTION-RP-004` +- 当前阶段:`Phase 4` - 当前焦点: - - 已完成 `GFramework.Core/Architectures/ArchitectureLifecycle.cs` 的 `MA0051` 长方法拆分,保持阶段推进、日志文本和 late registration 语义不变 - - 已确认 `GFramework.Core` 定向 `warnings-only` 构建从 `30 Warning(s)` 收敛到 `29 Warning(s)`,`ArchitectureLifecycle` 已不再出现在剩余 `MA0051` 热点中 + - 已完成当前分支 PR #263 的最新 review follow-up,本地确认并修复 `GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs` + 的 `null!` 可空契约问题,同时消除 active trace 的重复标题 `MD024` + - 已确认 PR 上的测试信号为 `2134 Passed / 0 Failed`;MegaLinter 唯一告警来自 CI 中 `dotnet-format` restore 失败, + 当前本地 follow-up 不需要额外处理 - 下一轮若继续推进,优先从 `PauseStackManager`、`CoroutineScheduler` 或 `Store` 的剩余 `MA0051` 中只选一个切入点 ## 当前状态摘要 @@ -27,6 +29,7 @@ - `RP-001` 的详细实现历史、测试记录和 warning 热点清单已归档到主题内 `archive/` - `RP-002` 已在不改公共契约的前提下完成 `CqrsHandlerRegistrar` 结构拆分,并通过定向 build/test 验证 - `RP-003` 已在不改生命周期契约的前提下完成 `ArchitectureLifecycle` 初始化主流程拆分,并通过定向 build/test 验证 +- `RP-004` 已完成当前 PR review follow-up:修复 `TryCreateGeneratedRegistry` 的可空 `out` 契约并清理 trace 文档重复标题 - 当前工作树分支 `fix/analyzer-warning-reduction-batch` 已在 `ai-plan/public/README.md` 建立 topic 映射 ## 当前风险 @@ -52,6 +55,9 @@ - `RP-003` 的定向验证结果: - `dotnet build GFramework.Core/GFramework.Core.csproj -c Release -t:Rebuild --no-restore -p:UseSharedCompilation=false -p:TargetFramework=net8.0 -p:RestoreFallbackFolders= -nologo -clp:Summary;WarningsOnly` - `dotnet test GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release --filter FullyQualifiedName~ArchitectureLifecycleBehaviorTests -p:RestoreFallbackFolders=` +- `RP-004` 的定向验证结果: + - `dotnet build GFramework.Cqrs/GFramework.Cqrs.csproj -c Release --no-restore -p:TargetFramework=net8.0 -p:UseSharedCompilation=false -p:RestoreFallbackFolders=` + - 结果:`0 Warning(s)`,`0 Error(s)` - active 跟踪文件只保留当前恢复点、活跃事实、风险与下一步,不再重复保存已完成阶段的长篇历史 ## 下一步 diff --git a/ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md b/ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md index e879388b..58f5485b 100644 --- a/ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md +++ b/ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md @@ -1,6 +1,6 @@ # Analyzer Warning Reduction 追踪 -## 2026-04-21 +## 2026-04-21 — RP-003 ### 阶段:Architecture 生命周期 `MA0051` 收口(RP-003) @@ -20,7 +20,22 @@ - `dotnet test GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release --filter FullyQualifiedName~ArchitectureLifecycleBehaviorTests -p:RestoreFallbackFolders=` - 结果:`6 Passed`,`0 Failed` -## 2026-04-21 +## 2026-04-21 — RP-004 + +### 阶段:PR review follow-up(RP-004) + +- 使用 `gframework-pr-review` 抓取当前分支 PR #263 的最新 CodeRabbit review threads、MegaLinter 摘要与 CTRF 测试结果, + 只接受仍能在本地工作树复现的 review 点 +- 在 `GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs` 中将 `TryCreateGeneratedRegistry` 的 `out` 参数改为 + `[NotNullWhen(true)] out ICqrsHandlerRegistry?`,移除三处 `null!` 抑制,保持激活失败时的日志文本与回退语义不变 +- 修正 active trace 中重复的 `## 2026-04-21` 二级标题,消除 CodeRabbit 报告的 markdownlint `MD024` +- 核实 PR 信号后确认:当前 CTRF 报告为 `2134 passed / 0 failed`;MegaLinter 唯一告警来自 CI 环境中的 `dotnet-format` + restore 失败,不是本地代码格式问题 +- 验证通过: + - `dotnet build GFramework.Cqrs/GFramework.Cqrs.csproj -c Release --no-restore -p:TargetFramework=net8.0 -p:UseSharedCompilation=false -p:RestoreFallbackFolders=` + - 结果:`0 Warning(s)`,`0 Error(s)` + +## 2026-04-21 — RP-002 ### 阶段:CQRS `MA0051` 收口(RP-002)