I have the following protobuf message protocol:
message TestMsg
{
int32 int = 1;
google.protobuf.Int32Value nullable_int = 2;
repeated google.protobuf.Int32Value nullable_int_array = 3; // Runtime fail
}
protoc compiles it fine and in C# all Int32Values are int?. But it fail in runtime with a null argument not allowed exception. I can understand repeated
does not not allow null messages. But Int32Value
is a WellKnownType so the compiler could generate a special NullValue type if needed.
Is this a limitation in protobuf (not allowing Int32Value
in repeated
) or is it a limitation/bug in the C# code generation and supporting libraries?
What are the options to do nullable int arrays in protobuf protocol, except creating your own message and codegen?