aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2015-08-13 12:01:41 +0100
committerGravatar Jon Skeet <jonskeet@google.com>2015-08-13 12:01:41 +0100
commita39ababb7cf8839d96b3347e0da87fbcc3d512e8 (patch)
treee08353c9677af5b1b200cb8189b45e91dc0840a3 /src
parentf818183f9b0c0c8838dd99c54923d8dd6c11d4ed (diff)
Allow public access to descriptor.proto as a dependency.
With this in place, generating APIs on github.com/google/googleapis works - previously annotations.proto failed. Currently there's no access to the annotations (stored as extensions) but we could potentially expose those at a later date.
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.h5
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc9
2 files changed, 12 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h
index 1d17af61..278e05f3 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.h
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h
@@ -117,7 +117,10 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
inline bool IsDescriptorProto(const FileDescriptor* descriptor) {
// TODO: Do this better! (Currently this depends on a hack in generate_protos.sh to rename
// the file...)
- return descriptor->name() == "google/protobuf/descriptor_proto_file.proto";
+ // We need to be able to detect the "normal" name as well, for times that we're just
+ // depending on descriptor.proto instead of generating it.
+ return descriptor->name() == "google/protobuf/descriptor_proto_file.proto"
+ || descriptor->name() == "google/protobuf/descriptor.proto";
}
inline bool IsWrapperType(const FieldDescriptor* descriptor) {
diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc
index 0ffae3d4..399c64e1 100644
--- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc
@@ -180,10 +180,17 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) {
"descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,\n");
printer->Print(" new pbr::FileDescriptor[] { ");
for (int i = 0; i < file_->dependency_count(); i++) {
- printer->Print(
+ // descriptor.proto is special: we don't allow access to the generated code, but there's
+ // a separately-exposed property to get at the file descriptor, specifically to allow this
+ // kind of dependency.
+ if (IsDescriptorProto(file_->dependency(i))) {
+ printer->Print("pbr::FileDescriptor.DescriptorProtoFileDescriptor, ");
+ } else {
+ printer->Print(
"$full_umbrella_class_name$.Descriptor, ",
"full_umbrella_class_name",
GetUmbrellaClassName(file_->dependency(i)));
+ }
}
printer->Print("},\n"
" new pbr::GeneratedCodeInfo(");