connectrpc/connect-es

Allow keeping original method names

Thalhammer opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
protoc-gen-connect-es always turns the first character of a method name to lower case. While this might make sense for some names (e.g. GenerateThing => generateThing) it makes the names really weird when there are multiple uppercase letters at the front. This is fairly common when the names start with a Group/Type (e.g. IPBanAdd, which turns into iPBanAdd).

Describe the solution you'd like
I think there should be an option to tell protoc-gen-connect-es to just keep the name as it is (like it does for messages and services).

Describe alternatives you've considered

Additional context
The name change happens because of a call to localName here, which calls results in this code returning the mangled name.

Casing of message and service names is left alone because it's best practice to use PascalCase for them in Protobuf and in ECMAScript.

Function and method names are lowerCamelCase in ECMAScript, but it's best practice to use PascalCase in Protobuf. It would be confusing to users to see an object method start with an uppercase letter.

The same applies to Java. A Protobuf RPC IPBanAdd will generate a Java gRPC client method iPBanAdd. The best way to avoid this problem is to capitalize abbreviations as a single word, like the style guide on protobuf.dev recommends.

The good news: It's trivial to write your own plugin for your use case - it's just 50 LoC if you settle on TypeScript output, and you don't have to publish it on npmjs.com to work (see the example here).

The good news: It's trivial to write your own plugin for your use case - it's just 50 LoC if you settle on TypeScript output

Which is what I already did, I just thought a general option to make the output similar between the reference implementation in C++ and Typescript might be useful to others. I guess its not ;)