-
Notifications
You must be signed in to change notification settings - Fork 509
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
CPAM34
wants to merge
10
commits into
DotNetAnalyzers:master
Choose a base branch
from
CPAM34:Issue3094
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
85fe51d
Checks for exclude tag in rules SA 1604-1611
8f35e00
Wrote exclude cases for rest of applicable documentation rules
a157eb8
Test case for doc rules SA1605 and SA1606
7f5209f
Test cases for SA1604, 1607-1610
86d30e8
Test cases created for SA1611-1612, 1617
1e85be1
Test cases added for exclude in rules SA1618-1620, 1625
c799a57
Fixes applied for rules SA1604, SA1618
20bf1d8
Fixes applied for SA1605, SA1609
c8f5eb8
Formatting fixes, removed commented code
caf0a9d
SA1623-1624 fixed, removed more commented blocks of code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/> | ||
{0} TypeName | ||
{{ | ||
}}"; | ||
await VerifyCSharpDiagnosticAsync(string.Format(testCode, typeName), DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); | ||
} | ||
|
||
[Theory] | ||
[InlineData("enum")] | ||
[InlineData("class")] | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 📝 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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.