Skip to content

Commit 2d5a62f

Browse files
committed
Allow inheritdoc for constructors with base types
1 parent 1dd5ced commit 2d5a62f

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1648UnitTests.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
#nullable disable
4+
#nullable enable
55

66
namespace StyleCop.Analyzers.Test.DocumentationRules
77
{
@@ -18,6 +18,23 @@ namespace StyleCop.Analyzers.Test.DocumentationRules
1818
/// </summary>
1919
public class SA1648UnitTests
2020
{
21+
[Fact]
22+
public async Task TestConstructorInheritsFromParentAsync()
23+
{
24+
var testCode = @"class Base
25+
{
26+
public Base() { }
27+
}
28+
29+
class Test : Base
30+
{
31+
/// <inheritdoc />
32+
public Test() { }
33+
}";
34+
35+
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
36+
}
37+
2138
[Fact]
2239
public async Task TestClassOverridesClassAsync()
2340
{

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ private static void HandleMemberDeclaration(SyntaxNodeAnalysisContext context)
159159
}
160160
}
161161

162+
if (memberSyntax is ConstructorDeclarationSyntax && declaredSymbol is IMethodSymbol methodSymbol && methodSymbol.ContainingType?.BaseType != null)
163+
{
164+
return;
165+
}
166+
162167
if (documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag) is XmlEmptyElementSyntax includeElement)
163168
{
164169
if (declaredSymbol == null)

0 commit comments

Comments
 (0)