The command pipeline uses attributes to control the registration and execution order of behaviors.
The OrderAttribute is used to define the priority of a behavior.
[Order(100)]
public class MyBehavior : IPreBehavior<MyCommand, MyResult> { ... }
Order(1) will wrap a behavior with Order(10).Default Value: If the attribute is missing, the system defaults to int.MinValue, meaning it will likely run before behaviors that have an explicit order defined (unless they use a value lower than int.MinValue).
The SharedBehaviorAttribute is a marker attribute used during assembly scanning.
[SharedBehavior]
public class ValidationBehavior<TCommand, TResult> : IPreBehavior<TCommand, TResult> { ... }
It indicates that the behavior is generic and should be applied to all commands that match its generic constraints. This is particularly useful for cross-cutting concerns like validation, logging, or transaction management that apply to many different command types.
While not directly used for behavior ordering, the SpanAttribute (found in TaskHub.Shared.Commands.Abstractions.Attributes) is used to provide metadata for telemetry.
[Span("user.create")]
public class CreateUserHandler : ICommandHandler<CreateUserCommand, Result> { ... }
It allows customizing the name of the OpenTelemetry span created for the handler. If not provided, the system defaults to the class name.