Messagepack-csharp: Unity IL2CPP generic object wrapper code gen

Created on 25 Jun 2020  路  3Comments  路  Source: neuecc/MessagePack-CSharp

Bug description

Hello, I'm trying to use a generic object wrapper it works in the editor but during runtime it throws an error. I'm unsure if the code gen is supposed to work with generics. If not I'll have to figure out a workaround :( Thanks in advance for any help!

Error Message
MessagePack.MessagePackSerializationException: Failed to deserialize MyAssembly.MyDataModel value. ---> MessagePack.FormatterNotRegisteredException: MyAssembly.Wrapper"1[[System.Int32, System, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] is not registered in resolver: MessagePack.Resolvers.StaticCompositeResolver

Repro steps

[MessagePackObject]
[Union(0, typeof(WrapperGeneric<int>))]
public abstract class Wrapper
{
    public static WrapperGeneric<T> Create<T>(T value)
    {
        return new WrapperGeneric<T>(value);
    }
    [IgnoreMember]
    public object Value
    {
        get { return ValueImpl; }
        set { ValueImpl = value; }
    }
    protected abstract object ValueImpl { get; set; }
    protected Wrapper() { }
}
[MessagePackObject]
public sealed class WrapperGeneric<T> : Wrapper
{
    public WrapperGeneric() { }
    public WrapperGeneric(T value) { Value = value; }
    [Key(0)]
    public new T Value { get; set; }
    protected override object ValueImpl
    {
        get { return Value; }
        set { Value = (T)value; }
    }
}

Called during edit mode and runtime returns null
GeneratedResolver.Instance.GetFormatter<WrapperGeneric<int>>()

  • Version used:
  • Unity 2019.4.1f1 LTS IL2CPP .NET 4.x
  • MessagePack.Unity.2.1.143
mpc unity

Most helpful comment

This issue should now be fixed. @MetaCitizenOffical

All 3 comments

I have the exact same issue...

@AArnott Is there no way to tell mpc to generate formatters for 'known' generic wrapper types?

Or just in general how can I create a formatter for such a generic wrapper?

I don't maintain mpc. @neuecc would have to answer that question.

This issue should now be fixed. @MetaCitizenOffical

Was this page helpful?
0 / 5 - 0 ratings