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

Feature: add option to avoid nested messages to be under "Types" class. #75

Open
GoogleCodeExporter opened this issue Apr 7, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Please provide any additional information below.

Consider the following .proto file:

message OutterMsg {
  message InnerMsg {}
  optional InnerMsg inner_msg = 1;
}

Currently, produced code looks like this:

class OutterMsg {
  class Types {
    class InnerMsg {...}
  }
  Types.InnerMsg InnerMsg;
}

Which means that to declare a builder for InnerMsg, one needs to type:

  OutterMsg.Types.InnerMsg msg;

That's rather long.

It's known that "Types" nested class is used to avoid clashing sub-message and 
Property names.

Another way to avoid such problem is to prefix sub-message names. For instance, 
a leading underscore char should suffice for 99% of the cases. Produced code 
would look like the following:

class OutterMsg {
  class _InnerMsg {...}
  _InnerMsg InnerMsg;
}

Declaration would look like:

  OutterMsg._InnerMsg msg;

A per-message (and perhaps a per-proto-file) option string 
csharp_nesting_prefix should work just fine. Proto file would look like the 
following:

message OutterMsg {
  option (csharp_nesting_prefix) = "_";

  message InnerMsg {}
  optional InnerMsg inner_msg = 1;
}

Original issue reported on code.google.com by [email protected] on 21 Feb 2014 at 11:22

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

No branches or pull requests

1 participant