Skip to content

Commit 821d294

Browse files
committed
C#: Add library support for CIL generic attributes.
1 parent 5ff89a2 commit 821d294

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

csharp/ql/lib/semmle/code/cil/Attribute.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,19 @@ class Attribute extends Element, @cil_attribute {
2727

2828
override CS::Location getLocation() { result = getDeclaration().getLocation() }
2929
}
30+
31+
/** A generic attribute to a declaration. */
32+
class GenericAttribute extends Attribute {
33+
private ConstructedType type;
34+
35+
GenericAttribute() { type = this.getType() }
36+
37+
/** Gets the total number of type arguments. */
38+
int getNumberOfTypeArguments() { result = count(int i | cil_type_argument(type, i, _)) }
39+
40+
/** Gets the `i`th type argument, if any. */
41+
Type getTypeArgument(int i) { result = type.getTypeArgument(i) }
42+
43+
/** Get a type argument. */
44+
Type getATypeArgument() { result = this.getTypeArgument(_) }
45+
}

0 commit comments

Comments
 (0)