Closed PhilJollans closed 6 months ago
Added your implementation to H.Formatters.MessagePack lib. https://github.com/HavenDV/H.Pipes/commit/a34a0a2e08c129b449c28454a9102b5153a07277
This is available in the latest prerelease version and will be stable after some time I don't see any other way to solve the problem, so I'm closing this.
Describe the bug
I have several classes defined as a Union, using the MessagePack.Union attribute. See https://github.com/MessagePack-CSharp/MessagePack-CSharp?tab=readme-ov-file#union
I had no problem with .NET 6, but with .NET 8 I find that the Union classes are not serialized correctly,
So far as I can tell, it is necessary to provide a type parameter to
MessagePackSerializer.Serialize()
, specifying the base class used for the union.I have defined my own formatter class
which I specify with both
PipeClient
and thePipeSever
In my application, this seems to have fixed the problem, but I'm not sure that it is a general solution.
Steps to reproduce the bug
Define a set of classes using MessageBase.Union, following the example in https://github.com/MessagePack-CSharp/MessagePack-CSharp?tab=readme-ov-file#union
I defined the base class as an
abstract class
, not aninterface
.Create a PipeServer an a PipeClient based on the union class.
Create an instance of one of the derived classes.
Send it via the PipeServer.
On receiving the message, the PipeClient will generate an error.
Expected behavior
No response
Screenshots
No response
NuGet package version
No response
Platform
Console
IDE
Visual Studio 2022
Additional context
.NET 8