Messagepack-csharp: Could you please update the Readme to show how to implemented the Generated Resolver with mpc.exe

Created on 19 Oct 2019  路  9Comments  路  Source: neuecc/MessagePack-CSharp

Is your feature request related to a problem? Please describe.

In your readme I can see this code to use the generated resolver
`
// Do this once and store it for reuse.
var resolver = MessagePack.Resolvers.CompositeResolver.Create(
Array.Empty(),
new IFormatterResolver[]
{
MessagePack.Resolvers.GeneratedResolver.Instance,
MessagePack.Resolvers.StandardResolver.Instance,
});
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);

// Each time you serialize/deserialize, specify the options:
byte[] msgpackBytes = MessagePackSerializer.Serialize(myObject, options);
T myObject2 = MessagePackSerializer.Deserialize(msgpackBytes, options);
`

But the method CompositeResolver.Create doesn't exist anymore and this object
MessagePackSerializerOptions neither

Describe the solution you'd like

I assume we have to use instead of the Create the register method, but I am not sure about the serializerOptions

I assume it will be something like this
IFormatterResolver options = null; void Awake () { var resolver = CompositeResolver.Instance; CompositeResolver.Register ( Array.Empty<IMessagePackFormatter> (), new IFormatterResolver[] { GeneratedResolver.Instance, StandardResolver.Instance, }); // options = MessagePackSerializerOptions.Standard.WithResolver (resolver); options = resolver; }
and then in another method I will call it as shown in your readme
s_rpc_object toObjectFast (byte[] dat) { return MessagePackSerializer.Deserialize<s_rpc_object> (dat, options); }

Could you confirm please?

Describe alternatives you've considered

Additional context

Btw thank you so much for this library, I am using it on Oculus Quest and I can see 5 times better performance than with binary serializer, I am about to try this on the android if it works ( hopefully yes )

no-issue-activity

All 9 comments

+1, having the same issue. Too bad the confusion hasn't been cleaned up yet.

To the original poster: Have you got it to work, because I couldn't and I'm fairly lost. Any help would be greatly appreciated.

This is due to the default branch in GitHub being master.
master is a preview version and is not stable.
We should set v1.7 (v1.8) as the default branch during the preview.

Thank you for the quick response, I finally got it to work.

There is still one more question I have: I am using Unity (2019.3beta) and the only version of MessagePack-C# I got to work was from the .unitypackage from the Ver 1.7.3.5 release. Is that fine? Felt a bit outdated since the newest release is v1.8.74. But wasn't able to get it to work in Unity, are there some instructions I've missed on how to get it to work with Unity?

Ok to use 1.7.3.5.

But of course, better to ship the latest version to Unity.
In v2 has the PackageExporter https://github.com/neuecc/MessagePack-CSharp/blob/master/src/MessagePack.UnityClient/Assets/Editor/PackageExport.cs
We should port to v1.8 and run on CI and store it to artifact(and automatically update to GH releases).
What to do? @AArnott

I've never coded up a build/pipeline that pushes to GitHub Releases automatically, but I'm interested in learning for other reasons as well.
Can you port the PackageExport.cs change to produce the package, and I'll work on the pipeline change to publish to github releases?

Thank you for your effort!

@AArnott I've added PackageExporter(direct pushed).

to upload GitHub Releases, I'm using ghr in another project.
https://github.com/tcnksm/ghr
yml sample(it uploads unitypackage and codegenerator).
https://github.com/Cysharp/MasterMemory/blob/master/.circleci/config.yml#L102-L109

Hello! Is there any sample / doc to illustrate this ? Or the current and above referenced doc is valid ?

MessagePack is used by SignalR as referenced [here]
(https://docs.microsoft.com/en-us/aspnet/core/signalr/messagepackhubprotocol?view=aspnetcore-3.0)

Not sure which version of MessagePack-Csharp is used by msft as the suggested package is Microsoft.AspNetCore.SignalR.Protocols.MessagePack

Nevertheless the SignalR docs point here for any material regarding mpc.exe. More clarity or sample on generating and using resolvers would be highly appreciated.

cc @neuecc @jmd42 @one-man-machine

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Was this page helpful?
0 / 5 - 0 ratings