Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions mdoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ Test/DocTest-enumerations.dll:
Test/DocTest-embedded-type.dll:
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-embedded-type.cs

Test/DocTest-differentTypeDefinitions-First.dll:
rm -f $@
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-differentTypeDefinitions.cs /define:FIRST

Test/DocTest-differentTypeDefinitions-Second.dll:
rm -f $@
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-differentTypeDefinitions.cs /define:SECOND

Test/DocTest-typeForwards-First.dll:
rm -f $@
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-typeForwards.cs /define:FIRST
Expand Down Expand Up @@ -199,6 +207,20 @@ Test/FrameworkTestData-fx-inheritance: Test/DocTest-framework-inheritance-one.dl
cp Test/DocTest-framework-inheritance-three.dll Test/FrameworkTestData-fx-inheritance/Three/
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-fx-inheritance

.PHONY: check-monodocer-differentTypeDefinitions
check-monodocer-differentTypeDefinitions : Test/DocTest-differentTypeDefinitions-First.dll Test/DocTest-differentTypeDefinitions-Second.dll
-rm -Rf Test/en.actual

-rm -Rf Test/FrameworkTestData-fx-differentTypeDefinitions
mkdir Test/FrameworkTestData-fx-differentTypeDefinitions
mkdir Test/FrameworkTestData-fx-differentTypeDefinitions/One
cp Test/DocTest-differentTypeDefinitions-First.dll Test/FrameworkTestData-fx-differentTypeDefinitions/One
cp Test/DocTest-differentTypeDefinitions-Second.dll Test/FrameworkTestData-fx-differentTypeDefinitions/One
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-fx-differentTypeDefinitions

$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-fx-differentTypeDefinitions
$(DIFF) Test/en.expected.differentTypeDefinitions Test/en.actual

.PHONY: check-monodocer-typeForwards
check-monodocer-typeForwards : Test/DocTest-typeForwards-First.dll Test/DocTest-typeForwards-Second.dll Test/DocTest-typeForwards-Third.dll
-rm -Rf Test/en.actual
Expand Down Expand Up @@ -835,6 +857,7 @@ run-test-local: check-doc-tools
run-test-update : check-doc-tools-update

check-doc-tools: \
check-monodocer-differentTypeDefinitions \
check-monodocer-typeForwards \
check-monodocer-nestedType-typeForwards \
check-monodocer-Eii-importslashdoc \
Expand Down
15 changes: 14 additions & 1 deletion mdoc/Mono.Documentation/MDocUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3873,9 +3873,22 @@ public static void MakeAttributes(
NormalizeWhitespace(e);
}

private bool ProcessedMoreThanOnce(FrameworkTypeEntry typeEntry)
{
if (typeEntry.TimesProcessed <= 1)
{
return false;
}
else
{
var assemblies = this.assemblies.Where(a => a.Name == typeEntry.Framework.Name).ToList();
return assemblies.Any(a => a.IsTypeForwardingTo(typeEntry));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two similar but independent scenarios that this fix should be addressing:

  1. A type forward assembly + the assembly with the actual definition
  2. Two separate assemblies, with the same type (name), but different TypeDefinitions (ie. different members ... such as different extension methods depending on which assembly reference you've added).

I would like to see some integration tests that reflect both of these scenarios. In fact, there's already a type forward test included here ... maybe you could add to that particular test, a separate test class that reflects the second scenario, to make sure that mdoc will correctly add all methods in both classes.

Suggested change
return assemblies.Any(a => a.IsTypeForwardingTo(typeEntry));
return assemblies.Any(a => a.IsTypeForwardingTo(typeEntry));

}
}

public void MakeParameters (XmlElement root, MemberReference member, IList<ParameterDefinition> parameters, FrameworkTypeEntry typeEntry, ref bool fxAlternateTriggered, bool shouldDuplicateWithNew = false)
{
if (typeEntry.TimesProcessed > 1)
if (ProcessedMoreThanOnce(typeEntry))
return;

XmlElement e = WriteElement (root, "Parameters");
Expand Down
5 changes: 5 additions & 0 deletions mdoc/Mono.Documentation/Updater/Frameworks/AssemblySet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,10 @@ IEnumerable<AssemblyDefinition> LoadAllAssemblies ()
else
return new HashSet<MDocResolver.TypeForwardEventArgs>();
}

public bool IsTypeForwardingTo(FrameworkTypeEntry typeEntry)
{
return forwardedTypesTo.ContainsKey(typeEntry.Name);
}
}
}
14 changes: 14 additions & 0 deletions mdoc/Test/DocTest-differentTypeDefinitions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TheNamespace
{
public class TheClass
{
#if FIRST
public TheClass(int arg)
{}
#endif
#if SECOND
public TheClass(string arg)
{}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Framework Name="One">
<Assemblies>
<Assembly Name="DocTest-differentTypeDefinitions-First" Version="0.0.0.0" />
<Assembly Name="DocTest-differentTypeDefinitions-Second" Version="0.0.0.0" />
</Assemblies>
<Namespace Name="TheNamespace">
<Type Name="TheNamespace.TheClass" Id="T:TheNamespace.TheClass">
<Member Id="M:TheNamespace.TheClass.#ctor(System.Int32)" />
<Member Id="M:TheNamespace.TheClass.#ctor(System.String)" />
</Type>
</Namespace>
</Framework>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Type Name="TheClass" FullName="TheNamespace.TheClass">
<TypeSignature Language="C#" Value="public class TheClass" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit TheClass extends System.Object" />
<AssemblyInfo>
<AssemblyName>DocTest-differentTypeDefinitions-First</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>DocTest-differentTypeDefinitions-Second</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 TheClass (int arg);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(int32 arg) cil managed" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>DocTest-differentTypeDefinitions-First</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="arg" Type="System.Int32" />
</Parameters>
<Docs>
<param name="arg">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public TheClass (string arg);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string arg) cil managed" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>DocTest-differentTypeDefinitions-Second</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="arg" Type="System.String" />
</Parameters>
<Docs>
<param name="arg">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
32 changes: 32 additions & 0 deletions mdoc/Test/en.expected.differentTypeDefinitions/index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Overview>
<Assemblies>
<Assembly Name="DocTest-differentTypeDefinitions-First" 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>
<Assembly Name="DocTest-differentTypeDefinitions-Second" 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="TheNamespace">
<Type Name="TheClass" Kind="Class" />
</Namespace>
</Types>
<Title>Untitled</Title>
</Overview>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Namespace Name="TheNamespace">
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Namespace>