aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jon Skeet <skeet@pobox.com>2016-04-07 22:05:40 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2016-04-07 22:05:40 +0100
commit667f4a6282f9d7e7edb0acc8758e384b17a0359d (patch)
tree90d4bd473450619f77962440f31651a9f959bb61 /src
parent09292d5759cbf3e82dcfae67e01ee31ed8906b5a (diff)
parenta6e39316a7ab891d86aad2a902a1d9d7b23fd95d (diff)
Merge pull request #1393 from gvaish/master
Added support for internal_access for C#
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_generator.cc2
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_options.h3
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc2
3 files changed, 6 insertions, 1 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc
index df9730f8..c13ed65b 100644
--- a/src/google/protobuf/compiler/csharp/csharp_generator.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc
@@ -81,6 +81,8 @@ bool Generator::Generate(
} else if (options[i].first == "base_namespace") {
cli_options.base_namespace = options[i].second;
cli_options.base_namespace_specified = true;
+ } else if (options[i].first == "internal_access") {
+ cli_options.internal_access = true;
} else {
*error = "Unknown generator option: " + options[i].first;
return false;
diff --git a/src/google/protobuf/compiler/csharp/csharp_options.h b/src/google/protobuf/compiler/csharp/csharp_options.h
index 9e5573ca..f25812c8 100644
--- a/src/google/protobuf/compiler/csharp/csharp_options.h
+++ b/src/google/protobuf/compiler/csharp/csharp_options.h
@@ -64,6 +64,9 @@ struct Options {
// string, meaning "create a full directory hierarchy, starting from the first
// segment of the namespace."
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
diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
index bd459dda..16411e49 100644
--- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
@@ -60,7 +60,7 @@ void SourceGeneratorBase::WriteGeneratedCodeAttributes(io::Printer* printer) {
}
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() {