fixing implementation of GetFileUmbrellaNamespace

pull/288/head
Jan Tattermusch 10 years ago
parent 5ac8de5b46
commit 7cc05ecb3a
  1. 40
      src/google/protobuf/compiler/csharp/csharp_helpers.cc

@ -127,26 +127,30 @@ std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor) {
} }
std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) { std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) {
if (!descriptor->options().has_csharp_umbrella_namespace()) { if (descriptor->options().has_csharp_umbrella_namespace()) {
bool collision = false; return descriptor->options().csharp_umbrella_namespace();
// TODO(jtattermusch): detect collisions! }
// foreach (IDescriptor d in MessageTypes) bool collision = false;
// { std::string umbrella_classname = GetFileUmbrellaClassname(descriptor);
// collision |= d.Name == builder.UmbrellaClassname; for(int i = 0; i < descriptor->message_type_count(); i++) {
// } if (descriptor->message_type(i)->name() == umbrella_classname) {
// foreach (IDescriptor d in Services) collision = true;
// { break;
// collision |= d.Name == builder.UmbrellaClassname; }
// } }
// foreach (IDescriptor d in EnumTypes) for (int i = 0; i < descriptor->service_count(); i++) {
// { if (descriptor->service(i)->name() == umbrella_classname) {
// collision |= d.Name == builder.UmbrellaClassname; collision = true;
// } break;
if (collision) { }
return "Proto"; }
for (int i = 0; i < descriptor->enum_type_count(); i++) {
if (descriptor->enum_type(i)->name() == umbrella_classname) {
collision = true;
break;
} }
} }
return ""; return collision ? "Proto" : "";
} }
// TODO(jtattermusch): can we reuse a utility function? // TODO(jtattermusch): can we reuse a utility function?

Loading…
Cancel
Save