Skip to content

Commit

Permalink
Merge 12fac09 into 3c87326
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih authored Apr 3, 2023
2 parents 3c87326 + 12fac09 commit b859a8a
Show file tree
Hide file tree
Showing 36 changed files with 9,306 additions and 301 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PackageVersion Include="CommandLineParser" Version="1.9.71" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.46" />
<PackageVersion Include="ICSharpCode.Decompiler" Version="8.0.0.7246-preview3" />
<PackageVersion Include="IgnoresAccessChecksToGenerator" Version="0.6.0" />
<PackageVersion Include="iTextSharp" Version="5.5.13.3" />
<PackageVersion Include="Jint" Version="3.0.0-beta-2048" />
<PackageVersion Include="JsonSchema.Net" Version="4.0.2" />
Expand Down
111 changes: 111 additions & 0 deletions samples/seed/dotnet/project/Project/Inheritdoc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
namespace BuildFromProject;

public interface IInheritdoc
{
/// <summary>
/// This method should do something...
/// </summary>
void Issue7629();
}

public class Inheritdoc : IInheritdoc, IDisposable
{
public void Dispose() { }

public void Issue7629() { }

/// <inheritdoc cref="IInheritdoc.Issue7629" />
public void Issue7628() { }

public class Issue8101
{
/// <summary>
/// Create a new tween.
/// </summary>
/// <param name="from">The starting value.</param>
/// <param name="to">The end value.</param>
/// <param name="duration">Total tween duration in seconds.</param>
/// <param name="onChange">A callback that will be invoked every time the tween value changes.</param>
/// <returns>The newly created tween instance.</returns>
public static object Tween(float from, float to, float duration, Action<float> onChange) => null;

/// <inheritdoc cref="Tween" />
public static object Tween(int from, int to, float duration, Action<int> onChange) => null;
}

public struct Issue8129
{
/// <inheritdoc/>
public Issue8129(string foo) { }
}

/// <summary>
/// This is a test class to have something for DocFX to document.
/// </summary>
/// <remarks>
/// We're going to talk about things now.
/// <list type="table">
/// <listheader>Things for the header</listheader>
/// <item>
/// <term><see cref="BoolReturningMethod(bool)"/></term>
/// <description><inheritdoc cref="BoolReturningMethod(bool)" path="/summary"/></description>
/// </item>
/// <item>
/// <term><see cref="DoDad"/></term>
/// <description><inheritdoc cref="DoDad" path="/summary"/></description>
/// </item>
/// </list>
/// </remarks>
public class Issue7484
{
/// <summary>
/// This is a constructor to document.
/// </summary>
public Issue7484() { }

/// <summary>
/// A string that could have something.
/// </summary>
public string DoDad { get; }

/// <summary>
/// Simple method to generate docs for.
/// </summary>
/// <remarks>
/// I'd like to take a moment to thank all of those who helped me get to
/// a place where I can write documentation like this.
/// </remarks>
/// <param name="source">A meaningless boolean value, much like most questions in the world.</param>
/// <returns>An exactly equivalently meaningless boolean value, much like most answers in the world.</returns>
public bool BoolReturningMethod(bool source) => source;
}

public class Issue7035
{
/// <inheritdoc cref="B"/>
public void A() { }

/// <inheritdoc cref="A"/>
public void B() { }
}

public class Issue6366
{
public abstract class Class1<T>
{
/// <summary>
/// This text inherited.
/// </summary>
/// <param name="parm1">This text NOT inherited.</param>
/// <param name="parm2">This text inherited.</param>
/// <returns>This text inherited.</returns>
public abstract T TestMethod1(T parm1, int parm2);
}

public class Class2 : Class1<bool>
{
/// <inheritdoc/>
public override bool TestMethod1(bool parm1, int parm2) => false;
}
}
}
31 changes: 0 additions & 31 deletions src/Microsoft.DocAsCode.Dotnet/ExtractMetadata/MetadataItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ internal class MetadataItem : ICloneable
[JsonIgnore]
public bool IsInvalid { get; set; }

[YamlIgnore]
[JsonIgnore]
public string RawComment { get; set; }

