Skip to content

Commit 204bbd0

Browse files
committed
C#: Do not insert a synthetic ToString call, if a format or alignment option is specified in the string interpolation.
1 parent e6b40a4 commit 204bbd0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/InterpolatedString.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ protected override void PopulateExpression(TextWriter trapFile)
2020
{
2121
case SyntaxKind.Interpolation:
2222
var interpolation = (InterpolationSyntax)c;
23-
ImplicitToString.Create(Context, interpolation.Expression, this, child++);
23+
if (interpolation.FormatClause is null && interpolation.AlignmentClause is null)
24+
{
25+
ImplicitToString.Create(Context, interpolation.Expression, this, child++);
26+
}
27+
else
28+
{
29+
Create(Context, interpolation.Expression, this, child++);
30+
}
2431
break;
2532
case SyntaxKind.InterpolatedStringText:
2633
// Create a string literal

0 commit comments

Comments
 (0)