[monodoc] Fixed several issues with `.ToEcmaCRef` method.
[mono.git] / mcs / class / monodoc / Monodoc.Ecma / EcmaDesc.cs
index ccf4b4bb12d91b9720c874de7062d13928296514..2f46c6cc0fddccb6aa562c3bc515ef73c0727b35 100644 (file)
@@ -226,32 +226,24 @@ namespace Monodoc.Ecma
                        return sb.ToString ();
                }
 
-               void ConstructCRef (StringBuilder sb)
+               void ConstructCRef (StringBuilder sb, bool skipLeadingDot = false)
                {
+                       if (string.IsNullOrEmpty (Namespace))
+                               skipLeadingDot = true;
+
                        sb.Append (Namespace);
                        if (DescKind == Kind.Namespace)
                                return;
 
-                       sb.Append ('.');
+                       if (!skipLeadingDot)
+                               sb.Append ('.');
+
                        sb.Append (TypeName);
-                       if (GenericTypeArguments != null && GenericTypeArgumentsIsNumeric) {
-                               sb.AppendFormat ("`{0}", GenericTypeArgumentsCount);
-                       } else if (GenericTypeArguments != null) {
-                               sb.Append ('<');
-                               int i=0;
-                               foreach (var t in GenericTypeArguments) {
-                                       if (i > 0) {
-                                               sb.Append (",");
-                                       }
-                                       t.ConstructCRef (sb);
+                       AppendGenericArguments (sb, GenericTypeArguments, GenericTypeArgumentsIsNumeric, GenericTypeArgumentsCount);
 
-                                       i++;
-                               }
-                               sb.Append ('>');
-                       }
                        if (NestedType != null) {
                                sb.Append ('+');
-                               NestedType.ConstructCRef (sb);
+                               NestedType.ConstructCRef (sb, skipLeadingDot: true);
                        }
                        if (ArrayDimensions != null && ArrayDimensions.Count > 0) {
                                for (int i = 0; i < ArrayDimensions.Count; i++) {
@@ -263,9 +255,18 @@ namespace Monodoc.Ecma
                        if (DescKind == Kind.Type)
                                return;
 
+                       if (ExplicitImplMember != null) {
+                               sb.Append ('$');
+                               ExplicitImplMember.DescKind = this.DescKind;
+                               ExplicitImplMember.ConstructCRef (sb, skipLeadingDot: false);
+                               return;
+                       }
+
                        sb.Append (".");
                        sb.Append (MemberName);
 
+                       AppendGenericArguments (sb, GenericMemberArguments, GenericMemberArgumentsIsNumeric, GenericMemberArgumentsCount);
+
                        if (MemberArguments != null && MemberArgumentsCount > 0) {
                                sb.Append ("(");
                                int i=0;
@@ -280,6 +281,25 @@ namespace Monodoc.Ecma
                        }
                }
 
+               void AppendGenericArguments (StringBuilder sb, IEnumerable<EcmaDesc> arguments, bool isNumeric, int argumentsCount)
+               {
+                       if (arguments != null && isNumeric) {
+                               sb.AppendFormat ("`{0}", argumentsCount);
+                       } else if (arguments != null) {
+                               sb.Append ('<');
+                               int i=0;
+                               foreach (var t in arguments) {
+                                       if (i > 0) {
+                                               sb.Append (",");
+                                       }
+                                       t.ConstructCRef (sb);
+
+                                       i++;
+                               }
+                               sb.Append ('>');
+                       }
+               }
+
                public override string ToString ()
                {
                        return string.Format ("({8}) {0}::{1}{2}{3}{7} {4}{5}{6} {9} {10}",