Skip to content

Commit b2faf36

Browse files
committed
C#: Add support for params parameters in getRuntimeArgumentForParameter.
1 parent f0852c8 commit b2faf36

File tree

1 file changed

+9
-1
lines changed
  • csharp/ql/lib/semmle/code/csharp/exprs

1 file changed

+9
-1
lines changed

csharp/ql/lib/semmle/code/csharp/exprs/Call.qll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,20 @@ class Call extends DotNet::Call, Expr, @call {
182182
/**
183183
* Gets the argument that corresponds to parameter `p` of a potential
184184
* run-time target of this call.
185+
*
186+
* Does not consider default arguments.
185187
*/
186188
Expr getRuntimeArgumentForParameter(Parameter p) {
187189
exists(Callable c |
188190
c = this.getARuntimeTarget() and
189191
p = c.getAParameter() and
190-
result = this.getRuntimeArgument(p.getPosition())
192+
(
193+
p.isParams() and
194+
result = this.getRuntimeArgument(any(int i | i >= p.getPosition()))
195+
or
196+
not p.isParams() and
197+
result = this.getRuntimeArgument(p.getPosition())
198+
)
191199
)
192200
}
193201

0 commit comments

Comments
 (0)