Skip to content

Commit e0d7e27

Browse files
committed
C#: Align counting with Java and only count calls and not all possible dispatch calls.
1 parent be1129e commit e0d7e27

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

csharp/ql/src/Telemetry/ExternalApi.qll

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ class ExternalApi extends DotNet::Callable {
5353
*/
5454
string getApiName() { result = this.getNamespace() + "#" + this.getSignature() }
5555

56-
/** Gets a call to this API callable. */
57-
DispatchCall getACall() {
58-
this = result.getADynamicTarget().getUnboundDeclaration()
59-
or
60-
this = result.getAStaticTarget().getUnboundDeclaration()
61-
}
62-
6356
/** Gets a node that is an input to a call to this API. */
6457
private ArgumentNode getAnInput() {
65-
result.getCall().(DataFlowDispatch::NonDelegateDataFlowCall).getDispatchCall() = this.getACall()
58+
result
59+
.getCall()
60+
.(DataFlowDispatch::NonDelegateDataFlowCall)
61+
.getATarget(_)
62+
.getUnboundDeclaration() = this
6663
}
6764

6865
/** Gets a node that is an output from a call to this API. */
6966
private DataFlow::Node getAnOutput() {
70-
exists(DataFlowDispatch::NonDelegateDataFlowCall call, DataFlowImplCommon::ReturnKindExt ret |
71-
result = ret.getAnOutNode(call)
67+
exists(
68+
Call c, DataFlowDispatch::NonDelegateDataFlowCall dc, DataFlowImplCommon::ReturnKindExt ret
69+
|
70+
dc.getDispatchCall().getCall() = c and
71+
c.getTarget().getUnboundDeclaration() = this
7272
|
73-
this.getACall() = call.getDispatchCall()
73+
result = ret.getAnOutNode(dc)
7474
)
7575
}
7676

@@ -121,8 +121,8 @@ signature predicate relevantApi(ExternalApi api);
121121
module Results<relevantApi/1 getRelevantUsages> {
122122
private int getUsages(string apiName) {
123123
result =
124-
strictcount(DispatchCall c, ExternalApi api |
125-
c = api.getACall() and
124+
strictcount(Call c, ExternalApi api |
125+
c.getTarget().getUnboundDeclaration() = api and
126126
apiName = api.getApiName() and
127127
getRelevantUsages(api)
128128
)

csharp/ql/src/Telemetry/ExternalLibraryUsage.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ private import ExternalApi
1212

1313
private predicate getRelevantUsages(string namespace, int usages) {
1414
usages =
15-
strictcount(DispatchCall c, ExternalApi api |
16-
c = api.getACall() and
15+
strictcount(Call c, ExternalApi api |
16+
c.getTarget().getUnboundDeclaration() = api and
1717
api.getNamespace() = namespace and
1818
not api.isUninteresting()
1919
)

0 commit comments

Comments
 (0)