Skip to content

Commit 64de324

Browse files
committed
Fix requested changes from @vweijsters for #3174
* Rename 'isInheritingDocumentation' to 'hasIncludedDocumentation' to avoid confusion with the '<include [...] />' tag (Naming). * Move a declaration near to the statement to avoid unused function result (Design)
1 parent 3b59095 commit 64de324

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,10 @@ private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettin
229229
return;
230230
}
231231

232-
IEnumerable<XmlNodeSyntax> matchingXmlElements = string.IsNullOrEmpty(this.matchElementName)
233-
? documentation.Content
234-
.Where(x => x is XmlElementSyntax || x is XmlEmptyElementSyntax)
235-
.Where(x => !string.Equals(x.GetName()?.ToString(), XmlCommentHelper.IncludeXmlTag, StringComparison.Ordinal))
236-
: documentation.Content.GetXmlElements(this.matchElementName);
237-
238-
var isInheritingDocumentation =
232+
var hasIncludedDocumentation =
239233
documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag) is object;
240234

241-
if (isInheritingDocumentation)
235+
if (hasIncludedDocumentation)
242236
{
243237
var declaration = context.SemanticModel.GetDeclaredSymbol(node, context.CancellationToken);
244238
var rawDocumentation = declaration?.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken);
@@ -255,6 +249,12 @@ private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettin
255249
}
256250
else
257251
{
252+
IEnumerable<XmlNodeSyntax> matchingXmlElements = string.IsNullOrEmpty(this.matchElementName)
253+
? documentation.Content
254+
.Where(x => x is XmlElementSyntax || x is XmlEmptyElementSyntax)
255+
.Where(x => !string.Equals(x.GetName()?.ToString(), XmlCommentHelper.IncludeXmlTag, StringComparison.Ordinal))
256+
: documentation.Content.GetXmlElements(this.matchElementName);
257+
258258
this.HandleXmlElement(context, settings, needsComment, matchingXmlElements, locations);
259259
}
260260
}

0 commit comments

Comments
 (0)