Skip to content

Name casing in generated code #280

Open
@sveinnthorarins

Description

Is your feature request related to a problem? Please describe.

Release v2.8.0 fixed a bug where name casing was not applied to generated code.
So after updating, the names of all the values for my enum type are now different when generated.

I'll show you a minimal example of what I'm working with...

The enum is called MessageType and is supposed to denote of which type each message is. It has a lot of values so I decided to prefix values with 's' (server) or 'c' (client) to distinguish which actor sends this type of message. So as a result, the values are named with camel case in my message.bop file. The camel case name casing used to carry over to the generated code but now the values are named with pascal case in the generated code.

// message.bop
enum MessageType: uint8 {
    sUserJoined = 10;
    sUserLeft = 11;
    cChooseUsername = 20;
}

// message.ts before v2.8.0
export enum MessageType {
    sUserJoined = 10;
    sUserLeft = 11;
    cChooseUsername = 20;
}

// message.ts after v2.8.0
export enum MessageType {
    SUserJoined = 10;
    SUserLeft = 11;
    CChooseUsername = 20;
}

This causes two different choices of frustration points that I can go for, either I have to always change the generated file after generation or I have to change every line in my codebase that uses the generated enum type and accept this uglier (in my opinion) type of name casing.

Describe the solution you'd like

The first solution that came to mind was to check if there were any arguments for name casing I could give the compiler, but I've looked around in the documentation and can't find a list of possible arguments anywhere (documentation seems to mainly show how to install and lacks documentation of how to actually use tools).

If there is such a list anywhere in the docs and/or such an argument exists, let me know... Otherwise I'd like to propose such an argument option. The options could be for example to make compiler (1) change to pascal case, (2) change to camel case, (3) no case changes, i.e. use the casing as it is in the .bop file.

Let me know what you think. Oh, and thanks for creating and maintaining this project, it rules! :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions