Do you have/can you make a simple example of this for me to reproduce it? How are you setting the bool to false? Is this proto2 or proto3?
In proto3 if you did not qualify your field with "optional", this is unfortunately working as intended <https://github.com/protocolbuffers/protobuf/issues/1772>. I think if you explicitly list the field as "optional" ListFields should work like you want it to. If this is happening in proto2 after you explicitly set the bool to false, this is not expected behavior and you should file a bug <https://github.com/protocolbuffers/protobuf/issues> in our repository with more details. On Tuesday, August 2, 2022 at 6:26:02 AM UTC-7 [email protected] wrote: > I need to get all fields of Message, which are set, with reflection, so > i usegoogle::protobuf::Reflection::ListFields. > google::protobuf::Reflection::ListFields returns a vector, that contains > google::protobuf::FieldDescriptor(variables of Proto Message) of > google::protobuf::Message, *which are currently set*. > I have two variables in proto message of type bool, which i set on > false and true, so when i call ListFields, it returns a vector without > bool, which set on *false,* but with bool, which set on *true*. I suggest > it happens because bool in binary format in protobuf messages is Varint > type. [image: Снимок экрана от 2022-08-02 18-13-22.png] > And when Varint is zero(because 'false' becomes a zero) ListFields thinks > that this variable is not set, because it set on zero. > So the question: how can i get this variable if it isn't in Listfields > vector? > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/d687abfd-9dba-42f5-a33c-3c238211bd80n%40googlegroups.com.
