mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-13 06:04:30 +08:00
- 修复 MicrosoftDiContainer 的 IDisposable 释放逻辑、根 ServiceProvider 清理与释放后访问保护 - 更新 CQRS benchmarks 的容器 cleanup,并补齐 RequestStartupBenchmarks 的冷启动容器释放路径 - 补充 Core 容器生命周期回归测试并归档 issue 327 的 ai-plan topic
2.0 KiB
2.0 KiB
MicrosoftDiContainer Disposal Trace
2026-05-06
MDC-DISPOSE-RP-001 Issue #327 disposal repair
- Trigger:
- issue
#327reports thatMicrosoftDiContainerholds aReaderWriterLockSlimand a frozenIServiceProviderbut never releases either resource explicitly - CQRS benchmark types keep
MicrosoftDiContainerfields alive across runs and currently only dispose the MediatRServiceProviderside RequestStartupBenchmarksalso creates temporary GFramework runtimes whose backing containers are never surfaced for cleanup
- issue
- Decisions:
- treat the fix as a container lifetime contract update, not only a benchmark workaround
- add the disposal contract at the
IIocContainerabstraction so callers holding interface references can release the container explicitly - keep runtime ownership unchanged; benchmarks that create containers remain responsible for disposing them
- Implementation notes:
MicrosoftDiContainernow releases its frozen rootIServiceProvider, clears registration state, disposes the internalReaderWriterLockSlim, and rejects all later operations withObjectDisposedExceptionRequestStartupBenchmarkswas rewritten so the steady-state runtime keeps an explicit container field and the cold-start benchmark disposes its temporary container in the same measured invocation- other benchmark classes that own
MicrosoftDiContainerfields now dispose them duringGlobalCleanup
- Validation milestone:
python3 scripts/license-header.py --checkpasseddotnet test GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release --filter "FullyQualifiedName~MicrosoftDiContainer|FullyQualifiedName~IocContainerLifetimeTests"passed (55/55)dotnet build GFramework.Cqrs.Benchmarks/GFramework.Cqrs.Benchmarks.csproj -c Releasepassed with0 warnings / 0 errorsdotnet build GFramework.sln -c Releasepassed with0 warnings / 0 errors
- Immediate next step:
- archive the topic and push the branch