Skip to content

Commit

Permalink
mdoc: EII events are now documented.
Browse files Browse the repository at this point in the history
Closes #106
  • Loading branch information
joelmartinez committed Oct 27, 2017
1 parent 795fb33 commit 412a78b
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 22 deletions.
2 changes: 1 addition & 1 deletion mdoc/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Mono.Documentation
{
public static class Consts
{
public static string MonoVersion = "5.1.1.0";
public static string MonoVersion = "5.2.0.0";
}
}
2 changes: 1 addition & 1 deletion mdoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,4 @@ check-doc-tools-update: check-monodocer-since-update \
check-mdoc-validate-update

check: nunit check-doc-tools

@echo "mdoc Tests Complete!"
20 changes: 8 additions & 12 deletions mdoc/Mono.Documentation/MDocUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,19 +1104,10 @@ private static string GetTypeKind (TypeDefinition type)
throw new ArgumentException ("Unknown kind for type: " + type.FullName);
}

[Obsolete("Use DocUtils.IsPublic instead")]
public static bool IsPublic (TypeDefinition type)
{
TypeDefinition decl = type;
while (decl != null)
{
if (!(decl.IsPublic || decl.IsNestedPublic ||
decl.IsNestedFamily || decl.IsNestedFamily || decl.IsNestedFamilyOrAssembly))
{
return false;
}
decl = (TypeDefinition)decl.DeclaringType;
}
return true;
return DocUtils.IsPublic (type);
}

private void CleanupFiles (string dest, HashSet<string> goodfiles)
Expand Down Expand Up @@ -1451,6 +1442,11 @@ public void DoUpdateType2 (string message, XmlDocument basefile, TypeDefinition
var prop = m as PropertyDefinition;
methdef = prop.GetMethod ?? prop.SetMethod;
}
else if (m is EventDefinition)
{
var ev = m as EventDefinition;
methdef = ev.AddMethod ?? ev.RemoveMethod;
}

