Skip to content

Commit

Permalink
Update PropertySummaryDocumentationAnalyzer (SA1623 and SA1624) to ig…
Browse files Browse the repository at this point in the history
…nore summary tags containing an inheritdoc tag

DotNetAnalyzers#3465
  • Loading branch information
bjornhellander committed Aug 2, 2024
1 parent a61e80b commit e6b6efc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,26 @@ public class TestClass
/// <summary/>
public int TestProperty { get; set; }
}
";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Theory]
[InlineData("<inheritdoc/>")]
[InlineData("XYZ <inheritdoc/>")]
[InlineData("<inheritdoc/> XYZ")]
[WorkItem(3465, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3465")]
public async Task VerifyInheritdocInSummaryTagIsAllowedAsync(string summary)
{
var testCode = $@"
public class TestClass
{{
/// <summary>
/// {summary}
/// </summary>
public int TestProperty {{ get; set; }}
}}
";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@ public class TestClass
/// <summary/>
public int TestProperty { get; set; }
}
";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Theory]
[InlineData("<inheritdoc/>")]
[InlineData("XYZ <inheritdoc/>")]
[InlineData("<inheritdoc/> XYZ")]
[WorkItem(3465, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3465")]
public async Task VerifyInheritdocInSummaryTagIsAllowedAsync(string summary)
{
var testCode = $@"
public class TestClass
{{
/// <summary>
/// {summary}
/// </summary>
public int TestProperty {{ get; private set; }}
}}
";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl
return;
}

if (summaryElement.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null)
{
// Ignore nodes with an <inheritdoc/> tag.
return;
}

var propertyDeclaration = (PropertyDeclarationSyntax)context.Node;
var propertyType = context.SemanticModel.GetTypeInfo(propertyDeclaration.Type.StripRefFromType());
var culture = settings.DocumentationRules.DocumentationCultureInfo;
Expand Down

0 comments on commit e6b6efc

Please sign in to comment.