You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with classes generated from enums, sometimes I have a string and I'd like to grab the corresponding object whose name matches that string. A fromName function within generated enum classes would be helpful so we don't have to write many-line when statements to match strings to their corresponding enum objects.
The text was updated successfully, but these errors were encountered:
The complication here is which enum name to support when an enum's variations all start with the enum name prefix. In this case protokt will cut off the prefix in generated code since the name of a protobuf enum is not important. Which name should be supported in fromName - the original declared name with the prefix, which is used e.g. in the proto3 JSON spec (which also supports the number instead https://protobuf.dev/programming-guides/proto3/#json), or the name in the generated code without it?
When working with classes generated from enums, sometimes I have a string and I'd like to grab the corresponding object whose name matches that string. A
fromName
function within generated enum classes would be helpful so we don't have to write many-linewhen
statements to match strings to their corresponding enum objects.The text was updated successfully, but these errors were encountered: