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

Fields beginning with _{digit} generate invalid C# code #308

Closed
jskeet opened this issue Apr 28, 2015 · 1 comment
Closed

Fields beginning with _{digit} generate invalid C# code #308

jskeet opened this issue Apr 28, 2015 · 1 comment
Assignees
Labels

Comments

@jskeet
Copy link
Contributor

jskeet commented Apr 28, 2015

A proto like this:

Generates C# code like this:

public const int 0FieldNumber = 1;
private bool has0;
private string 0_ = "";
public bool Has0 {
  get { return has0; }
}
public string 0 {
  get { return 0_; }
}

The 0FieldNumber, 0 and 0_ field/property names are invalid.

It looks like the Java code generator creates invalid code for this too, so although this is a regression in the C# codegen compared with the protobuf-csharp-port generator, we might deem it a reasonable restriction - but it would probably make sense to prohibit it explicitly.

@jskeet
Copy link
Contributor Author

jskeet commented Apr 28, 2015

In the protobuf-csharp-port codebase, this was fixed by
jskeet/protobuf-csharp-port@1851676

jskeet added a commit to jskeet/protobuf that referenced this issue Apr 28, 2015
This commit includes changes to the C#-specific protos, and rebuilt versions of the "stock" protos.
The stock protos have been locally updated to have a specific C# namespace, but this is expected to change soon, so hasn't been committed.
Four areas are currently not tested:
1) Serialization - we may restore this at some point, possibly optionally.
2) Services - currently nothing is generated for this; will need to see how it interacts with GRPC
3) Fields beginning with _{digit} - see protocolbuffers#308
4) Fields with names which conflict with the declaring type in nasty ways - see protocolbuffers#309
@jskeet jskeet added c# and removed c# labels Apr 29, 2015
@jskeet jskeet self-assigned this Aug 3, 2015
@liujisi liujisi closed this as completed Mar 7, 2017
xykong pushed a commit to xykong/protobuf-for-unity that referenced this issue Feb 24, 2018
This commit includes changes to the C#-specific protos, and rebuilt versions of the "stock" protos.
The stock protos have been locally updated to have a specific C# namespace, but this is expected to change soon, so hasn't been committed.
Four areas are currently not tested:
1) Serialization - we may restore this at some point, possibly optionally.
2) Services - currently nothing is generated for this; will need to see how it interacts with GRPC
3) Fields beginning with _{digit} - see protocolbuffers/protobuf#308
4) Fields with names which conflict with the declaring type in nasty ways - see protocolbuffers/protobuf#309
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants