Overview
Implement a new PowerCSharp package family for thread-safe Sitecore context access, solving the non-thread-safe nature of Sitecore.Context.Database and Sitecore.Context.Request in multi-threaded scenarios.
Problem Statement
Sitecore.Context is not thread-safe. In multi-threaded scenarios, Sitecore.Context.Database returns null, leading to unexpected null references and hard-to-trace bugs, including deadlocks.
Solution
Implement a thread-safe context package using the MarshalByRefObject + ILogicalThreadAffinative pattern to propagate context across thread boundaries, avoiding direct reliance on Sitecore.Context.
Package Structure
PowerCSharp.Sitecore.Abstractions - Interfaces with no Sitecore dependencies
PowerCSharp.Sitecore - Implementation using reflection (no compile-time Sitecore.Kernel dependency)
Target Frameworks
- net48 (Sitecore 10.4 on .NET Framework 4.8)
- net6.0 (Sitecore 10.3+ on .NET 6)
- net8.0 (Future Sitecore versions)
API Surface
PowerCSharp.Sitecore.ThreadSafeContext.Database (v1.0.0)
- Future: Item, Site, User properties (v1.1.0)
Implementation Phases
This epic is broken down into the following phases (see child issues):
- Phase 1: Core Abstractions
- Phase 2: Core Implementation
- Phase 3: .NET Framework Support
- Phase 4: .NET 6/8 Support
- Phase 5: Documentation
- Phase 6: Additional Context Properties
Branch Strategy
GitFlow: feature/sitecore/* → develop → release/sitecore/v1.0.0 → main
Commit scope: sitecore
References
Overview
Implement a new PowerCSharp package family for thread-safe Sitecore context access, solving the non-thread-safe nature of
Sitecore.Context.DatabaseandSitecore.Context.Requestin multi-threaded scenarios.Problem Statement
Sitecore.Context is not thread-safe. In multi-threaded scenarios,
Sitecore.Context.Databasereturns null, leading to unexpected null references and hard-to-trace bugs, including deadlocks.Solution
Implement a thread-safe context package using the MarshalByRefObject + ILogicalThreadAffinative pattern to propagate context across thread boundaries, avoiding direct reliance on Sitecore.Context.
Package Structure
PowerCSharp.Sitecore.Abstractions- Interfaces with no Sitecore dependenciesPowerCSharp.Sitecore- Implementation using reflection (no compile-time Sitecore.Kernel dependency)Target Frameworks
API Surface
PowerCSharp.Sitecore.ThreadSafeContext.Database(v1.0.0)Implementation Phases
This epic is broken down into the following phases (see child issues):
Branch Strategy
GitFlow:
feature/sitecore/* → develop → release/sitecore/v1.0.0 → mainCommit scope:
sitecoreReferences