Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Add support for protobuf-net bcl-Types #66

Open
Schwem opened this issue Oct 25, 2016 · 4 comments
Open

Add support for protobuf-net bcl-Types #66

Schwem opened this issue Oct 25, 2016 · 4 comments

Comments

@Schwem
Copy link

Schwem commented Oct 25, 2016

The following .proto (created with protobuf-net)

import "bcl.proto"; // schema for protobuf-net's handling of core .NET types

message ClassA {
   optional string ID;
   optional string Name = 1 [default = aa];
   optional bcl.Guid mGuid = 2 [default = 00000000-0000-0000-0000-000000000000];
}

crashes with this message:

Error in Ln: 6 Col: 51
  optional bcl.Guid mGuid = 3 [default = 00000000-0000-0000-0000-000000000000];
                                                 ^
Expecting: newline, tab, ' ', ',', '/*', '//' or ']'

I try to parse it like this: FSharpList<Ast.PStatement> s = Parse.fromString(proto);

@jhugard
Copy link
Collaborator

jhugard commented Oct 26, 2016

The GUID data type bcl.Guid is a protobuf-net extension and not supported by the Google language spec, nor the protoc compiler. Can you rename this issue to something like "Add support for protobuf-net GUID values"?

One work around would be to modify (hand-edit) the field from "bcl.Guid" to "binary" and encode the binary as a string; e.g., "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0". I am fairly certain that this would be wire-compatible with protobuf-net code, and should interoperate with no problem.

Otherwise, it will be some work to modify Froto to accept this: the parser currently uses a Parsec helper function to parse numeric values and I'm pretty sure that function cannot be taught to handle GUID/UUID format. So, that means writing a complete numeric parser that also can consume GUID's.

Can you just use the work-around, instead?

@Schwem Schwem changed the title Parser crashs when working with Guid / - and default Add support for protobuf-net bcl-Types Oct 31, 2016
@Schwem
Copy link
Author

Schwem commented Oct 31, 2016

Thanks jhugard for your quick response.
We created a little parser only for our necessary types now.

So, should I close it or leave it open as new Task?

@jhugard
Copy link
Collaborator

jhugard commented Oct 31, 2016

Go ahead and leave it open.

@Karamell
Copy link

Karamell commented Jun 8, 2018

I managed to decode a DateTime and a Guid from Protobuf.net. If anyone is interested I could try and convert the code to fit Froto.

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

No branches or pull requests

3 participants