Commit 2a18bb5a authored by Jon Skeet's avatar Jon Skeet

Add more documentation for csharp_options.h

This also renames generate_directories to base_namespace_specified; generating directories is the
immediate *effect* of specifying a base namespace, but with this change the options reflect what has been
specified rather than the effect. (There may be other effects in the future, of course.)
parent bfd1c84a
...@@ -80,7 +80,7 @@ bool Generator::Generate( ...@@ -80,7 +80,7 @@ bool Generator::Generate(
cli_options.file_extension = options[i].second; cli_options.file_extension = options[i].second;
} else if (options[i].first == "base_namespace") { } else if (options[i].first == "base_namespace") {
cli_options.base_namespace = options[i].second; cli_options.base_namespace = options[i].second;
cli_options.generate_directories = true; cli_options.base_namespace_specified = true;
} else { } else {
*error = "Unknown generator option: " + options[i].first; *error = "Unknown generator option: " + options[i].first;
return false; return false;
...@@ -90,7 +90,7 @@ bool Generator::Generate( ...@@ -90,7 +90,7 @@ bool Generator::Generate(
string filename_error = ""; string filename_error = "";
std::string filename = GetOutputFile(file, std::string filename = GetOutputFile(file,
cli_options.file_extension, cli_options.file_extension,
cli_options.generate_directories, cli_options.base_namespace_specified,
cli_options.base_namespace, cli_options.base_namespace,
&filename_error); &filename_error);
......
...@@ -44,14 +44,26 @@ struct Options { ...@@ -44,14 +44,26 @@ struct Options {
Options() : Options() :
file_extension(".cs"), file_extension(".cs"),
base_namespace(""), base_namespace(""),
generate_directories(false) { base_namespace_specified(false) {
} }
// Extension of the generated file. Defaults to ".cs" // Extension of the generated file. Defaults to ".cs"
string file_extension; string file_extension;
// Base namespace to use to create directory hierarchy. Defaults to "" // Base namespace to use to create directory hierarchy. Defaults to "".
// This option allows the simple creation of a conventional C# file layout,
// where directories are created relative to a project-specific base
// namespace. For example, in a project with a base namespace of PetShop, a
// proto of user.proto with a C# namespace of PetShop.Model.Shared would
// generate Model/Shared/User.cs underneath the specified --csharp_out
// directory.
//
// If no base namespace is specified, all files are generated in the
// --csharp_out directory, with no subdirectories created automatically.
string base_namespace; string base_namespace;
// Whether or not to generate directory hierarchy. Defaults to false // Whether the base namespace has been explicitly specified by the user.
bool generate_directories; // This is required as the base namespace can be explicitly set to the empty
// string, meaning "create a full directory hierarchy, starting from the first
// segment of the namespace."
bool base_namespace_specified;
}; };
} // namespace csharp } // namespace csharp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment