Should Send be constrained to take a Command and Publish an Event?
Today we just constrain both of these to an IRequest. But our semantics imply that Send is one handler only for a Command and Publish is zero or more handlers for an event. Should this be explicit?
Absolutely. Forcing developers to use the correct semantics makes it easier to reason about code. E.g. one can trust that an implementation of ICommand is actually used as command throughout the system.
This also means that Post<T> is now a potential loophole.
Obviously people can still write things like OrderAccepted : ICommand or ProcessOrder : IEvent, but hey, it's something.
It's a breaking change, but I don't think anyone will be using this in a breaking way, and it would be informative if they were. Let's fix it.
PR ready to go...
So it turns out this breaks Dispatch. The Dispatcher does not know the type of the request, only that it is an IRequest. The compiler won't let us pass that to an interface constrained to IEvent or ICommand, so we are forced to cast it. If we cast it, Send and Publish don't know what the actual type is, and won;t be able to find the handler.
This may be related to the explicity GetKey() issue to map handlers to requests.