Git Product home page Git Product logo

Comments (3)

yfakariya avatar yfakariya commented on August 17, 2024

(I removed previous post because I found the cause while I reproduced issue #46, and edit at 15:15)

Hi @JamesWM
Sorry for inconvinience and delay.

I found it is by design to work around C# and CLR reflection API desigin -- they DO NOT gurantee the order of the field. MessagePack CLI sorts membres in lexical order to avoid future incompatibility of stored data. So your MessageDescriptor might be serialized as [<messageId>, <version>], so the version=1 was deserialized as messageId.

Please try to put [MessagePackMembrer(n)] attributes to your fields to specify explicit order like:

public class MessageDescriptor
{
    [MessagePackMember(0)]
    public byte version = 1;
    [MessagePackMember(1)]
    public MessageId messageId;
    ...
}

-Note: I guess an annotation to specify order is needed in Java (see http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getDeclaredFields%28%29 , it states that the order returned from reflection API is undefined in Java too), but I am not expart of MessagePack Java (@Index annotation looks help you)-

from msgpack-cli.

chefhoobajoob avatar chefhoobajoob commented on August 17, 2024

Ok - similar to issue 46. I will try this and update with results (might be a day or two).

from msgpack-cli.

chefhoobajoob avatar chefhoobajoob commented on August 17, 2024

Got around to testing this, and it works as long as:

There are @Index attributes for each of the enum members in the java class, and the @Index values are zero-based, and the enum values are also 0-based, and their values are all equal to the @Index attribute values.

...and the same is true on the C# side, with the enum attributed with [MessagePackEnum(SerializationMethod=EnumSerializationMethod.ByUnderlyingValue)]

...then I can get enum's to interoperate between the languages.

from msgpack-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.