Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keep_enum_prefix plugin option #187

Merged
merged 3 commits into from
Nov 29, 2021

Conversation

be9
Copy link
Contributor

@be9 be9 commented Nov 17, 2021

This new option, if specified, will instruct the plugin to NOT drop a common shared enum name prefix. By default, the prefix
is removed.

Motivation: my company has a huge legacy TypeScript codebase that uses protobuf.js-generated proto definitions. We want to migrate it to protobuf-ts. Some enums are very pervasive, converted from and to strings with prefix assumed, so it's easier to just keep the damn prefix where it is.

We also have a ton of Go code where prefix is not removed, so for the sake of consistency I want to introduce this new option which is, of course, off by default.

This option, if specified, will instruct the plugin to NOT drop
a common shared enum name prefix. By default, the prefix
is removed as it used to be.
@timostamm
Copy link
Owner

Oleg, I just saw your PR, will have a look soon.

MANUAL.md Outdated Show resolved Hide resolved
packages/plugin/src/protobufts-plugin.ts Outdated Show resolved Hide resolved
@timostamm
Copy link
Owner

We also have a ton of Go code where prefix is not removed, so for the sake of consistency I want to introduce this new option which is, of course, off by default.

Go doesn't have an enum construct, but for languages that do, dropping the prefix is the way to go. The official C# code generator does it, too: https://developers.google.com/protocol-buffers/docs/reference/csharp-generated#enum

I am not a fan of this option, but see that it can be useful for migration.

be9 and others added 2 commits November 29, 2021 13:11
@be9
Copy link
Contributor Author

be9 commented Nov 29, 2021

@timostamm thanks for reviewing, I've accepted your suggestions! I also don't like meaningless prefixes, but these days I care more about safe migrations than aesthetics 😄 (wasn't always the case in my career, heh)

@timostamm timostamm merged commit 8d5f33b into timostamm:master Nov 29, 2021
@be9 be9 deleted the od-enum-prefix-flag branch November 29, 2021 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants