Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / tools / mdoc / Mono.Documentation / monodocer.cs
index dee1da2c0a4ea3106a80b3b2746f9b5451a755ae..dcb23d2f17c9890b7477423b5c0f73e9717f0598 100644 (file)
@@ -60,6 +60,8 @@ class MDocUpdater : MDocCommand
 
        MyXmlNodeList extensionMethods = new MyXmlNodeList ();
 
+       HashSet<string> forwardedTypes = new HashSet<string> ();
+
        public override void Run (IEnumerable<string> args)
        {
                show_exceptions = DebugOutput;
@@ -142,6 +144,9 @@ class MDocUpdater : MDocCommand
                
                this.assemblies = assemblies.Select (a => LoadAssembly (a)).ToList ();
 
+               // Store types that have been forwarded to avoid duplicate generation
+               GatherForwardedTypes ();
+
                docEnum = docEnum ?? new DocumentationEnumerator ();
                
                // PERFORM THE UPDATES
@@ -188,6 +193,13 @@ class MDocUpdater : MDocCommand
                }
        }
 
+       void GatherForwardedTypes ()
+       {
+               foreach (var asm in assemblies)
+                       foreach (var type in asm.MainModule.ExportedTypes.Where (t => t.IsForwarder).Select (t => t.FullName))
+                               forwardedTypes.Add (type);
+       }
+
        static ExceptionLocations ParseExceptionLocations (string s)
        {
                ExceptionLocations loc = ExceptionLocations.Member;
@@ -618,7 +630,7 @@ class MDocUpdater : MDocCommand
                index_assemblies.RemoveAll ();
 
 
-               HashSet<string> goodfiles = new HashSet<string> ();
+               HashSet<string> goodfiles = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
 
                foreach (AssemblyDefinition assm in assemblies) {
                        AddIndexAssembly (assm, index_assemblies);
@@ -641,7 +653,7 @@ class MDocUpdater : MDocCommand
        {
                foreach (TypeDefinition type in docEnum.GetDocumentationTypes (assembly, null)) {
                        string typename = GetTypeFileName(type);
-                       if (!IsPublic (type) || typename.IndexOfAny (InvalidFilenameChars) >= 0)
+                       if (!IsPublic (type) || typename.IndexOfAny (InvalidFilenameChars) >= 0 || forwardedTypes.Contains (type.FullName))
                                continue;
 
                        string reltypepath = DoUpdateType (type, source, dest);
@@ -754,7 +766,8 @@ class MDocUpdater : MDocCommand
        {
                TypeDefinition decl = type;
                while (decl != null) {
-                       if (!(decl.IsPublic || decl.IsNestedPublic)) {
+                       if (!(decl.IsPublic || decl.IsNestedPublic ||
+                                               decl.IsNestedFamily || decl.IsNestedFamily || decl.IsNestedFamilyOrAssembly)) {
                                return false;
                        }
                        decl = (TypeDefinition) decl.DeclaringType;
@@ -1946,7 +1959,7 @@ class MDocUpdater : MDocCommand
                                        (from i in values.Keys
                                         where (c & i) != 0
                                         select typename + "." + values [i])
-                                       .ToArray ());
+                                       .DefaultIfEmpty (v.ToString ()).ToArray ());
                }
                return "(" + GetDocTypeFullName (valueType) + ") " + v.ToString ();
        }