msgpack-sharp icon indicating copy to clipboard operation
msgpack-sharp copied to clipboard

C# MessagePackMember Attribute Deserialize bug

Open germwire opened this issue 8 years ago • 5 comments

[MessagePackMember(1, Name = "fees", NilImplication = NilImplication.MemberDefault)] public decimal Fees { get; set; }

ERROR:

{"The unpacked value is not expected type. Do not convert System.Byte (binary:0x0) MessagePackObject to MsgPack.MessagePackString."} The unpacked value is not expected type. Do not convert System.Byte (binary:0x0) MessagePackObject to MsgPack.MessagePackString. at MsgPack.Serialization.DefaultSerializers.System_DecimalMessagePackSerializer.UnpackFromCore(Unpacker unpacker) at MsgPack.Serialization.MessagePackSerializer1.UnpackFrom(Unpacker unpacker) at MsgPack.Serialization.UnpackHelpers.UnpackComplexObject[T](Unpacker unpacker, MessagePackSerializer1 serializer, Int32 unpacked) at MsgPack.Serialization.UnpackHelpers.UnpackValueTypeValueCoreTContext,TValue at MsgPack.Serialization.UnpackHelpers.UnpackValueTypeValueTContext,TValue at MsgPack.Serialization.EmittingSerializers.Generated.####_Models_OrderSerializer1.UnpackValueOfprocessingFee(Unpacker , Order , Int32 , Int32 ) at MsgPack.Serialization.UnpackHelpers.UnpackFromMapCoreTContext,TResult at MsgPack.Serialization.UnpackHelpers.UnpackFromMapTContext,TResult at MsgPack.Serialization.UnpackHelpers.UnpackFromMapTContext,TResult at MsgPack.Serialization.EmittingSerializers.Generated.####_Models_OrderSerializer1.UnpackFromCore(Unpacker ) at MsgPack.Serialization.MessagePackSerializer`1.UnpackFrom(Unpacker unpacker)

germwire avatar Oct 12 '16 15:10 germwire

It looks like decimals aren't supported (https://github.com/scopely/msgpack-sharp/blob/eef2661f466ec1a341486b3011e0f68feb708396/msgpack-sharp/MsgPackIO.cs#L907)

@Claytonious can you confirm?

avram avatar Oct 12 '16 16:10 avram

Correct.

On Wed, Oct 12, 2016, 9:10 AM Avram Lyon [email protected] wrote:

It looks like decimals aren't supported ( https://github.com/scopely/msgpack-sharp/blob/eef2661f466ec1a341486b3011e0f68feb708396/msgpack-sharp/MsgPackIO.cs#L907 )

@Claytonious https://github.com/Claytonious can you confirm?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scopely/msgpack-sharp/issues/30#issuecomment-253259518, or mute the thread https://github.com/notifications/unsubscribe-auth/AAktn50bgMLw2d16PZbNotHqxFHhJhqMks5qzQZcgaJpZM4KU4CJ .

Claytonious avatar Oct 12 '16 16:10 Claytonious

It also appears that MessagePack doesn't have a standard decimal representation: https://github.com/msgpack/msgpack/blob/master/spec.md#formats

avram avatar Oct 12 '16 16:10 avram

I need decimal calculations for money math arithmetic. Is there an alternative?

germwire avatar Oct 12 '16 16:10 germwire

So with vanilla MessagePack, other types are usually packed using the ext type: https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family

msgpack-sharp doesn't currently have a mechanism for registering serializations into the ext family, but that would be the logical direction to go.

avram avatar Oct 12 '16 16:10 avram