Skip to content

Commit af825db

Browse files
committed
C#: Update the ImplicitToStringExpr class to take AssignAddExpr into account.
1 parent 869be94 commit af825db

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

csharp/ql/lib/semmle/code/csharp/commons/Strings.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ class ImplicitToStringExpr extends Expr {
4949
this = add.getOtherOperand(o).stripImplicit()
5050
)
5151
or
52+
// s1 += s2 for where the left hand side is a string, call an operator +(string, object)
53+
exists(AssignAddExpr add, Operator o, Parameter p0, Parameter p1 |
54+
o = add.getTarget() and
55+
o.getName() = "+" and
56+
p0 = o.getParameter(0) and
57+
p1 = o.getParameter(1) and
58+
p0.getType() instanceof StringType and
59+
this = getAnAssignedArgumentOrParam(p1).stripImplicit()
60+
)
61+
or
5262
this = any(InterpolatedStringExpr ise).getAnInsert().stripImplicit()
5363
}
5464
}

0 commit comments

Comments
 (0)