Closed GoogleCodeExporter closed 9 years ago
I can look at improving the output, but fundamentally my understanding is that
the protobuf specification does not support [Flags] / enum bitmasks.
Prototobuf-net passes them through as ints, so I suspect the only sane thing I
can do here is describe it as int on the .proto schema. I can perhaps list the
flags etc as comments?
Original comment by marc.gravell
on 18 Oct 2012 at 4:25
We currently have a C++ application that communicates with a C# application
using an enum of this type, and we use protogen and protoc to create the
classes to send /receive this enum.
Here is .proto syntax of the enum (with names changed to protect innocent
variables):
enum EFlags
{
TF_P = 0x00000001;
TF_D = 0x00000002;
TF_G = 0x00000004;
TF_SP = 0x00000008;
TF_SKD = 0x00000010;
TF_SKG = 0x00000020;
TF_VE = 0x00000040;
TF_VO = 0x00000080;
TF_RH = 0x00000100;
TF_AC = 0x00000200;
TF_FO = 0x00000400;
TF_ALL = 0x7FFFFFFF; // highest bit not usable due to network serialization
}
Here is the C++ enum as generated by protoc:
enum EFlags {
TF_P = 1,
TF_D = 2,
TF_G = 4,
TF_SP = 8,
TF_SKD = 16,
TF_SKG = 32,
TF_VE = 64,
TF_VO = 128,
TF_RH = 256,
TF_AC = 512,
TF_FO = 1024,
TF_ALL = 2147483647
};
And here is the protogen generated C# enum:
public enum ETheoFlags {
TF_P = 1,
TF_D = 2,
TF_G = 4,
TF_SP = 8,
TF_SKD = 16,
TF_SKG = 32,
TF_VE = 64,
TF_VO = 128,
TF_RH = 256,
TF_AC = 512,
TF_FO = 1024,
TF_ALL = 2147483647,
}
Is it possible to have protobuf-net do something similar?
Thanks! :)
Original comment by Franches...@gmail.com
on 19 Oct 2012 at 8:31
Fixed r596
Original comment by marc.gravell
on 19 Oct 2012 at 9:23
Original issue reported on code.google.com by
Franches...@gmail.com
on 18 Oct 2012 at 3:47