We usually try hard to avoid introducing new options because of the
maintenance burden they add, so unfortunately I don't think we will be able
to add an option for this. However, it should be pretty easy to
auto-generate these shims if you want to have them for your own codebase.
If you run protoc with --descriptor_set_out=some_file, it will output a
serialized FileDescriptorSet
<https://github.com/protocolbuffers/protobuf/blob/d2d6ff51a8fb67391c44223c6b0b523110ad8d21/src/google/protobuf/descriptor.proto#L57>
proto. You can then have a simple program parse the descriptors, iterate
over any enums and output the enum shims.

On Tue, Aug 6, 2019 at 11:48 PM Danny Pike <[email protected]> wrote:

> I realise that the style guide for Protocol Buffers requires that *enum*
> values be in UPPER_CASE but I am finding that this is increasingly
> conflicting with more modern styles such as C#
> <https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/enumeration-types>,
> C++11
> <https://stackoverflow.com/questions/8005671/namespace-level-enums-in-c>,
> TypeScript <https://www.typescriptlang.org/docs/handbook/enums.html> and
> maybe others that I am less familiar with.
>
> So I find myself increasingly having to add shims manually like this:
>
> enum MyTypes {
>     None = ProtoBufTypes.PT_UNSPECIFIED,
>     Elephant = ProtoBufTypes.PT_ELEPHANT,
>     Banana = ProtoBufTypes.PT_BANANA,
>     Motor = ProtoBufTypes.PT_MOTOR,
>     Alfafa = ProtoBufTypes.PT_ALFAFA
> }
>
> in order to conform to the style guides for the rest of my (non-protobuf)
> code, which naturally introduces a code maintenance issue that I would
> rather avoid.
>
> If you don't want to "modernise" the Google Style guide to allow CamelCase
> for enums, may I suggest that you add an option to protoc that tells it to
> use the enums exactly as I supply them and not to change the casing? Is
> there something inside protoc that will break if you don't use
> all-uppercase?
>
> --
> 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/77d35ce4-14de-48a7-85e9-21108c826949%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/77d35ce4-14de-48a7-85e9-21108c826949%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADqAXr4-KSVdxGiBFZb%2B98QjMq740EyXse2GPnaV3TzuynP-AQ%40mail.gmail.com.

Reply via email to