comiler error from generated .proto file

409 views
Skip to first unread message

Lars Schouw

unread,
Jul 8, 2011, 9:29:43 AM7/8/11
to prot...@googlegroups.com
I am getteing an error 
error CS1001: Identifier expected
when I generate a .cs file from this .proto file. How can I fix this and make it compile?

person.proto
message Person { 
required int32 id = 1; 
optional string name = 2;
optional string motto = 3 [default="When the cat is away, the mouse is alone!"];
enum Gender{ 
MALE = 1;
FEMALE =2;
}
optional Gender gender = 4;
}
  
using protogen.exe -i:person.proto -o:person.cs

this generates a c# source file that has compilation errors:

    private Person.Gender _gender = Person.Gender.;
    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"gender", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
    [global::System.ComponentModel.DefaultValue(Person.Gender.)]
    public Person.Gender gender
    {
      get { return _gender; }
      set { _gender = value; }
    }

Jason Hsueh

unread,
Jul 8, 2011, 4:59:46 PM7/8/11
to prot...@googlegroups.com
You'll have to check with the developer of the C# implementation for support, but it appears that this code is the initialization of the member to the default value. My guess is the implementation's code generator looks up the enum name of the default value, and assumes that the default value is zero if none is specified. Since you don't have an enum value with numeric value zero defined, it returns an empty symbol. Try explicitly adding a default value?

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/GM5gmkno2l8J.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Reply all
Reply to author
Forward
0 new messages