msgpack android,GitHub - msgpack/msgpack-cli: MessagePack implementation for Common Language Infrast...

MessagePack for CLI

CI Status

Configuration

Status

Release

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f356c6e3775376566776a65706a366f383f7376673d74727565

Debug (.NET Core 2.0)

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f646c6330763472726f6c776a307432743f7376673d74727565

Debug (.NET Core 2.0)

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f6176757266353139616c6c39327635753f7376673d74727565

Debug (.NET Framework 4.x)

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f6e703637323371327569716f667231613f7376673d74727565

Debug (Code DOM)]

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f316d773738776b787835306a766162313f7376673d74727565

Debug (miscs)]

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f61767566633531797532636d366964773f7376673d74727565

Debug (.NET Framework 3.5)

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f636a703870686c6e62776a37676b6a393f7376673d74727565

Debug (.NET Framework 3.5 Code DOM)

68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f316d773738776b787835306a766162313f7376673d74727565

What is it?

This is MessagePack serialization/deserialization for CLI (Common Language Infrastructure) implementations such as .NET Framework, Silverlight, Mono (including Moonlight.)

This library can be used from ALL CLS compliant languages such as C#, F#, Visual Basic, Iron Python, Iron Ruby, PowerShell, C++/CLI or so.

Usage

You can serialize/deserialize objects as following:

Create serializer via MessagePackSerializer.Get generic method. This method creates dependent types serializers as well.

Invoke serializer as following:

Pack method with destination Stream and target object for serialization.

Unpack method with source Stream.

// Creates serializer.

var serializer = MessagePackSerializer.Get();

// Pack obj to stream.

serializer.Pack(stream, obj);

// Unpack from stream.

var unpackedObject = serializer.Unpack(stream);

' Creates serializer.

Dim serializer = MessagePackSerializer.Get(Of T)()

' Pack obj to stream.

serializer.Pack(stream, obj)

' Unpack from stream.

Dim unpackedObject = serializer.Unpack(stream)

For production environment, you should instantiate own SerializationContext and manage its lifetime. It is good idea to treat it as singleton because SerializationContext is thread-safe.

Features

Fast and interoperable binary format serialization with simple API.

Generating pre-compiled assembly for rapid start up.

Flexible MessagePackObject which represents MessagePack type system naturally.

Note: AOT support is limited yet. Use serializer pre-generation with mpu -s utility or API.

If you do not pre-generated serializers, MsgPack for CLI uses reflection in AOT environments, it is slower and it sometimes causes AOT related error (ExecutionEngineException for runtime JIT compilation). You also have to call MessagePackSerializer.PrepareType and companions in advance to avoid AOT related error. See wiki for details.

Documentation

Installation

Binary files distributed via the NuGet package MsgPack.Cli.

You can extract binary (DLL) file as following:

Download *.zip file from GitHub Release page.

Extract it.

Under the bin directory, binaries are there!

For mono, you can use net461 or net35 drops as you run with.

For Unity, unity3d drop is suitable.

How to build

For .NET Framework

Install Visual Studio 2017 (Community edition is OK) and 2015 (for MsgPack.Windows.sln).

You must install .NET Framework 3.5, 4.x, .NET Core, and Xamarin dev tools to build all builds successfully.

If you do not want to install options, edit element in *.csproj files to exclude platforms you want to exclude.

Install latest .NET Core SDK.

Run with Visual Studio Developer Command Prompt:

msbuild MsgPack.sln /t:Restore

msbuild MsgPack.sln

Or (for Unity 3D drops):

msbuild MsgPack.compats.sln /t:Restore

msbuild MsgPack.compats.sln

Or (for Windows Runtime/Phone drops and Silverlight 5 drops):

msbuild MsgPack.Windows.sln /t:Restore

msbuild MsgPack.Windows.sln

Or (for Xamarin unit testing, you must have Xamarin Business or upper license and Mac machine on the LAN to build on Windows):

msbuild MsgPack.Xamarin.sln /t:Restore

