diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_file.cc | 4 | ||||
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_helpers.cc | 13 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_file.cc b/src/google/protobuf/compiler/csharp/csharp_file.cc index 286c408a..4c0d7443 100644 --- a/src/google/protobuf/compiler/csharp/csharp_file.cc +++ b/src/google/protobuf/compiler/csharp/csharp_file.cc @@ -95,8 +95,6 @@ void FileGenerator::Generate(io::Printer* printer) { printer->Print("using scg = global::System.Collections.Generic;\r\n"); if (!csharp_namespace_.empty()) { - printer->Print("using self = global::$selfnamespace$;\r\n\r\n", - "selfnamespace", csharp_namespace_); printer->Print( "namespace $namespace$ {\r\n", "namespace", csharp_namespace_); @@ -238,8 +236,6 @@ static void GenerateSibling(const string& csharp_namespace, printer.Print("using scg = global::System.Collections.Generic;\r\n"); if (!csharp_namespace.empty()) { - printer.Print("using self = global::$selfnamespace$;\r\n\r\n", - "selfnamespace", csharp_namespace); printer.Print( "namespace $namespace$ {\r\n", "namespace", csharp_namespace); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 067a7324..5747e5be 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -138,7 +138,7 @@ string FileCSharpNamespace(const FileDescriptor* file) { string ToCSharpName(const string& full_name, const FileDescriptor* file) { string result; if (!file->options().csharp_nest_classes()) { - result = ""; + result = FileCSharpNamespace(file); } else { result = ClassName(file); } @@ -150,17 +150,18 @@ string ToCSharpName(const string& full_name, const FileDescriptor* file) { classname = full_name; } else { // Strip the proto package from full_name since we've replaced it with - // the C# package. + // the C# namespace. classname = full_name.substr(file->package().size() + 1); } result += StringReplace(classname, ".", ".Types.", true); - const char *prefix = FileCSharpNamespace(file).empty() ? "global::" : "self::"; - return prefix + result; + return "global::" + result; } string ClassName(const FileDescriptor* descriptor) { - string alias = FileCSharpNamespace(descriptor).empty() ? "global::" : "self::"; - return alias + FileClassName(descriptor); + string result = FileCSharpNamespace(descriptor); + if (!result.empty()) result += '.'; + result += FileClassName(descriptor); + return "global::" + result; } MappedType GetMappedType(FieldDescriptor::Type field_type) { |