Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable documentation analysis for <exclude> elements #3121

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName)
await VerifyCSharpDiagnosticAsync(string.Format(testCode, typeName), DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Theory]
[InlineData("enum")]
[InlineData("class")]
[InlineData("struct")]
[InlineData("interface")]
public async Task TestTypeWithExcludedDocumentationAsync(string typeName)
{
var testCode = @"
/// <exclude/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 It seems like the <exclude/> element shouldn't always exclude the element, but rather it should force a public element to be treated like a non-public element. If documentation is required for non-public elements, diagnostics should still be reported for missing documentation.

{0} TypeName
{{
}}";
await VerifyCSharpDiagnosticAsync(string.Format(testCode, typeName), DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Theory]
[InlineData("enum")]
[InlineData("class")]
Expand Down Expand Up @@ -129,6 +144,16 @@ public delegate
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestDelegateWithExcludedDocumentationAsync()
{
var testCode = @"
/// <exclude/>
public delegate
void TypeName();";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestDelegateWithoutDocumentationAsync()
{
Expand Down Expand Up @@ -188,6 +213,21 @@ public void Test() { }
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestMethodWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
public void Test() { }
Copy link
Member

@sharwell sharwell Dec 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Should we also disable checks for a member if the containing type is marked with <exclude/>?

📝 The test for this could be added without duplicating all of the current tests, by having a single class with several members.

/// <exclude/>
public class ClassName
{
     public void ClassName() { }
     ~ClassName() { }
     public int Property { get; set; }
     public void Test() { }
     // ...
}

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

[Fact]
public async Task TestMethodWithoutDocumentationAsync()
{
Expand Down Expand Up @@ -290,6 +330,21 @@ public ClassName() { }
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestConstructorWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
public ClassName() { }
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestConstructorWithoutDocumentationAsync()
{
Expand Down Expand Up @@ -354,6 +409,21 @@ public class ClassName
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestDestructorWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
~ClassName() { }
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestDestructorWithoutDocumentationAsync()
{
Expand Down Expand Up @@ -404,6 +474,21 @@ public class ClassName
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestPropertyWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
public ClassName Property { get; set; }
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestPropertyNoDocumentationAsync()
{
Expand Down Expand Up @@ -468,6 +553,21 @@ public class ClassName
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestIndexerWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
public ClassName this[string t] { get { return null; } }
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestIndexerNoDocumentationAsync()
{
Expand Down Expand Up @@ -532,6 +632,21 @@ public class ClassName
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestFieldWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
public ClassName Foo;
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestFieldNoDocumentationAsync()
{
Expand Down Expand Up @@ -596,6 +711,21 @@ public class ClassName
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestEventWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
public event System.Action Foo;
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestEventNoDocumentationAsync()
{
Expand Down Expand Up @@ -660,6 +790,21 @@ event System.Action Foo { add { } remove { } }
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestEventPropertyWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public class ClassName
{
/// <exclude/>
event System.Action Foo { add { } remove { } }
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestEventPropertyNoDocumentationAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName)
await VerifyCSharpDiagnosticAsync(string.Format(testCode, typeName), DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Theory]
[InlineData("class")]
[InlineData("struct")]
[InlineData("interface")]
public async Task TestTypeWithExcludedDocumentationAsync(string typeName)
{
var testCode = @"
/// <exclude/>
partial {0} TypeName
{{
}}";
await VerifyCSharpDiagnosticAsync(string.Format(testCode, typeName), DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Theory]
[InlineData("class")]
[InlineData("struct")]
Expand Down Expand Up @@ -184,6 +198,21 @@ public partial class ClassName
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestMethodWithExcludedDocumentationAsync()
{
var testCode = @"
/// <summary>
///
/// </summary>
public partial class ClassName
{
/// <exclude/>
partial void Test();
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestMethodWithoutDocumentationAsync()
{
Expand Down
Loading