Merge pull request #1306 from joelmartinez/docs-privateinterface
authorJonathan Pryor <jonpryor@vt.edu>
Wed, 1 Oct 2014 19:23:08 +0000 (15:23 -0400)
committerJonathan Pryor <jonpryor@vt.edu>
Wed, 1 Oct 2014 19:23:08 +0000 (15:23 -0400)
mdoc no longer documents private interfaces

mcs/tools/mdoc/Makefile
mcs/tools/mdoc/Mono.Documentation/monodocer.cs
mcs/tools/mdoc/Test/DocTest-InternalInterface.cs [new file with mode: 0644]
mcs/tools/mdoc/Test/en.expected-internal-interface/MyNamespace/MyClass.xml [new file with mode: 0644]
mcs/tools/mdoc/Test/en.expected-internal-interface/index.xml [new file with mode: 0644]
mcs/tools/mdoc/Test/en.expected-internal-interface/ns-MyNamespace.xml [new file with mode: 0644]

index ad24c3d2d4e2078d16d3c98a6e16b3d7317c2c03..3b7e698d6042ad2e857de4ee831e078ab76da462 100644 (file)
@@ -104,6 +104,9 @@ Test/DocTest-DropNS-unified.dll:
 Test/DocTest.dll: 
        $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest.cs
 
+Test/DocTest-InternalInterface.dll: 
+       $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-InternalInterface.cs
+
 Test/DocTest.dll-v1: 
        -rm -f Test/DocTest.cs
        cp Test/DocTest-v1.cs Test/DocTest.cs
@@ -145,7 +148,13 @@ update-monodocer-dropns-unified-withsecondary: $(PROGRAM)
 update-monodocer-dropns-classic-secondary: $(PROGRAM)
        $(MAKE) Test/DocTest-DropNS-classic-secondary.dll
        $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll
-               
+
+check-monodocer-internal-interface: $(PROGRAM)
+       # Tests to make sure internal interfaces that are explicitly implemented are not documented
+       -rm -Rf Test/en.actual
+       $(MAKE) Test/DocTest-InternalInterface.dll
+       $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-InternalInterface.dll
+       diff --exclude=.svn -rup Test/en.expected-internal-interface Test/en.actual
 
 check-monodocer-update: $(PROGRAM)
        find Test/en.expected -name \*.xml -exec rm "{}" \;
@@ -305,6 +314,7 @@ check-doc-tools-update: check-monodocer-since-update \
        check-monodocer-update \
        check-monodocer-dropns-classic \
        check-monodocer-dropns-classic-withsecondary \
+       check-monodocer-internal-interface \
        check-monodocer-delete-update \
        check-mdoc-export-html-update \
        check-mdoc-export-msxdoc-update \
index 09763096e5592bb4d1ab98594760c1f2d95e9bea..842a4ae439f36136fbb90c5e5942dcf8b5d56cbb 100644 (file)
@@ -980,7 +980,7 @@ class MDocUpdater : MDocCommand
                throw new ArgumentException ("Unknown kind for type: " + type.FullName);
        }
 
-       private static bool IsPublic (TypeDefinition type)
+       public static bool IsPublic (TypeDefinition type)
        {
                TypeDefinition decl = type;
                while (decl != null) {
@@ -1164,6 +1164,27 @@ class MDocUpdater : MDocCommand
                                                string sig = memberFormatters [0].GetDeclaration (m);
                                                if (sig == null) return false;
                                                if (seenmembers.ContainsKey(sig)) return false;
+
+                                               // Verify that the member isn't an explicitly implemented 
+                                               // member of an internal interface, in which case we shouldn't return true.
+                                               MethodDefinition methdef = null;
+                                               if (m is MethodDefinition) 
+                                                       methdef = m as MethodDefinition;
+                                               else if (m is PropertyDefinition) {
+                                                       var prop = m as PropertyDefinition;
+                                                       methdef = prop.GetMethod ?? prop.SetMethod;
+                                               }
+
+                                               if (methdef != null) {
+                                                       TypeReference iface;
+                                                       MethodReference imethod;
+
+                                                       if (methdef.Overrides.Count == 1) {
+                                                               DocUtils.GetInfoForExplicitlyImplementedMethod (methdef, out iface, out imethod);
+                                                               if (!IsPublic (iface.Resolve ())) return false;
+                                                       }
+                                               }
+
                                                return true;
                                        })
                                        .ToArray();
@@ -3023,7 +3044,7 @@ static class DocUtils {
                        if (!inheritedInterfaces.Contains (GetQualifiedTypeName (lookup)))
                                userInterfaces.Add (iface);
                }
-               return userInterfaces;
+               return userInterfaces.Where (i => MDocUpdater.IsPublic (i.Resolve ()));
        }
 
        private static string GetQualifiedTypeName (TypeReference type)
@@ -4351,7 +4372,7 @@ class ILFullMemberFormatter : MemberFormatter {
                                buf.Append (full.GetName (type.BaseType).Substring ("class ".Length));
                }
                bool first = true;
