mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-11 20:38:58 +08:00
- 修复 Architecture 销毁后 GameContext 仍保留活动上下文的问题 - 补充生命周期回归测试并验证失败初始化后的解绑路径 - 收口生成器文档中的多架构表述并更新 ai-plan 追踪
4.1 KiB
4.1 KiB
Single Context Priority 跟踪
目标
围绕 GameContext 与 MicrosoftDiContainer 收敛当前运行时语义:
- 把
GameContext从弱约束的多上下文字典收敛为“单活动上下文 + 兼容别名查找”模型 - 保留按架构类型查找的兼容入口,同时禁止在同一全局上下文表中并存多个不同的架构上下文实例
- 统一
MicrosoftDiContainer预冻结阶段的单实例读取路径,减少RegisterPlurality/ CQRS 基础设施别名注册下的查询歧义
当前恢复点
- 恢复点编号:
SINGLE-CONTEXT-PRIORITY-RP-001 - 当前阶段:
Phase 2 - 当前结论:
GameContext已从“字典首个枚举值即默认上下文”收敛为“单活动上下文 + 类型别名兼容查找”;同一全局上下文表不再允许并存两个不同上下文实例MicrosoftDiContainer的预冻结Get<T>()/Get(Type)已改为复用实例可见性收集逻辑,和GetAll*的实例暴露规则保持一致IIocContainerXML 文档已明确预冻结查询与Contains<T>()的契约边界,避免把注册阶段查询误读为完整 DI 激活语义Architecture.DestroyAsync()现会在生命周期销毁完成后显式解除GameContext绑定,防止已销毁架构继续充当默认上下文回退入口- 当前分支从
main创建,已完成git pull --ff-only origin main
当前活跃事实
- 当前分支:
refactor/single-context-priority - 当前预期改动面:
GFramework.Core/Architectures/GameContext.csGFramework.Core/Rule/ContextAwareBase.csGFramework.Core/Ioc/MicrosoftDiContainer.csGFramework.Core.Abstractions/Ioc/IIocContainer.cs- 相关
GFramework.Core.Tests与必要文档页
当前风险
GameContext是公开静态入口,任何“允许多个不同上下文并存”的现有测试都需要按单活动上下文语义重写Contains<T>()在预冻结阶段目前更接近“是否存在注册”,不等同于“是否能立即解析实例”;本轮若不改其行为,需要在文档和测试中明确这一点ResolveCqrsRegistrationService()仍要求注册阶段对ICqrsRegistrationService可见的是实例绑定;若后续改成工厂或实现类型注册,需要额外设计注册阶段激活 helper- 现有解绑逻辑通过
Architecture.GetType()移除初始化期绑定;若后续引入更多显式上下文别名,需同步评估是否要在销毁时额外移除这些别名
最近权威验证
git pull --ff-only origin main- 结果:通过,当前主分支已同步
rg -n "GetFirstArchitectureContext|GameContext|RegisterPlurality|ResolveCqrsRegistrationService|GetAll\\(" ...- 结果:已确认
GameContext的默认回退集中在ContextAwareBase/GameContextProvider,且MicrosoftDiContainer的预冻结查询实现存在分叉
- 结果:已确认
python3 scripts/license-header.py --check- 结果:通过
dotnet test GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release --filter "FullyQualifiedName~GameContextTests|FullyQualifiedName~ContextProviderTests|FullyQualifiedName~ContextAwareTests|FullyQualifiedName~MicrosoftDiContainerTests|FullyQualifiedName~IocContainerLifetimeTests|FullyQualifiedName~ArchitectureInitializationPipelineTests"- 结果:通过,
92/92passed
- 结果:通过,
dotnet build GFramework.Core/GFramework.Core.csproj -c Release- 结果:通过,
0 warning / 0 error
- 结果:通过,
dotnet test GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release --filter "FullyQualifiedName~ArchitectureLifecycleBehaviorTests|FullyQualifiedName~SyncArchitectureTests|FullyQualifiedName~AsyncArchitectureTests|FullyQualifiedName~ArchitectureInitializationPipelineTests|FullyQualifiedName~ContextAwareTests"- 结果:通过,
32/32passed
- 结果:通过,
dotnet build GFramework.Core/GFramework.Core.csproj -c Release- 结果:再次通过,
0 warning / 0 error
- 结果:再次通过,
下一推荐步骤
- 若后续继续推进,可评估是否要把
GameContext.ArchitectureReadOnlyDictionary标记为兼容层,并收口其公开使用面 - 若 CQRS runtime seam 计划改成工厂式注册,再单独补“注册阶段激活 helper”的设计与测试