I have nullable enum in my code which I'm trying to define in my .proto file but when I generate the C# class the enum is not nullable. Here is my proto file
enum Foo {
Bar = 0;
Bat = 1;
}
message FooBar {
int32 Id = 1;
optional Foo Foo = 2;
}
I've read about two possible solutions.
- Use
oneof
but this way I can't set theBar
to be0
- Add
Unknown = 0;
but this is not backward compatible with the existing data where the0
element has different meaning
Is there another options or it is not possible to make Nullable<Enum>
as of now?
Thanks