Table of Contents

Interface IMessageUpcaster<TOld, TNew>

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

Base interface for type-safe message transformations between versions.

public interface IMessageUpcaster<in TOld, out TNew> where TOld : IDispatchMessage, IVersionedMessage where TNew : IDispatchMessage, IVersionedMessage

Type Parameters

TOld

The source message type (older version).

TNew

The target message type (newer version).

Extension Methods

Remarks

This is the generic base interface used by all specialized upcasters (events, commands, queries, integration events). Upcasters form a directed graph where nodes are message versions and edges are transformations. The IUpcastingPipeline uses BFS to find shortest paths between versions.

Variance markers:

  • in TOld (contravariant) - allows accepting base types
  • out TNew (covariant) - allows returning derived types

Performance: Measure conversion latency and allocation with the actual upcaster, message types and runtime. This contract does not guarantee a particular timing or allocation count.

Properties

FromVersion

Gets the source version this upcaster transforms from.

int FromVersion { get; }

Property Value

int

ToVersion

Gets the target version this upcaster transforms to.

int ToVersion { get; }

Property Value

int

Methods

Upcast(TOld)

Transforms an old message version to a new version.

TNew Upcast(TOld oldMessage)

Parameters

oldMessage TOld

The source message to transform.

Returns

TNew

A new message instance with the target version.

Remarks

This method must be:

  • Pure - same input always produces same output
  • Immutable - does not modify oldMessage
  • Deterministic - no random values or current time
  • Fast - called in hot path: event replay, command handling, query processing