if (methdef != null)
{
Expand All @@ -1460,7 +1456,7 @@ public void DoUpdateType2 (string message, XmlDocument basefile, TypeDefinition
if (methdef.Overrides.Count == 1 && !methdef.IsPublic)
{
DocUtils.GetInfoForExplicitlyImplementedMethod (methdef, out iface, out imethod);
if (!IsPublic (iface.Resolve ())) return false;
if (!DocUtils.IsPublic (iface.Resolve ())) return false;
}
}

Expand Down
15 changes: 15 additions & 0 deletions mdoc/Mono.Documentation/Updater/DocUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ public static void GetInfoForExplicitlyImplementedMethod (
ifaceMethod = method.Overrides[0];
}

public static bool IsPublic (TypeDefinition type)
{
TypeDefinition decl = type;
while (decl != null)
{
if (!(decl.IsPublic || decl.IsNestedPublic ||
decl.IsNestedFamily || decl.IsNestedFamily || decl.IsNestedFamilyOrAssembly))
{
return false;
}
decl = (TypeDefinition)decl.DeclaringType;
}
return true;
}

public static string GetPropertyName (PropertyDefinition pi)
{
// Issue: (g)mcs-generated assemblies that explicitly implement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,15 @@ static StringBuilder AppendFieldValue (StringBuilder buf, FieldDefinition field)
protected override string GetEventDeclaration (EventDefinition e)
{
StringBuilder buf = new StringBuilder ();
if (AppendVisibility (buf, e.AddMethod).Length == 0)

if (AppendVisibility (buf, e.AddMethod).Length == 0 && !IsPublicEII (e))
{
return null;
}

AppendModifiers (buf, e.AddMethod);

buf.Append (" event ");
buf.Append (buf.Length == 0 ? "event " : " event ");
buf.Append (GetTypeName (e.EventType, new DynamicParserContext (e.AddMethod.Parameters[0]))).Append (' ');
buf.Append (e.Name).Append (';');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static StringBuilder AppendFieldValue (StringBuilder buf, FieldDefinition field)
protected override string GetEventDeclaration (EventDefinition e)
{
StringBuilder buf = new StringBuilder ();
if (AppendVisibility (buf, e.AddMethod).Length == 0)
if (AppendVisibility (buf, e.AddMethod).Length == 0 && !IsPublicEII (e))
{
return null;
}
Expand Down
16 changes: 16 additions & 0 deletions mdoc/Mono.Documentation/Updater/Formatters/MemberFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,21 @@ protected virtual string GetEventDeclaration (EventDefinition e)
{
return GetEventName (e);
}

protected static bool IsPublicEII (EventDefinition e)
{
bool isPublicEII = false;
if (e.AddMethod.HasOverrides)
{
var resolvedAddMethod = e.AddMethod.Overrides[0].Resolve ();
var resolvedInterface = e.AddMethod.Overrides[0].DeclaringType.Resolve ();
if (DocUtils.IsPublic (resolvedInterface) && resolvedAddMethod != null && resolvedAddMethod.IsPublic)
{
isPublicEII = true;
}
}

return isPublicEII;
}
}
}
12 changes: 11 additions & 1 deletion mdoc/Test/DocTest-InternalInterface.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System;

namespace MyNamespace {
internal interface MyInternalInterface {
bool Foo {get;set;}
string FooSet {set;}
void FooMeth ();
void BarMeth ();
event EventHandler<string> InternalEvent;
}
public interface MyPublicInterface {
event EventHandler<string> PublicEvent;
}

public class MyClass : MyInternalInterface {
public class MyClass : MyInternalInterface, MyPublicInterface {
[System.ComponentModel.DefaultValue ('\0')]
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 () {}

event EventHandler<string> MyPublicInterface.PublicEvent {add{}remove{}}
event EventHandler<string> MyInternalInterface.InternalEvent {add{}remove{}}
public event EventHandler<int> InstanceEvent {add{}remove{}}
}

public static class ArrayX10 {
Expand Down
40 changes: 37 additions & 3 deletions mdoc/Test/en.expected-internal-interface/MyNamespace/MyClass.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<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" />
<TypeSignature Language="C#" Value="public class MyClass : MyNamespace.MyPublicInterface" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit MyClass extends System.Object implements class MyNamespace.MyPublicInterface" />
<AssemblyInfo>
<AssemblyName>DocTest-InternalInterface</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Interfaces>
<Interface>
<InterfaceName>MyNamespace.MyPublicInterface</InterfaceName>
</Interface>
</Interfaces>
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
Expand Down Expand Up @@ -64,5 +68,35 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="InstanceEvent">
<MemberSignature Language="C#" Value="public event EventHandler&lt;int&gt; InstanceEvent;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler`1&lt;int32&gt; InstanceEvent" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler&lt;System.Int32&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="MyNamespace.MyPublicInterface.PublicEvent">
<MemberSignature Language="C#" Value="event EventHandler&lt;string&gt; MyNamespace.MyPublicInterface.PublicEvent;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler`1&lt;string&gt; MyNamespace.MyPublicInterface.PublicEvent" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler&lt;System.String&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Type Name="MyPublicInterface" FullName="MyNamespace.MyPublicInterface">
<TypeSignature Language="C#" Value="public interface MyPublicInterface" />
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract MyPublicInterface" />
<AssemblyInfo>
<AssemblyName>DocTest-InternalInterface</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Interfaces />
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
<Member MemberName="PublicEvent">
<MemberSignature Language="C#" Value="public event EventHandler&lt;string&gt; PublicEvent;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler`1&lt;string&gt; PublicEvent" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler&lt;System.String&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
1 change: 1 addition & 0 deletions mdoc/Test/en.expected-internal-interface/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Namespace Name="MyNamespace">
<Type Name="ArrayX10" Kind="Class" />
<Type Name="MyClass" Kind="Class" />
<Type Name="MyPublicInterface" Kind="Interface" />
</Namespace>
</Types>
<Title>DocTest-InternalInterface</Title>
Expand Down
2 changes: 1 addition & 1 deletion mdoc/mdoc.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>mdoc</id>
<version>5.1.1.0</version>
<version>5.2.0.0</version>
<title>mdoc</title>
<authors>Joel Martinez</authors>
<owners>Xamarin</owners>
Expand Down
1 change: 1 addition & 0 deletions monodoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ CONFIGURATION = Release

check:
mono ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe Test/bin/$(CONFIGURATION)/Monodoc.Test.dll
@echo "monodoc Tests Complete!"

0 comments on commit 412a78b

Please sign in to comment.