aboutsummaryrefslogtreecommitdiff
path: root/src/ProtoGen/DescriptorUtil.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ProtoGen/DescriptorUtil.cs')
-rw-r--r--src/ProtoGen/DescriptorUtil.cs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ProtoGen/DescriptorUtil.cs b/src/ProtoGen/DescriptorUtil.cs
index 14d28bb8..af5a2f9a 100644
--- a/src/ProtoGen/DescriptorUtil.cs
+++ b/src/ProtoGen/DescriptorUtil.cs
@@ -45,11 +45,26 @@ namespace Google.ProtocolBuffers.ProtoGen {
internal static string GetFullUmbrellaClassName(IDescriptor descriptor) {
CSharpFileOptions options = descriptor.File.CSharpOptions;
string result = options.Namespace;
- if (result != "") result += '.';
- result += options.UmbrellaClassname;
+ if (result != "") {
+ result += '.';
+ }
+ result += GetQualifiedUmbrellaClassName(options);
return "global::" + result;
}
+ /// <summary>
+ /// Evaluates the options and returns the qualified name of the umbrella class
+ /// relative to the descriptor type's namespace. Basically concatenates the
+ /// UmbrellaNamespace + UmbrellaClassname fields.
+ /// </summary>
+ internal static string GetQualifiedUmbrellaClassName(CSharpFileOptions options) {
+ string fullName = options.UmbrellaClassname;
+ if (!options.NestClasses && options.UmbrellaNamespace != "") {
+ fullName = String.Format("{0}.{1}", options.UmbrellaNamespace, options.UmbrellaClassname);
+ }
+ return fullName;
+ }
+
internal static string GetMappedTypeName(MappedType type) {
switch(type) {
case MappedType.Int32: return "int";