- Notifications
You must be signed in to change notification settings - Fork 174
Closed
Labels
bugDetected as bugDetected as bug
Description
Hello,
Let me report an issue.
ISSUE DESCRIPTION
Serialization fails with InvalidOperationException if:
- The class has static member variables
- Put values to static member variables on declaration
- Platform is UWP (*)
(*) I verified this works on Unity Editor.
ENVIRONMENT
MessagePack for CLI 0.7.0-beta1
Visual Studio 2015 Version 14.0.25123.00 Update 2
Windows 10
REPRO CODE
Put the following code and call Serialize() method.
public class ClassHasStaticField { public string m_string; #if NO_PROBLEM_PATTERN static int m_int; #else static int m_int = 1000; #endif public ClassHasStaticField() { m_string = "dummy"; m_int = 1000; } } void Serialize() { ClassHasStaticField chsf = new ClassHasStaticField(); MsgPack.Serialization.MessagePackSerializer serializer; byte[] byteArray; using (MemoryStream stream = new MemoryStream()) { try { serializer = MsgPack.Serialization.MessagePackSerializer.Get(chsf.GetType()); byteArray = serializer.PackSingleObject(chsf); } catch (Exception ex) { Debug.WriteLine("Exception caught: " + ex.ToString()); } } } EXPECTED RESULT
Serialized successfully.
ACTUAL RESULT
The following exception thrown:
Exception thrown: 'System.InvalidOperationException' in System.Linq.dll Exception caught: System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) at MsgPack.ReflectionAbstractions.GetConstructor(TypeInfo source, Type[] parameteres) at MsgPack.ReflectionAbstractions.GetConstructor(Type source, Type[] parameteres) at MsgPack.Serialization.SerializationTarget.Prepare(SerializationContext context, Type targetType) at MsgPack.Serialization.ReflectionSerializers.ReflectionObjectMessagePackSerializer`1..ctor(SerializationContext context) at MsgPack.Serialization.MessagePackSerializer.CreateReflectionInternal[T](SerializationContext context, Type concreteType, PolymorphismSchema schema) at MsgPack.Serialization.SerializationContext.GetSerializer[T](Object providerParameter) at MsgPack.Serialization.SerializationContext.SerializerGetter`1.Get(SerializationContext context, Object providerParameter) at MsgPack.Serialization.SerializationContext.SerializerGetter.Get(SerializationContext context, Type targetType, Object providerParameter) at MsgPack.Serialization.SerializationContext.GetSerializer(Type targetType, Object providerParameter) at MsgPack.Serialization.MessagePackSerializer.Get(Type targetType, SerializationContext context, Object providerParameter) at MsgPack.Serialization.MessagePackSerializer.Get(Type targetType) at Serializer_for_UWP.MainPage.Serialize() Metadata
Metadata
Assignees
Labels
bugDetected as bugDetected as bug