froto icon indicating copy to clipboard operation
froto copied to clipboard

Add support for protobuf-net bcl-Types

Open Schwem opened this issue 9 years ago • 4 comments

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);

Schwem avatar Oct 25 '16 10:10 Schwem

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?

jhugard avatar Oct 26 '16 15:10 jhugard

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?

Schwem avatar Oct 31 '16 13:10 Schwem

Go ahead and leave it open.

jhugard avatar Oct 31 '16 14:10 jhugard

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.

Karamell avatar Jun 08 '18 09:06 Karamell