Skip to content

Commit ad20436

Browse files
committed
Fix documentation with partial parameters declared (#3173)
1 parent 987420a commit ad20436

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -235,28 +235,28 @@ private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettin
235235
.Where(x => !string.Equals(x.GetName()?.ToString(), XmlCommentHelper.IncludeXmlTag, StringComparison.Ordinal))
236236
: documentation.Content.GetXmlElements(this.matchElementName);
237237

238-
if (!matchingXmlElements.Any())
238+
var isInheritingDocumentation = documentation.Content
239+
.Any(x => string.Equals(x.GetName()?.ToString(), XmlCommentHelper.IncludeXmlTag, StringComparison.Ordinal));
240+
241+
if (isInheritingDocumentation)
239242
{
240-
var includedDocumentation = documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag);
241-
if (includedDocumentation != null)
243+
var declaration = context.SemanticModel.GetDeclaredSymbol(node, context.CancellationToken);
244+
var rawDocumentation = declaration?.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken);
245+
var completeDocumentation = XElement.Parse(rawDocumentation, LoadOptions.None);
246+
247+
if (this.inheritDocSuppressesWarnings &&
248+
completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.InheritdocXmlTag))
242249
{
243-
var declaration = context.SemanticModel.GetDeclaredSymbol(node, context.CancellationToken);
244-
var rawDocumentation = declaration?.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken);
245-
var completeDocumentation = XElement.Parse(rawDocumentation, LoadOptions.None);
246-
247-
if (this.inheritDocSuppressesWarnings &&
248-
completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.InheritdocXmlTag))
249-
{
250-
// Ignore nodes with an <inheritdoc/> tag in the included XML.
251-
return;
252-
}
253-
254-
this.HandleCompleteDocumentation(context, needsComment, completeDocumentation, locations);
255-
return; // done
250+
// Ignore nodes with an <inheritdoc/> tag in the included XML.
251+
return;
256252
}
257-
}
258253

259-
this.HandleXmlElement(context, settings, needsComment, matchingXmlElements, locations);
254+
this.HandleCompleteDocumentation(context, needsComment, completeDocumentation, locations);
255+
}
256+
else
257+
{
258+
this.HandleXmlElement(context, settings, needsComment, matchingXmlElements, locations);
259+
}
260260
}
261261
}
262262
}

0 commit comments

Comments
 (0)