mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Exclude System.Runtime.CompilerServices attributes from XML documentation needed check
This commit is contained in:
@@ -45,7 +45,10 @@ predicate declarationHasXmlComment(Declaration d) { exists(getADeclarationXmlCom
|
||||
/** Whether a declaration should have documentation. */
|
||||
predicate isDocumentationNeeded(Modifiable decl) {
|
||||
decl.isUnboundDeclaration() and // Exclude constructed types and methods
|
||||
not exists(decl.(Attributable).getAnAttribute()) and // An attribute may serve to document
|
||||
not exists(Attribute a |
|
||||
a = decl.(Attributable).getAnAttribute() and
|
||||
not a.getType().hasFullyQualifiedName("System.Runtime.CompilerServices", _)
|
||||
) and // An attribute may serve to document
|
||||
decl.isPublic() and
|
||||
(
|
||||
// The documentation of the overridden method (e.g. in an interface) is sufficient.
|
||||
|
||||
4
csharp/ql/src/change-notes/2024-08-12-doc-comments.md
Normal file
4
csharp/ql/src/change-notes/2024-08-12-doc-comments.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Attributes in the `System.Runtime.CompilerServices` namespace are ignored when checking if a declaration requires documentation comments.
|
||||
@@ -1,3 +1,4 @@
|
||||
| documentation.cs:39:16:39:22 | method3 | Public method should be documented. |
|
||||
| documentation.cs:51:18:51:23 | Class2 | Public class should be documented. |
|
||||
| documentation.cs:74:12:74:17 | Class1 | Public constructor should be documented. |
|
||||
| documentation.cs:135:17:135:23 | method6 | Public method should be documented. |
|
||||
|
||||
@@ -123,4 +123,23 @@ class Class2 : Class1
|
||||
// GOOD: Even if the overridden method is bad.
|
||||
/// <inheritdoc/>
|
||||
public override int method4<T>(int p1, int p2) { return p1; }
|
||||
|
||||
// GOOD: Has an attribute
|
||||
[My1]
|
||||
public void method5()
|
||||
{
|
||||
}
|
||||
|
||||
// BAD: Has only System.Runtime.CompilerServices attribute
|
||||
[System.Runtime.CompilerServices.My2]
|
||||
public void method6()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal class My1Attribute : Attribute { }
|
||||
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
internal class My2Attribute : Attribute { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user