-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessagePack Unions not serialized correctly. #48
Labels
bug
Something isn't working
Comments
Added your implementation to H.Formatters.MessagePack lib. |
This is available in the latest prerelease version and will be stable after some time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: