C#: Add test for interpolated strings, where newlines are used in the provided expression.

This commit is contained in:
Michael Nebel
2023-01-17 09:59:45 +01:00
parent 976b0401be
commit ad20e81d05
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System;
public class MyTestClass
{
public string M1(int x)
{
// Use an expression that spans across multiple lines in a string interpolation.
return $"This is my int {x switch
{
42 => "forty two",
_ => "something else"
}}.";
}
}

View File

@@ -0,0 +1,3 @@
| Strings.cs:8:16:12:12 | $"..." | Strings.cs:8:18:8:32 | "This is my int " |
| Strings.cs:8:16:12:12 | $"..." | Strings.cs:8:34:12:9 | ... switch { ... } |
| Strings.cs:8:16:12:12 | $"..." | Strings.cs:12:11:12:11 | "." |

View File

@@ -0,0 +1,6 @@
import csharp
query predicate interpolatedstrings(InterpolatedStringExpr se, Expr e) {
se.getFile().getStem() = "Strings" and
(e = se.getAText() or e = se.getAnInsert())
}