I'm working with a protobuf message that has some of the fields marked for deprecation with [deprecated = true]
.
To my understanding the field can still be used by some part of the code (maybe with a warning).
I want to make sure that my code is still supporting this field with the possibility of handling the case when it actually gets deprecated. Was thinking HasField gives me that tool but sounds like HasField only check if an existing field in a message has been set or not.
In my case my proto message looks roughly like this:
message Message1 {
map<string, Message2> message_collection = 1;
}
message Message2 {
bool some_var = 1 [deprecated = true];
}
I was hoping for a piece of code like this:
my_message = Message1()
for mystr, mymessage2 in my_message.message_collection.items():
if mymessage2.HasField("some_var"):
mymessage2.some_var = True
How can I check if some_var in Message2 is still a defined field or not?