deniszykov / msgpack-unity3d

MessagePack and JSON serializer for Unity3D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReflectionExtensions.GetDataMemberName doesn't work under WebGL in Unity

mabakay opened this issue · comments

[DataContract] public class Token { [DataMember(Name = "expires_in")] private long _expiresIn; }

To resolve this I had to cast to DataMemberAttribute directly and access "Name" property.

Are you sure that byte-code stripper doesn't removed DataMember.Name property? To make sure do assert runtime

typeof(DataMember).GetMethod("get_Name", BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null) != null

If it is false you should configure bytecode stripping in Unity.

You could be right. Anyway whats the reason to access Name field by reflection? Why not just cast to DataMemberAttribute and access it explicty? It is for avoiding dependancy to System.Runtime.Serialization?

Yes, dependency on System.Runtime.Serialization will cause compilation errors for many users due to the fact that there are many different versions of this assembly and with some Unity settings it is not included in build at all.