Added support for internal_access for C#
This commit is contained in:
parent
cef46e115a
commit
a6e39316a7
@ -81,6 +81,8 @@ bool Generator::Generate(
|
|||||||
} 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.base_namespace_specified = true;
|
cli_options.base_namespace_specified = true;
|
||||||
|
} else if (options[i].first == "internal_access") {
|
||||||
|
cli_options.internal_access = true;
|
||||||
} else {
|
} else {
|
||||||
*error = "Unknown generator option: " + options[i].first;
|
*error = "Unknown generator option: " + options[i].first;
|
||||||
return false;
|
return false;
|
||||||
|
@ -64,6 +64,9 @@ struct Options {
|
|||||||
// string, meaning "create a full directory hierarchy, starting from the first
|
// string, meaning "create a full directory hierarchy, starting from the first
|
||||||
// segment of the namespace."
|
// segment of the namespace."
|
||||||
bool base_namespace_specified;
|
bool base_namespace_specified;
|
||||||
|
// Whether the generated classes should have accessibility level of "internal".
|
||||||
|
// Defaults to false that generates "public" classes.
|
||||||
|
bool internal_access;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csharp
|
} // namespace csharp
|
||||||
|
@ -60,7 +60,7 @@ void SourceGeneratorBase::WriteGeneratedCodeAttributes(io::Printer* printer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SourceGeneratorBase::class_access_level() {
|
std::string SourceGeneratorBase::class_access_level() {
|
||||||
return IsDescriptorProto(descriptor_) ? "internal" : "public"; // public_classes is always on.
|
return (IsDescriptorProto(descriptor_) || this->options()->internal_access) ? "internal" : "public";
|
||||||
}
|
}
|
||||||
|
|
||||||
const Options* SourceGeneratorBase::options() {
|
const Options* SourceGeneratorBase::options() {
|
||||||
|
Loading…
Reference in New Issue
Block a user