-               foreach (var name in type.Interfaces
+               foreach (var name in type.Interfaces.Where (i => MDocUpdater.IsPublic (i.Resolve ()))
                                .Select (i => full.GetName (i))
                                .OrderBy (n => n)) {
                        if (first) {
diff --git a/mcs/tools/mdoc/Test/DocTest-InternalInterface.cs b/mcs/tools/mdoc/Test/DocTest-InternalInterface.cs
new file mode 100644 (file)
index 0000000..5d65c34
--- /dev/null
@@ -0,0 +1,17 @@
+namespace MyNamespace {
+       internal interface MyInternalInterface {
+               bool Foo {get;set;}
+               string FooSet {set;}
+               void FooMeth ();
+               void BarMeth ();
+       }
+
+       public class MyClass : MyInternalInterface {
+               public string Bar {get;set;}
+               public void BarMeth () {} // part of the interface, but publicly implemented
+
+               string MyInternalInterface.FooSet {set {}}
+               bool MyInternalInterface.Foo {get;set;}
+               void MyInternalInterface.FooMeth () {}
+       }
+}
diff --git a/mcs/tools/mdoc/Test/en.expected-internal-interface/MyNamespace/MyClass.xml b/mcs/tools/mdoc/Test/en.expected-internal-interface/MyNamespace/MyClass.xml
new file mode 100644 (file)
index 0000000..614b7b7
--- /dev/null
@@ -0,0 +1,63 @@
+<Type Name="MyClass" FullName="MyNamespace.MyClass">
+  <TypeSignature Language="C#" Value="public class MyClass" />
+  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit MyClass extends System.Object" />
+  <AssemblyInfo>
+    <AssemblyName>DocTest-InternalInterface</AssemblyName>
+    <AssemblyVersion>0.0.0.0</AssemblyVersion>
+  </AssemblyInfo>
+  <Base>
+    <BaseTypeName>System.Object</BaseTypeName>
+  </Base>
+  <Interfaces />
+  <Docs>
+    <summary>To be added.</summary>
+    <remarks>To be added.</remarks>
+  </Docs>
+  <Members>
+    <Member MemberName=".ctor">
+      <MemberSignature Language="C#" Value="public MyClass ();" />
+      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
+      <MemberType>Constructor</MemberType>
+      <AssemblyInfo>
+        <AssemblyVersion>0.0.0.0</AssemblyVersion>
+      </AssemblyInfo>
+      <Parameters />
+      <Docs>
+        <summary>To be added.</summary>
+        <remarks>To be added.</remarks>
+      </Docs>
+    </Member>
+    <Member MemberName="Bar">
+      <MemberSignature Language="C#" Value="public string Bar { get; set; }" />
+      <MemberSignature Language="ILAsm" Value=".property instance string Bar" />
+      <MemberType>Property</MemberType>
+      <AssemblyInfo>
+        <AssemblyVersion>0.0.0.0</AssemblyVersion>
+      </AssemblyInfo>
+      <ReturnValue>
+        <ReturnType>System.String</ReturnType>
+      </ReturnValue>
+      <Docs>
+        <summary>To be added.</summary>
+        <value>To be added.</value>
+        <remarks>To be added.</remarks>
+      </Docs>
+    </Member>
+    <Member MemberName="BarMeth">
+      <MemberSignature Language="C#" Value="public void BarMeth ();" />
+      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void BarMeth() cil managed" />
+      <MemberType>Method</MemberType>
+      <AssemblyInfo>
+        <AssemblyVersion>0.0.0.0</AssemblyVersion>
+      </AssemblyInfo>
+      <ReturnValue>
+        <ReturnType>System.Void</ReturnType>
+      </ReturnValue>
+      <Parameters />
+      <Docs>
+        <summary>To be added.</summary>
+        <remarks>To be added.</remarks>
+      </Docs>
+    </Member>
+  </Members>
+</Type>
diff --git a/mcs/tools/mdoc/Test/en.expected-internal-interface/index.xml b/mcs/tools/mdoc/Test/en.expected-internal-interface/index.xml
new file mode 100644 (file)
index 0000000..5b49f3c
--- /dev/null
@@ -0,0 +1,22 @@
+<Overview>
+  <Assemblies>
+    <Assembly Name="DocTest-InternalInterface" Version="0.0.0.0">
+      <Attributes>
+        <Attribute>
+          <AttributeName>System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute+DebuggingModes.IgnoreSymbolStoreSequencePoints)</AttributeName>
+        </Attribute>
+        <Attribute>
+          <AttributeName>System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)</AttributeName>
+        </Attribute>
+      </Attributes>
+    </Assembly>
+  </Assemblies>
+  <Remarks>To be added.</Remarks>
+  <Copyright>To be added.</Copyright>
+  <Types>
+    <Namespace Name="MyNamespace">
+      <Type Name="MyClass" Kind="Class" />
+    </Namespace>
+  </Types>
+  <Title>DocTest-InternalInterface</Title>
+</Overview>
diff --git a/mcs/tools/mdoc/Test/en.expected-internal-interface/ns-MyNamespace.xml b/mcs/tools/mdoc/Test/en.expected-internal-interface/ns-MyNamespace.xml
new file mode 100644 (file)
index 0000000..bd8d431
--- /dev/null
@@ -0,0 +1,6 @@
+<Namespace Name="MyNamespace">
+  <Docs>
+    <summary>To be added.</summary>
+    <remarks>To be added.</remarks>
+  </Docs>
+</Namespace>