Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you please update the Readme to show how to implemented the Generated Resolver with mpc.exe #593

Closed
one-man-machine opened this issue Oct 19, 2019 · 9 comments
Assignees
Milestone

Comments

@one-man-machine
Copy link

one-man-machine commented Oct 19, 2019

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 )

@jmd42
Copy link

jmd42 commented Oct 31, 2019

+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.

@neuecc
Copy link
Member

neuecc commented Oct 31, 2019

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.

@jmd42
Copy link

jmd42 commented Oct 31, 2019

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?

@neuecc
Copy link
Member

neuecc commented Nov 1, 2019

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

@AArnott
Copy link
Collaborator

AArnott commented Nov 1, 2019

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?

@jmd42
Copy link

jmd42 commented Nov 1, 2019

Thank you for your effort!

neuecc added a commit that referenced this issue Nov 5, 2019
@neuecc
Copy link
Member

neuecc commented Nov 5, 2019

@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

@AArnott AArnott self-assigned this Nov 5, 2019
@AArnott AArnott added this to the v1.8 milestone Nov 5, 2019
@rhy-ama
Copy link

rhy-ama commented Nov 21, 2019

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

@AArnott AArnott modified the milestones: v1.8, v1.9 Feb 7, 2020
@github-actions
Copy link

github-actions bot commented May 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants