mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C#: Add test for interpolated strings, where newlines are used in the provided expression.
This commit is contained in:
14
csharp/ql/test/library-tests/csharp11/Strings.cs
Normal file
14
csharp/ql/test/library-tests/csharp11/Strings.cs
Normal 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"
|
||||
}}.";
|
||||
}
|
||||
}
|
||||
3
csharp/ql/test/library-tests/csharp11/strings.expected
Normal file
3
csharp/ql/test/library-tests/csharp11/strings.expected
Normal 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 | "." |
|
||||
6
csharp/ql/test/library-tests/csharp11/strings.ql
Normal file
6
csharp/ql/test/library-tests/csharp11/strings.ql
Normal 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())
|
||||
}
|
||||
Reference in New Issue
Block a user