Our code base is using <inheritdoc>, which may result in warnings by Docfx, if the same parameter is documented multiple times:
Processing Foo.Bar
warning: Duplicate parameter 'foo' found in comments, the latter one is ignored.
warning: Duplicate parameter 'cancellationToken' found in comments, the latter one is ignored.
Unfortunately this warning does not give any context about the affected type and member (at least when dlls are scanned and not projects).
I changed the code to also log the fully qualified name of the affected member:
Index: src/Docfx.Dotnet/Parsers/XmlCommentParserContext.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Docfx.Dotnet/Parsers/XmlCommentParserContext.cs b/src/Docfx.Dotnet/Parsers/XmlCommentParserContext.cs
--- a/src/Docfx.Dotnet/Parsers/XmlCommentParserContext.cs (revision fc8404cc55c7177bf68e659a963b79e607d45d64)
+++ b/src/Docfx.Dotnet/Parsers/XmlCommentParserContext.cs (date 1700833785544)
@@ -14,4 +14,6 @@
public Func<string, string> ResolveCode { get; init; }
public SourceDetail Source { get; init; }
+
+ public string ItemName { get; set; }
}
Index: src/Docfx.Dotnet/Parsers/XmlComment.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Docfx.Dotnet/Parsers/XmlComment.cs b/src/Docfx.Dotnet/Parsers/XmlComment.cs
--- a/src/Docfx.Dotnet/Parsers/XmlComment.cs (revision fc8404cc55c7177bf68e659a963b79e607d45d64)
+++ b/src/Docfx.Dotnet/Parsers/XmlComment.cs (date 1700839318506)
@@ -16,6 +16,7 @@
using Markdig.Renderers.Roundtrip;
using Markdig.Syntax;
using Markdig.Syntax.Inlines;
+using Markdown = Markdig.Markdown;
namespace Docfx.Dotnet;
@@ -235,26 +236,30 @@
{
var iterator = navigator.Select(xpath);
var result = new Dictionary<string, string>();
- if (iterator == null)
- {
- return result;
- }
+ var duplicates = new List<string>();
+ string path = context.Source?.Remote != null
+ ? Path.Combine(EnvironmentContext.BaseDirectory, context.Source.Remote.Path)
+ : context.Source?.Path;
+
foreach (XPathNavigator nav in iterator)
{
string name = nav.GetAttribute("name", string.Empty);
string description = GetXmlValue(nav);
if (!string.IsNullOrEmpty(name))
{
- if (result.ContainsKey(name))
+ if (!result.TryAdd(name, description))
{
- string path = context.Source?.Remote != null ? Path.Combine(EnvironmentContext.BaseDirectory, context.Source.Remote.Path) : context.Source?.Path;
- Logger.LogWarning($"Duplicate {contentType} '{name}' found in comments, the latter one is ignored.", file: StringExtension.ToDisplayPath(path), line: context.Source?.StartLine.ToString());
+ duplicates.Add(name);
}
- else
- {
- result.Add(name, description);
- }
- }
+ }
+ }
+
+ if (duplicates.Count != 0)
+ {
+ string duplicatesString = string.Join(", ", duplicates.Select(d => $"'{d}'"));
+ Logger.LogWarning(
+ $"Duplicate {contentType}(s) {duplicatesString} found in comments for {context.ItemName}, the latter one is ignored.",
+ file: path.ToDisplayPath(), line: context.Source?.StartLine.ToString());
}
return result;
Index: src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs b/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs
--- a/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs (revision fc8404cc55c7177bf68e659a963b79e607d45d64)
+++ b/src/Docfx.Dotnet/ManagedReference/Visitors/SymbolVisitorAdapter.cs (date 1700833795510)
@@ -706,6 +706,7 @@
AddReferenceDelegate = AddReferenceDelegate,
Source = item.Source,
ResolveCode = ResolveCode,
+ ItemName = item.Name
};
void AddReferenceDelegate(string id, string commentId)
Our code base is using
<inheritdoc>
, which may result in warnings by Docfx, if the same parameter is documented multiple times:Unfortunately this warning does not give any context about the affected type and member (at least when dlls are scanned and not projects). I changed the code to also log the fully qualified name of the affected member: