Code-Sharp/WampSharp

Error when sending System.Decimal (NotImplementedException)

Opened this issue · 3 comments

Error:

WampSharp.WebSockets.ControlledBinaryWebSocketConnection`1[Newtonsoft.Json.Linq.JToken]|An error occurred while attempting to send a message to remote peer.|EXCEPTION OCCURRED:System.NotImplementedException The method or operation is not implemented. Void WriteValue(System.Decimal)

Callee looks like this:

    public interface ICallee
    {
        [WampProcedure("get_something")]
        Task<IEnumerable<SomeClassDto>> GetSomething();
    }

Class:

public class SomeClassDto
{
//...
    public decimal? WgsX { get; set; }
    public decimal? WgsY { get; set; }
//...
}

Using WampSharp.Websockets as transport & WampSharp.NewtonsoftCbor for serialization on client,

darkl commented

This is a bug for this library which seems not to be maintained, but maybe they accept pull requests.

Elad

Wouldn't it be better to use a well maintained implementation like this? https://github.com/peteroupc/CBOR Seems to be much more active and maintained and is definitely not an alpha release like the library mentioned.

darkl commented

It's not that simple. WampSharp needs the serialization library to support partial deserialization (or "deserialization by parts"), see my comments for this issue. That's one obstacle.
The second obstacle is that if we use something that is not Newtonsoft.Json based, we'll have to implement a mechanism that serializes our objects from/to JToken and the dynamic object in the other serialization library (as the router treats it as JToken or the other dynamic object type). See for example this attempt here. I think this implementation will be very buggy. The last reason which is the main reason that WampSharp uses Newtonsoft.Json based serialization for MessagePack serialization, is that it is the easiest way to make the serialization libraries behaviors consistent with each other. For instance, one serialization library might decide that its default is to write null values, while the other might decide that the default is not to write them. Another example is that some serialization libraries might respect some attributes, while others don't.
That being said, serialization formats are pluggable using IWampBinding and you can implement a different one. But I might not want to support it myself due to the problems it might cause.