[JsonProperty(Constants.PropertyName.IsEii)]
[YamlMember(Alias = Constants.PropertyName.IsEii)]
public bool IsExplicitInterfaceImplementation { get; set; }
Expand Down Expand Up @@ -137,10 +133,6 @@ internal class MetadataItem : ICloneable
[JsonProperty("references")]
public Dictionary<string, ReferenceItem> References { get; set; }

[YamlIgnore]
[JsonIgnore]
public string InheritDoc { get; set; }

[YamlIgnore]
[JsonIgnore]
public XmlComment CommentModel { get; set; }
Expand All @@ -154,27 +146,4 @@ public object Clone()
{
return MemberwiseClone();
}

public void CopyInheritedData(MetadataItem src)
{
if (src == null)
throw new ArgumentNullException(nameof(src));

if (Summary == null)
Summary = src.Summary;
if (Remarks == null)
Remarks = src.Remarks;

if (Exceptions == null && src.Exceptions != null)
Exceptions = src.Exceptions.Select(e => e.Clone()).ToList();
if (SeeAlsos == null && src.SeeAlsos != null)
SeeAlsos = src.SeeAlsos.Select(s => s.Clone()).ToList();
if (Examples == null && src.Examples != null)
Examples = new List<string>(src.Examples);

if (CommentModel != null && src.CommentModel != null)
CommentModel.CopyInheritedData(src.CommentModel);
if (Syntax != null && src.Syntax != null)
Syntax.CopyInheritedData(src.Syntax);
}
}
26 changes: 0 additions & 26 deletions src/Microsoft.DocAsCode.Dotnet/ExtractMetadata/SyntaxDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,4 @@ internal class SyntaxDetail
[YamlMember(Alias = "return")]
[JsonProperty("return")]
public ApiParameter Return { get; set; }

internal void CopyInheritedData(SyntaxDetail src)
{
if (src == null)
throw new ArgumentNullException(nameof(src));

CopyInheritedParameterList(Parameters, src.Parameters);
CopyInheritedParameterList(TypeParameters, src.TypeParameters);
if (Return != null && src.Return != null)
Return.CopyInheritedData(src.Return);
}

static void CopyInheritedParameterList(List<ApiParameter> dest, List<ApiParameter> src)
{
if (dest == null || src == null || dest.Count != src.Count)
return;
for (int ndx = 0; ndx < dest.Count; ndx++)
{
var myParam = dest[ndx];
var srcParam = src[ndx];
if (myParam.Name == srcParam.Name && myParam.Type == srcParam.Type)
{
myParam.CopyInheritedData(srcParam);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,4 @@ public class ApiParameter
[JsonProperty("attributes")]
[MergeOption(MergeOption.Ignore)]
public List<AttributeInfo> Attributes { get; set; }

internal void CopyInheritedData(ApiParameter src)
{
if (src == null)
throw new ArgumentNullException(nameof(src));

if (Description == null)
Description = src.Description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<ItemGroup>
<PackageReference Include="ICSharpCode.Decompiler" />
<PackageReference Include="IgnoresAccessChecksToGenerator" PrivateAssets="All" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" />
Expand All @@ -32,4 +33,9 @@
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
</ItemGroup>

<ItemGroup>
<InternalsAssemblyName Include="Microsoft.CodeAnalysis.Workspaces" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions src/Microsoft.DocAsCode.Dotnet/Parsers/XmlComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ internal class XmlComment

private XmlComment(string xml, XmlCommentParserContext context)
{
// Treat <doc> as <member>
if (xml.StartsWith("<doc>") && xml.EndsWith("</doc>"))
{
var innerXml = xml.Substring(5, xml.Length - 11);
var innerXmlTrim = innerXml.Trim();

// Workaround external XML doc not wrapped in summary tag: https://github.com/dotnet/roslyn/pull/66668
if (innerXmlTrim.StartsWith('<') && innerXmlTrim.EndsWith('>'))
xml = $"<member>{innerXml}</member>";
else
xml = $"<member><summary>{innerXml}</summary></member>";
}

// Workaround: https://github.com/dotnet/roslyn/pull/66668
if (!xml.StartsWith("<member", StringComparison.Ordinal) && !xml.EndsWith("</member>", StringComparison.Ordinal))
{
Expand Down
Loading

0 comments on commit b859a8a

Please sign in to comment.