Class MessageNameAliasAttribute
Declares a name this message was known by previously, so data already written keeps resolving.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
public sealed class MessageNameAliasAttribute : Attribute
- Inheritance
-
MessageNameAliasAttribute
- Inherited Members
- Extension Methods
Examples
[MessageName("customer-created")]
[MessageNameAlias("Contoso.Legacy.Events.CustomerCreated, Contoso.Legacy")]
public sealed record CustomerCreated(Guid CustomerId, string Name) : IDomainEvent;
Remarks
Apply this when an event's stored name changes -- because the type moved namespace or assembly, or because its declared MessageNameAttribute name was replaced. An alias affects reading only: events are always written under the type's current name, so a retired name stops spreading and the store converges as new events arrive.
Apply it once per historical name, and keep them. Removing one makes every event still stored under that name unreadable.
Constructors
MessageNameAliasAttribute(string)
Initializes a new instance of the MessageNameAliasAttribute class.
public MessageNameAliasAttribute(string name)
Parameters
namestringA name this event was previously stored under.
Exceptions
- ArgumentException
nameis null or whitespace.
Properties
Name
Gets a name this event was previously stored under.
public string Name { get; }