Skip to content

[Phase 2] Implement PowerCSharp.Sitecore core context logic #36

Description

@marioarce

Task

Implement the core thread-safe context logic using MarshalByRefObject + ILogicalThreadAffinative pattern.

Deliverables

  • Create src/PowerCSharp.Sitecore/PowerCSharp.Sitecore.csproj
  • Target frameworks: net48, net6.0, net8.0
  • Implement SitecoreThreadSafeContext:
    • Implements ISitecoreThreadSafeContext
    • Implements ILogicalThreadAffinative
    • Marked as [Serializable]
    • Stores context in CallContext (net48) or AsyncLocal (net6/8)
  • Implement SitecoreContextService:
    • Extends MarshalByRefObject
    • Static Context property for access
    • Uses CallContext.GetData/SetData for context propagation
  • Implement ReflectionSitecoreContextProvider:
    • Uses reflection to access Sitecore.Context at runtime
    • Caches PropertyInfo for performance
    • Gracefully handles missing Sitecore assembly
  • Add Database property only (v1.0.0 scope)
  • Add README.md
  • Add package to PowerCSharp.sln
  • Configure CI/CD

Acceptance Criteria

  • Context propagates across thread boundaries
  • Reflection-based Sitecore access works at runtime
  • Graceful failure when Sitecore unavailable
  • No compile-time Sitecore.Kernel dependency
  • Unit tests pass for all target frameworks

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions