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

ts_option is not reliable, while using useOptionals=none #369

Open
johan44co opened this issue Feb 8, 2023 · 1 comment
Open

ts_option is not reliable, while using useOptionals=none #369

johan44co opened this issue Feb 8, 2023 · 1 comment

Comments

@johan44co
Copy link

left code generated using; namely/protoc:1.42_2
right code generated using; namely/protoc-all:1.51_1
Screenshot 2023-02-08 at 14 29 49

I have tried passing the option --ts_opt useOptionals=none but it does not have any effect

Proto definition for reference

Screenshot 2023-02-08 at 14 34 12

@abe545
Copy link
Contributor

abe545 commented Feb 8, 2023

Hi @johan44co - I'm wondering if this is an issue with your enum definitions. I know for the C# generation, to get the expected output, the enum items must all be prefixed with the enum name. For instance, the Groups enum should be

enum Groups {
    GROUPS_UNKNOWN = 0;
    GROUPS_TEST_0 = 1;
    GROUPS_TEST_1 = 2;
}

The C# enum for the above would be generated as

public enum Groups {
    Unknown,
    Test0,
    Test1
}

With your current proto definition, the C# code that gets generated would be:

public enum Groups {
    UnknownGroups,
    Test0,
    Test1
}

For your Unlisted enum, since they are not all prefixed with UNLISTED_, the code generation would fail to recognize the prefix, and each item would simply be converted to pascal case in c#. I'm assuming the ts protobuf generator will do something similar with the naming conventions.

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

No branches or pull requests

2 participants