Skip to content

Consider populating a directory hierarchy for C# based on namespace #773

@jskeet

Description

@jskeet

Currently we don't do this because in .NET projects there tends to be a "base" namespace, but I think we'll want to address this with another flag, based on a bit of experience of trying to use the current approach.

Proposal:

  • Add a new flag of csharp_base_package
  • When working out where to generate code, generate a directory name based on the namespace from the base package onwards. For example, if the base package is a.b and the declared package for the .proto file is a.b.c.d, create a directory of C.D and put the code in there, in a namespace of A.B.C.D
  • If csharp_base_package isn't specified, treat it as empty (e.g. create a directory of A.B.C.D in the above example)
  • If csharp_base_package is specified but the .proto package doesn't start with that, fail

Alternatives to consider:

  • Specify the base namespace instead of base package (e.g. A.B instead of a.b)
  • Have yet another flag to allow the existing behaviour of not creating directories

The GRPC plugin should do the same thing.

Thoughts?

@anandolee @jtattermusch

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions