Interface IMessageUpcaster<TOld, TNew>
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
TOldThe source message type (older version).
TNewThe 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 typesout 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
ToVersion
Gets the target version this upcaster transforms to.
int ToVersion { get; }
Property Value
Methods
Upcast(TOld)
Transforms an old message version to a new version.
TNew Upcast(TOld oldMessage)
Parameters
oldMessageTOldThe 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