Files
codeql/csharp/ql/test/library-tests/attributes/AttributeArguments.ql
Tom Hvitved d6515e7963 C#: Changes to extraction of attributes in assemblies
- Only cache on `AttributeData` and not the parent entity.
- Move `CreateGeneratedExpressionFromArgument` to `Expression.cs`.
- Restructure the various `CreateGenerated` methods so child entities are
  created inside them (and therefore no need to expose child index logic).
- Add locations to generated expressions.
- Avoid linear lookup in `CompilationUnit.cs`.
- Consolidate tests.
2020-11-11 09:54:51 +01:00

32 lines
817 B
Plaintext

import csharp
private class RelevantElement extends Element {
RelevantElement() {
this.fromSource()
or
this.getLocation().(Assembly).getName() = "Assembly1"
}
}
private class RelevantAttribute extends RelevantElement, Attribute {
RelevantAttribute() {
this.fromSource()
or
this.getType().getName() = "CustomAttribute"
}
}
private class RelevantExpr extends RelevantElement, Expr { }
query predicate arguments(RelevantAttribute attribute, int index, RelevantExpr e) {
e = attribute.getArgument(index)
}
query predicate constructorArguments(RelevantAttribute attribute, int index, RelevantExpr e) {
e = attribute.getConstructorArgument(index)
}
query predicate namedArguments(RelevantAttribute attribute, string name, RelevantExpr e) {
e = attribute.getNamedArgument(name)
}