Skip to content

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

Closed
@jskeet

Description

@jskeet

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions