Skip to content

Commit 2d87d76

Browse files
authored
Merge pull request github#14272 from michaelnebel/csharp/externalapi
C#: Minor improvements to the ExternalApi implementation.
2 parents f02d281 + e997a7c commit 2d87d76

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

csharp/ql/src/Telemetry/ExternalApi.qll

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ private import dotnet
55
private import semmle.code.csharp.dispatch.Dispatch
66
private import semmle.code.csharp.dataflow.ExternalFlow
77
private import semmle.code.csharp.dataflow.FlowSummary
8-
private import semmle.code.csharp.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
98
private import semmle.code.csharp.dataflow.internal.DataFlowPrivate
109
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch as DataFlowDispatch
1110
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
@@ -77,13 +76,11 @@ class ExternalApi extends DotNet::Callable {
7776

7877
/** Gets a node that is an output from a call to this API. */
7978
private DataFlow::Node getAnOutput() {
80-
exists(
81-
Call c, DataFlowDispatch::NonDelegateDataFlowCall dc, DataFlowImplCommon::ReturnKindExt ret
82-
|
79+
exists(Call c, DataFlowDispatch::NonDelegateDataFlowCall dc |
8380
dc.getDispatchCall().getCall() = c and
8481
c.getTarget().getUnboundDeclaration() = this
8582
|
86-
result = ret.getAnOutNode(dc)
83+
result = DataFlowDispatch::getAnOutNode(dc, _)
8784
)
8885
}
8986

@@ -119,18 +116,17 @@ class ExternalApi extends DotNet::Callable {
119116
}
120117

121118
/**
122-
* Gets the nested name of the declaration.
119+
* Gets the nested name of the type `t`.
123120
*
124-
* If the declaration is not a nested type, the result is the same as \`getName()\`.
121+
* If the type is not a nested type, the result is the same as \`getName()\`.
125122
* Otherwise the name of the nested type is prefixed with a \`+\` and appended to
126123
* the name of the enclosing type, which might be a nested type as well.
127124
*/
128-
private string nestedName(Declaration declaration) {
129-
not exists(declaration.getDeclaringType().getUnboundDeclaration()) and
130-
result = declaration.getName()
125+
private string nestedName(Type t) {
126+
not exists(t.getDeclaringType().getUnboundDeclaration()) and
127+
result = t.getName()
131128
or
132-
nestedName(declaration.getDeclaringType().getUnboundDeclaration()) + "+" + declaration.getName() =
133-
result
129+
nestedName(t.getDeclaringType().getUnboundDeclaration()) + "+" + t.getName() = result
134130
}
135131

136132
/**

0 commit comments

Comments
 (0)