msbuild MsgPack.Xamarin.sln

Or open one of above solution files in your IDE and run build command in it.

For Mono

Install latest Mono and .NET Core SDK.

Now, you can build MsgPack.sln and MsgPack.Xamarin.sln with above instructions and msbuild in latest Mono. Note that xbuild does not work because it does not support latest csproj format.

Own Unity 3D Build

First of all, there are binary drops on github release page, you should use it to save your time.

Because we will not guarantee source code organization compatibilities, we might add/remove non-public types or members, which should break source code build.

If you want to import sources, you must include just only described on MsgPack.Unity3D.csproj.

If you want to use ".NET 2.0 Subset" settings, you must use just only described on MsgPack.Unity3D.CorLibOnly.csproj file, and define CORLIB_ONLY compiler constants.

Xamarin Android testing

If you run on Windows, it is recommended to use HXM instead of Hyper-V based emulator.

You can disable Hyper-V from priviledged (administrator) powershell as follows:

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor

If you want to use Hyper-V again (such as for Docker for Windows etc.), you can do it by following in priviledged (administrator) powershell:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor

Xamarin Android Trouble shooting tips

Q: Javac shows compilation error.

A: Rebuild the test project and try it run again.

Xamarin iOS testing

You must create provisoning profiles in your MacOS devices.

See Xamarin documents about provisining for details.

There are bundle IDs of current iOS tests:

org.msgpack.msgpack-cli-xamarin-ios-test

org.msgpack.msgpack-cli-xamarin-ios-test-packer

org.msgpack.msgpack-cli-xamarin-ios-test-unpacker

org.msgpack.msgpack-cli-xamarin-ios-test-unpacking

org.msgpack.msgpack-cli-xamarin-ios-test-timestamp

org.msgpack.msgpack-cli-xamarin-ios-test-arrayserialization

org.msgpack.msgpack-cli-xamarin-ios-test-mapserialization

Note that some reflection based serializer tests failed with AOT related limitation.

Xamarin iOS Trouble shooting tips

Q: An error occurred while running unit test project.

A: Rebuild the project and rerun it. Or, login your Mac again, ant retry it.

Q: It is hard to read English.

A: You can read localized Xamarin docs with putting {region}-{lang} as the first component of URL path such as https://developer.xamarin.com/ja-jp/guides/....

Maintenance

MsgPack.Windows.sln

This solution contains Silverlight5 and (old) UWP project for backward compability. They are required Visual Studio 2015 to build and test.

You can download Visual Studio 2015 community edition from here.

You do not have to install Visual Studio 2015 as long as you don't edit/test/build Silverlight and/or old UWP project.

See also

/home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/v1/object.hpp:664:34: error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘struct msgpack::v2::object’ from an array of ‘const msgpack_object’ {aka ‘const struct msgpack_object’} [-Werror=class-memaccess] std::memcpy(&o, &v, sizeof(v)); ^ In file included from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/object_fwd.hpp:17, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/v1/adaptor/adaptor_base_decl.hpp:14, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/adaptor/adaptor_base_decl.hpp:13, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/adaptor/adaptor_base.hpp:13, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/v1/object_decl.hpp:16, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/object_decl.hpp:14, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/object.hpp:13, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack.hpp:10, from /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/example/cpp03/stream.cpp:10: /home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master/include/msgpack/v2/object_fwd.hpp:23:8: note: ‘struct msgpack::v2::object’ declared here struct object : v1::object { ^~~~~~ cc1plus: all warnings being treated as errors make[2]: *** [example/cpp03/CMakeFiles/stream.dir/build.make:63:example/cpp03/CMakeFiles/stream.dir/stream.cpp.o] 错误 1 make[2]: 离开目录“/home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master” make[1]: *** [CMakeFiles/Makefile2:415:example/cpp03/CMakeFiles/stream.dir/all] 错误 2 make[1]: 离开目录“/home/AQTJClient/AQTJAuditClient/depends/msgpack-c-master”
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值