aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2008-08-14 20:35:35 +0100
committerJon Skeet <skeet@pobox.com>2008-08-14 20:35:35 +0100
commiteb4ef52c66a8e9f9a0477936adf4444ae37dd045 (patch)
tree8f9fd99e786dd5361a127affcc92285c980b27b0 /src
parent5407a4329d578d8858cbcb3097b29a438fb03e43 (diff)
downloadprotobuf-eb4ef52c66a8e9f9a0477936adf4444ae37dd045.tar.gz
protobuf-eb4ef52c66a8e9f9a0477936adf4444ae37dd045.tar.bz2
protobuf-eb4ef52c66a8e9f9a0477936adf4444ae37dd045.zip
Abandon the 'self' namespace alias - we need to be able to import types in other namespaces too.
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_file.cc4
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.cc13
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) {