Skip to content

Generate C# directory hierarchy with new option#785

Merged
jtattermusch merged 5 commits intoprotocolbuffers:masterfrom
jskeet:csharp-directories
Sep 23, 2015
Merged

Generate C# directory hierarchy with new option#785
jtattermusch merged 5 commits intoprotocolbuffers:masterfrom
jskeet:csharp-directories

Conversation

@jskeet
Copy link
Copy Markdown
Contributor

@jskeet jskeet commented Sep 1, 2015

This introduces a new C# option, base_namespace.
If the option is not specified, the behaviour is as before: no directories are generated.
If the option is specified, all C# namespaces must be relative to the base namespace, and the directories are generated relative to that namespace.

Example:

  • Any.proto declares csharp_namespace = "Google.Protobuf.WellKnownTypes"
  • We build with --csharp_out=Google.Protobuf --csharp_opt=base_namespace=Google.Protobuf
  • The Any.cs file is generated in Google.Protobuf/WellKnownTypes (where it currently lives)

This PR fixes #773.

// cc @anandolee

This introduces a new C# option, base_namespace.
If the option is not specified, the behaviour is as before: no directories are generated.
If the option *is* specified, all C# namespaces must be relative to the base namespace, and the directories are generated relative to that namespace.

Example:
- Any.proto declares csharp_namespace = "Google.Protobuf.WellKnownTypes"
- We build with --csharp_out=Google.Protobuf --csharp_opt=base_namespace=Google.Protobuf
- The Any.cs file is generated in Google.Protobuf/WellKnownTypes (where it currently lives)

We need a change to descriptor.proto before this will all work (it wasn't in the right C# namespace) but that needs the other descriptors to be regenerated too. See next commit...
Other changes are due to the well-known types changing without us regenerating.
@jskeet
Copy link
Copy Markdown
Contributor Author

jskeet commented Sep 3, 2015

@jtattermusch Jan, have you had a chance to look at this?

@jskeet
Copy link
Copy Markdown
Contributor Author

jskeet commented Sep 4, 2015

Yes, that's exactly what it will do - at least, that's what it's intended to do :) I'll double-check that it really does do that...

@jtattermusch
Copy link
Copy Markdown
Contributor

@xfxyjwf is there a way to make a command line option "base_namespace" in "--csharp_opt=base_namespace=Google.Protobuf" shared across multiple protoc plugins (C# plugin and gRPC C# plugin in our case)? If so, is that something you would recommend?

@xfxyjwf
Copy link
Copy Markdown
Contributor

xfxyjwf commented Sep 9, 2015

No, there isn't a way to share the command line options between different plugins. Protoc treat each plugin as an independent code generator and do not pass any information between them.

@jtattermusch
Copy link
Copy Markdown
Contributor

Alright, it looks like exposing GetOutputFile in csharp_names.h should be easy, so I will merge this now and expose the function in a followup PR.

jtattermusch added a commit that referenced this pull request Sep 23, 2015
Generate C# directory hierarchy with new option
@jtattermusch jtattermusch merged commit 97a1c1e into protocolbuffers:master Sep 23, 2015
@jskeet jskeet deleted the csharp-directories branch October 8, 2015 15:00
abergmeier pushed a commit to abergmeier/protobuf that referenced this pull request May 15, 2019
This changes protoc-gen-go-grpc to always emit an UnimplementedServer type
that implements the service interface. Users trying to implement
the service interface can embed this type to ensure that new methods
can be added in a forwards compatible manner.
bithium pushed a commit to bithium/protobuf that referenced this pull request Sep 4, 2023
Generate C# directory hierarchy with new option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider populating a directory hierarchy for C# based on namespace

4 participants