Skip to content

[C#]: Provide a switch so that the C# code generator can just ignore proto2 syntax features, rather than erroring out #2991

Closed
@DavidR91

Description

Currently, attempting to generate C# from a proto2 file produces the following:

C# code generation only supports proto3 syntax

This makes sense - however, it would be tremendously useful to have a mode/switch that will silently ignore the unsupported syntax, and produce code that just doesn't honour the required/optional statements

Rationale

proto files are frequently shared between multiple languages/tools - and because 'required' is enforced differently by certain libraries/implementations, sometimes it is useful to have this statement in the .proto, even if you don't want it to do anything when using C# codegen

For example, protobuf-jsonschema can generate JSON schemas with the necessary 'required' attributes.

Moving to proto3

Moving to proto3 syntax and just dropping required and optional is fine - the problem is that other tools/libraries that are doing something useful with the extra attributes cease to do so

The only alternative is to either have multiple copies of the file (which is obviously not helpful) or to preprocess the files ourselves before running protoc

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions