You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This throws on the Invoke line because the union data was not serialized. MessagePackFormatter serializes the return value as UnionDerivedClass directly, so no union data appears necessary. But on the receiving end, only UnionBaseClass is expected, so union data is necessary.
To fix this, the MessagePackFormatter needs to know what the declared type is and tell the MessagePackSerializer to serialize that as a generic type argument. That way the union data (if any) will be included.
The text was updated successfully, but these errors were encountered:
We need to support this for arguments as well as return values.
While return types have a declared type on both sides, arguments do not have a declared type on the originating side -- only the receiving side declares parameter types.
This leaves us with a very interesting problem for how to send arguments involving Union types with the MessagePackFormatter (or even the JsonMessageFormatter if combined with a custom discriminator JsonConverter, perhaps).
AArnott
added a commit
to AArnott/vs-streamjsonrpc
that referenced
this issue
May 2, 2020
Given a type hierarchy that utilizes MessagePack's
UnionAttribute
:And given a server method that declares to return the base type:
MessagePackFormatter
fails to deserialize the result:This throws on the Invoke line because the union data was not serialized. MessagePackFormatter serializes the return value as
UnionDerivedClass
directly, so no union data appears necessary. But on the receiving end, onlyUnionBaseClass
is expected, so union data is necessary.To fix this, the
MessagePackFormatter
needs to know what the declared type is and tell theMessagePackSerializer
to serialize that as a generic type argument. That way the union data (if any) will be included.The text was updated successfully, but these errors were encountered: