Skip to content

Commit a6d16e7

Browse files
committed
C#: Add overload resolution priority attribute class.
1 parent 568d3cc commit a6d16e7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class Attribute extends TopLevelExprParent, @attribute {
6969
attributes(this, _, getTypeRef(result), _)
7070
}
7171

72+
/** Gets the namespace containing the attribute type declaration. */
73+
Namespace getNamespace() { result = this.getType().getNamespace() }
74+
7275
/** Gets the element that this attribute is attached to. */
7376
Attributable getTarget() { attributes(this, _, _, result) }
7477

csharp/ql/lib/semmle/code/csharp/frameworks/system/runtime/CompilerServices.qll

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,25 @@ class SystemRuntimeCompilerServicesConfiguredTaskAwaitableTConfiguredTaskAwaiter
7474
/** An attribute of type `System.Runtime.CompilerServices.InlineArrayAttribute`. */
7575
class SystemRuntimeCompilerServicesInlineArrayAttribute extends Attribute {
7676
SystemRuntimeCompilerServicesInlineArrayAttribute() {
77-
this.getType().hasFullyQualifiedName("System.Runtime.CompilerServices", "InlineArrayAttribute")
77+
this.getNamespace() instanceof SystemRuntimeCompilerServicesNamespace and
78+
this.getType().hasName("InlineArrayAttribute")
7879
}
7980

8081
/**
8182
* Gets the length of the inline array.
8283
*/
8384
int getLength() { result = this.getConstructorArgument(0).getValue().toInt() }
8485
}
86+
87+
/** An attribute of type `System.Runtime.CompilerServices.OverloadResolutionPriority`. */
88+
class SystemRuntimeCompilerServicesOverloadResolutionPriorityAttribute extends Attribute {
89+
SystemRuntimeCompilerServicesOverloadResolutionPriorityAttribute() {
90+
this.getNamespace() instanceof SystemRuntimeCompilerServicesNamespace and
91+
this.getType().hasName("OverloadResolutionPriorityAttribute")
92+
}
93+
94+
/**
95+
* Gets the priority number.
96+
*/
97+
int getPriority() { result = this.getConstructorArgument(0).getValue().toInt() }
98+
}

0 commit comments

Comments
 (0)