Skip to content

[Epic] Implement Thread-Safe Sitecore Context Package #34

Description

@marioarce

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions