mirror of
https://github.com/github/codeql.git
synced 2026-04-18 13:34:02 +02:00
C#: Add CIL attribute tests
This commit is contained in:
7
csharp/ql/test/library-tests/cil/attributes/Test.cs
Normal file
7
csharp/ql/test/library-tests/cil/attributes/Test.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
// semmle-extractor-options: --cil
|
||||
|
||||
using System;
|
||||
|
||||
class Test
|
||||
{
|
||||
}
|
||||
2614
csharp/ql/test/library-tests/cil/attributes/attribute.expected
Normal file
2614
csharp/ql/test/library-tests/cil/attributes/attribute.expected
Normal file
File diff suppressed because it is too large
Load Diff
32
csharp/ql/test/library-tests/cil/attributes/attribute.ql
Normal file
32
csharp/ql/test/library-tests/cil/attributes/attribute.ql
Normal file
@@ -0,0 +1,32 @@
|
||||
import semmle.code.cil.Attribute
|
||||
import semmle.code.cil.Declaration
|
||||
|
||||
query predicate attrNoArg(string dec, string attr) {
|
||||
exists(Declaration d, Attribute a |
|
||||
a.getDeclaration() = d and
|
||||
not exists(a.getAnArgument())
|
||||
|
|
||||
dec = d.toStringWithTypes() and
|
||||
attr = a.toStringWithTypes()
|
||||
)
|
||||
}
|
||||
|
||||
query predicate attrArgNamed(string dec, string attr, string name, string value) {
|
||||
exists(Declaration d, Attribute a |
|
||||
a.getDeclaration() = d and
|
||||
a.getNamedArgument(name) = value
|
||||
|
|
||||
dec = d.toStringWithTypes() and
|
||||
attr = a.toStringWithTypes()
|
||||
)
|
||||
}
|
||||
|
||||
query predicate attrArgPositional(string dec, string attr, int index, string value) {
|
||||
exists(Declaration d, Attribute a |
|
||||
a.getDeclaration() = d and
|
||||
a.getArgument(index) = value
|
||||
|
|
||||
dec = d.toStringWithTypes() and
|
||||
attr = a.toStringWithTypes()
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user