-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Milestone
Description
According to the Style Guide, protobuf enums should have the enum name as a prefix for all enum values, to avoid naming conflicts in languages like C, where all values from all enums are in the global namespace. Protobuf compilers for languages with scoped enums like C# will strip these prefixes if they match the enum name. Since enums in betterproto are scoped as well, these prefixes should be stripped.
Example:
enum ArithmeticOperator {
ARITHMETIC_OPERATOR_NONE = 0;
ARITHMETIC_OPERATOR_PLUS = 1;
ARITHMETIC_OPERATOR_MINUS = 2;
}
should become
class ArithmeticOperator(betterproto.Enum):
NONE = 0
PLUS = 1
MINUS = 2
so that we can use it as
if something.operator == ArithmeticOperator.PLUS:
do_addition()
instead of
if something.operator == ArithmeticOperator.ARITHMETIC_OPERATOR_PLUS:
do_addition()
wonderbeyond and terax6669wonderbeyond
Metadata
Metadata
Assignees
Labels
No labels