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

[c#] Generated code for non-alphanumeric enum names is invalid #19134

Closed
saquibmian opened this issue Nov 5, 2024 · 3 comments
Closed

[c#] Generated code for non-alphanumeric enum names is invalid #19134

saquibmian opened this issue Nov 5, 2024 · 3 comments
Labels
c# inactive Denotes the issue/PR has not seen activity in the last 90 days.

Comments

@saquibmian
Copy link

What version of protobuf and what language are you using?
Version: v28.3
Language: C#

What operating system (Linux, Windows, ...) and version?
macOS

What runtime / compiler are you using (e.g., python version or gcc version)
protoc

What did you do?
Steps to reproduce the behavior:

  1. Write foo.proto with the following content.
    syntax = "proto3";
    
    package foo.v1;
    
    enum Foo {
      _ = 0;
    }
  2. Run protoc -I . --csharp_out=. foo.proto

What did you expect to see
Foo.cs should contain the following definition:

public enum Foo {
  [pbr::OriginalName("_")]  _ = 0,
}

What did you see instead?
Foo.cs contains the following definition, which does not compile (missing enum name):

public enum Foo {
  [pbr::OriginalName("_")]  = 0,
}

Anything else we should know about your project / environment
Nothing else.

@saquibmian saquibmian added the untriaged auto added to all issues by default when created. label Nov 5, 2024
@jskeet jskeet added c# and removed untriaged auto added to all issues by default when created. labels Nov 5, 2024
@jskeet
Copy link
Contributor

jskeet commented Nov 5, 2024

I agree we shouldn't generate invalid code. Whether just _ is the right name to generate is up for discussion, given that _ has a "somewhat" special meaning in C#. (For an enum value that make be okay - for a field it could be pretty confusing. It's worth thinking about how it might be used in all contexts rather than just enums.)

I think it's unlikely that we're going to get to this corner case any time soon - but if you have the time to create a PR to change the C# generator code to fix this, I'd happily review it.

Copy link

github-actions bot commented Feb 4, 2025

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Feb 4, 2025
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c# inactive Denotes the issue/PR has not seen activity in the last 90 days.
Projects
None yet
Development

No branches or pull requests

2 participants