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

Non-public types

Open asdfgasdfsafgsdfa opened this issue 7 years ago • 2 comments

Is there any reason why only public types can be serialized? The library should not decide what is allowed to be serialized and what not. Why create an artificial limitation like that?

If there any way to turn this off?

I want to use msgpack to save private datatypes in my application. And I also don't want to have my network messages public for everyone to see. It would be bad design to make those types public.

asdfgasdfsafgsdfa avatar Apr 10 '17 19:04 asdfgasdfsafgsdfa

This is technical limitation in old days.

MsgPack for CLI internally uses IL generation (via System.Reflection.Emit) and/or source code generation (via code DOM) to generate serializer code. Both of them require the target type is public. Currently, it is possible when we use:

  1. Via reflection.
  2. Via DynamicMethod. As far as I know, msgpack for C# internally uses this technique, but this will take long time to implement.

yfakariya avatar Apr 11 '17 11:04 yfakariya

You can also use MessagePackMember attribute

itaign avatar Apr 13 '17 15:04 itaign