I am attempting to generate c++ protobuf classes from a large c# .net codebase. The enumeration 'NotSet' is used as a default value in many enum declarations throughout, so I have used the ProtoEnum attribute to provide a different name for exporting where conflicts have arisen. However I have found that where my exported .proto file has classes with one of these enums as a member its default value still uses the orginal name, and protoc then fails to produce C++ files without correction.
Using the following example,
[DataContract]
[ProtoContract]
public enum MyEnum
{
[EnumMember]
[ProtoEnum(Name = "MyEnum_NotSet", Value=0)]
NotSet,
SomeValue,
AndSoOn
}
In a class I need to export the enumeration appears as a member I wish to export.
[ProtoContract]
public class MyClass
{
[DataMember]
[ProtoMember(1)]
private MyEnum m_myEnum;
}
However in the exported .proto file, this class ends up with the original enum name as its default value...
syntax = "proto2";
enum MyEnum {
MyEnum_NotSet = 0;
SomeValue= 1;
AndSoOn= 2;
}
message MyClass{
optional MyEnum m_myEnum= 1 [default = NotSet];
}
Using protoc to generate c++ files from this fails - Enum type "MyEnum" has no value named "NotSet".
Is there some step I am missing here?