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

Included protogen is unable to parse "oneof" #478

Closed
xPaw opened this issue Oct 21, 2017 · 17 comments
Closed

Included protogen is unable to parse "oneof" #478

xPaw opened this issue Oct 21, 2017 · 17 comments
Labels
Milestone

Comments

@xPaw
Copy link
Member

xPaw commented Oct 21, 2017

tf_proto_def_messages.proto:119:9: Expected "required", "optional", or "repeated".
tf_proto_def_messages.proto:119:24: Missing field number.
steammessages_hiddevices.proto:99:9: Expected "required", "optional", or "repeated".
steammessages_hiddevices.proto:99:23: Missing field number.
@yaakov-h
Copy link
Member

@SudoHenk
Copy link

Seems like "oneof" is not going to be implemented anytime soon. Are there any other options to generate the code from the ProtoBuffs?

@yaakov-h
Copy link
Member

I believe oneof doesn't have any different wire encoding to regular fields, so in theory if you replace

oneof a_oneof {
    string first = 1;
    int second = 2;
}

with just

optional first = 1;
optional int second = 2;

then it should work, but you'd have to check in application code which of the fields is set.

@SudoHenk
Copy link

SudoHenk commented Oct 22, 2017

protobuf-net:protogen - code generator for .proto
tf_gcmessages.proto:191:16: Option "allow_alias" unknown.
tf_gcmessages.proto:7:8: Option "allow_alias" unknown.

Another problem, seems to be also only present in a newer version of ProtoBuf (I'm still a novice on ProtoBuff and .NET in general, just tried to compile it for the TF2 Update, don't know what the allow_alias option actually does).

@mgravell
Copy link

mgravell commented Oct 23, 2017

support for oneof in protobuf-net has been there since June (anything 2.3.0 or above): http://blog.marcgravell.com/2017/06/protobuf-net-gets-proto3-support.html

@yaakov-h
Copy link
Member

Thanks!

So how do we download/get/build the new protogen? Is there a convenient NuGet package?

@mgravell
Copy link

mgravell commented Oct 23, 2017

to pre-empt the next question ("how do I get standalone protogen?") (dammit, didn't quite type fast enough - you beat me!):

  • option 1: build the "protogen" tool from source - note that the args are now comparable to protoc - this is ideal for people familiar with protoc
  • option 2: take a look at the code in protogen's Program.cs (there isn't much) - then add a nuget reference to protobuf-net.Reflection and have fun - this is ideal for custom / automated scenarios
  • (edit) option 3: use the online tool https://protogen.marcgravell.com/ - this is ideal for light usage

to pre-empt the question after that ("why isn't there a nuget package for just protogen?"):

because nuget seems to have crappy options for this kind of tool; I'm harassing MS weekly on getting improved tools for build-time codegen.

@yaakov-h
Copy link
Member

Not even DotNetCliTool?

@mgravell
Copy link

honestly, I've never tried that; if that is an appropriate "fix" here, then I'm more than happy to take a look - especially if there are some reference docs somewhere

@yaakov-h
Copy link
Member

The docs for that are here, but I'm not quite sure what to make of them this late at night. 😅

@yaakov-h yaakov-h added bug and removed blocked labels Oct 23, 2017
@mgravell
Copy link

I'll take a look, thanks

@yaakov-h
Copy link
Member

With an new build of protogen, the only way (it seems) to define a namespace is by using option csharp_namespace inside the .proto file. Since these protobufs are reverse-engineered, I don't think we want to mess with them.

I might have to try option 2 above and build our own generator.

@mgravell
Copy link

mgravell commented Oct 30, 2017 via email

@xPaw
Copy link
Member Author

xPaw commented Nov 26, 2018

Looks like protogen is able to do this now, just need to update it.

@xPaw
Copy link
Member Author

xPaw commented Jan 18, 2019

@yaakov-h yaakov-h added this to the 2.3.0 milestone Feb 5, 2019
@yaakov-h
Copy link
Member

yaakov-h commented Oct 2, 2019

I got back to this... I tried to clean up / finish off #686 but there are bugs in protobuf-net 2.4 so we can't use that.

They seem to be fixed in 3.0 but we're now blocked waiting on this:

protobuf-net/protobuf-net#563

@yaakov-h
Copy link
Member

Resolved by #686.

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

No branches or pull requests

4 participants