Skip to content

Failed to serialize as List<[MessagePackObject]> With Union #2237

@moesionadel

Description

@moesionadel

I have an error like tihs:

Failed to serialize System.Collections.Generic.List`1[[Server.Shared.Message, Server.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] value.

From Unity and Server(.net8) both. I use [Union] for Polymorphism. My "Message" class from Shared Project like:

[Union(0, typeof(RegisterRequest))]
[Union(1, typeof(RegisterResponse))]
[Union(2, typeof(LoginRequest))]
[Union(3, typeof(LoginResponse))]
public abstract class Message { }

And all "Response" and "Request" inheriting from "Message" Class.

So when I try to serialize as List(), I always fail...

I want to send messages as list from an IL2CPP build. Also my server is AOT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions