Author: jonpryor
Date: 2007-06-11 13:49:56 -0400 (Mon, 11 Jun 2007)
New Revision: 79200

Modified:
   trunk/monodoc/tools/ChangeLog
   trunk/monodoc/tools/monodocer.cs
Log:
        * monodocer.cs: Add support for renaming of template parameters (useful
          because ECMA 335 refers to Array.ConvertAll<T,U> while Mono/.NET have
          Array.ConvertAll<TInput,TOutput>).  Not terribly intelligent, but 
smart
          enough that all but two System.Array members can now be imported (a
          private constructor, and a member with an incorrectly documented 
parameter
          type, neither of which I plan on supporting).  Cleanup some of the
          `#if NET_1_0` blocks by using `using' aliases -- alas, requires 
moving the
          [assembly:...] attributes; see bugzilla #81855.


Modified: trunk/monodoc/tools/ChangeLog
===================================================================
--- trunk/monodoc/tools/ChangeLog       2007-06-11 17:40:52 UTC (rev 79199)
+++ trunk/monodoc/tools/ChangeLog       2007-06-11 17:49:56 UTC (rev 79200)
@@ -1,5 +1,16 @@
 2007-06-11  Jonathan Pryor  <[EMAIL PROTECTED]>
 
+       * monodocer.cs: Add support for renaming of template parameters (useful
+         because ECMA 335 refers to Array.ConvertAll<T,U> while Mono/.NET have
+         Array.ConvertAll<TInput,TOutput>).  Not terribly intelligent, but 
smart
+         enough that all but two System.Array members can now be imported (a
+         private constructor, and a member with an incorrectly documented 
parameter
+         type, neither of which I plan on supporting).  Cleanup some of the 
+         `#if NET_1_0` blocks by using `using' aliases -- alas, requires 
moving the
+         [assembly:...] attributes; see bugzilla #81855.
+
+2007-06-11  Jonathan Pryor  <[EMAIL PROTECTED]>
+
        * monodocer.cs: Add support for explicity-implemented interface members.
          Minor cleanup.  Replace catch(NotSupportedException){} blocks.
        * Makefile.am (clean): Cleanup monodocer.exe* files.

Modified: trunk/monodoc/tools/monodocer.cs
===================================================================
--- trunk/monodoc/tools/monodocer.cs    2007-06-11 17:40:52 UTC (rev 79199)
+++ trunk/monodoc/tools/monodocer.cs    2007-06-11 17:49:56 UTC (rev 79200)
@@ -14,12 +14,16 @@
 
 using Mono.GetOptions;
 
-[assembly: AssemblyTitle("Monodocer - The Mono Documentation Tool")]
-[assembly: AssemblyCopyright("Copyright (c) 2004 Joshua Tauberer <[EMAIL 
PROTECTED]>\nreleased under the GPL.")]
-[assembly: AssemblyDescription("A tool for creating and updating Mono XML 
documentation files for assemblies.")]
+#if NET_1_0
+using DocsEnumerable       = System.Collections.IEnumerable;
+using MemberInfoEnumerable = System.Collections.IEnumerable;
+using StringList           = System.Collections.ArrayList;
+#else
+using DocsEnumerable       = 
System.Collections.Generic.IEnumerable<Stub.DocsNodeInfo>;
+using MemberInfoEnumerable = 
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>;
+using StringList           = System.Collections.Generic.List<string>;
+#endif
 
-[assembly: Mono.UsageComplement("")]
-
 public class Stub {
        
        static string srcPath;
@@ -706,13 +710,7 @@
                writer.Close();
        }
 
-       private static 
-#if NET_1_0
-               IEnumerable
-#else
-               IEnumerable<DocsNodeInfo>
-#endif
-               GetDocumentationMembers (XmlDocument basefile, Type type, 
XmlNode ecmaDocsType)
+       private static DocsEnumerable GetDocumentationMembers (XmlDocument 
basefile, Type type, XmlNode ecmaDocsType)
        {
                if (ecmadocs == null) {
                        foreach (XmlElement oldmember in 
basefile.SelectNodes("Type/Members/Member")) {
@@ -801,23 +799,31 @@
                foreach (XmlElement param in 
member.SelectNodes("Parameters/Parameter"))
                        memberparams.Add(param.GetAttribute("Type"));
 
+               string docName = member.GetAttribute ("MemberName");
+               string[] docTypeParams = GetTypeParameters (docName);
+
                // Loop through all members in this type with the same name
-               foreach (MemberInfo mi in GetReflectionMembers (type, 
member.GetAttribute ("MemberName"))) {
+               foreach (MemberInfo mi in GetReflectionMembers (type, docName)) 
{
                        if (mi is Type) continue;
                        if (GetMemberType(mi) != membertype) continue;
 
                        string sig = MakeMemberSignature(mi);
                        if (sig == null) continue; // not publicly visible
 
-                       if (mi is MethodInfo) {
-                               // Casting operators can overload based on 
return type.
-                               if (returntype != GetDocTypeFullName 
(((MethodInfo)mi).ReturnType)) 
-                                       continue;
+                       ParameterInfo[] pis = null;
+                       string[] typeParams = null;
+                       if (mi is MethodInfo || mi is ConstructorInfo) {
+                               MethodBase mb = (MethodBase) mi;
+                               pis = mb.GetParameters();
+                               if (docTypeParams != null && 
DocUtils.GetContainsGenericParameters (mb)) {
+                                       Type[] args = 
DocUtils.GetGenericArguments (mb);
+                                       if (args.Length == 
docTypeParams.Length) {
+                                               typeParams = new string 
[args.Length];
+                                               for (int i = 0; i < 
args.Length; ++i)
+                                                       typeParams [i] = args 
[i].Name;
+                                       }
+                               }
                        }
-
-                       ParameterInfo[] pis = null;
-                       if (mi is MethodInfo || mi is ConstructorInfo)
-                               pis = ((MethodBase)mi).GetParameters();
                        else if (mi is PropertyInfo)
                                pis = ((PropertyInfo)mi).GetIndexParameters();
                        
@@ -826,12 +832,25 @@
                                
                        if (pis.Length != memberparams.Count) continue;
                        
+                       if (mi is MethodInfo) {
+                               // Casting operators can overload based on 
return type.
+                               if (returntype != GetReplacedString (
+                                                       GetDocTypeFullName 
(((MethodInfo)mi).ReturnType), 
+                                                       typeParams, 
docTypeParams)) {
+                                       continue;
+                               }
+                       }
+
                        bool good = true;
-                       for (int i = 0; i < pis.Length; i++)
-                               if (GetDocParameterType (pis[i].ParameterType) 
!= (string)memberparams[i]) {
+                       for (int i = 0; i < pis.Length; i++) {
+                               string paramType = GetReplacedString (
+                                       GetDocParameterType (pis 
[i].ParameterType),
+                                       typeParams, docTypeParams);
+                               if (paramType != (string)memberparams[i]) {
                                        good = false;
                                        break;
                                }
+                       }
                        if (!good) continue;
 
                        return mi;
@@ -840,13 +859,7 @@
                return null;
        }
 
-       private static
-#if NET_1_0
-               IEnumerable
-#else
-               IEnumerable<MemberInfo>
-#endif
-               GetReflectionMembers (Type type, string docName)
+       private static MemberInfoEnumerable GetReflectionMembers (Type type, 
string docName)
        {
                // need to worry about 4 forms of //@MemberName values:
                //  1. "Normal" (non-generic) member names: GetEnumerator
@@ -924,6 +937,39 @@
                                yield return mi;
                }
        }
+
+       static string[] GetTypeParameters (string docName)
+       {
+               if (docName [docName.Length-1] != '>')
+                       return null;
+               StringList types = new StringList ();
+               int endToken = docName.Length-2;
+               int i = docName.Length-2;
+               do {
+                       if (docName [i] == ',' || docName [i] == '<') {
+                               types.Add (docName.Substring (i + 1, endToken - 
i));
+                               endToken = i-1;
+                       }
+                       if (docName [i] == '<')
+                               break;
+               } while (--i >= 0);
+
+               types.Reverse ();
+#if NET_1_0
+               return (string[]) types.ToArray (typeof(string));
+#else
+               return types.ToArray ();
+#endif
+       }
+
+       static string GetReplacedString (string typeName, string[] from, 
string[] to)
+       {
+               if (from == null)
+                       return typeName;
+               for (int i = 0; i < from.Length; ++i)
+                       typeName = typeName.Replace (from [i], to [i]);
+               return typeName;
+       }
        
        // CREATE A STUB DOCUMENTATION FILE     
 
@@ -2900,3 +2946,9 @@
        }
 }
 
+[assembly: AssemblyTitle("Monodocer - The Mono Documentation Tool")]
+[assembly: AssemblyCopyright("Copyright (c) 2004 Joshua Tauberer <[EMAIL 
PROTECTED]>\nreleased under the GPL.")]
+[assembly: AssemblyDescription("A tool for creating and updating Mono XML 
documentation files for assemblies.")]
+
+[assembly: Mono.UsageComplement("")]
+

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to