mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
C#: Add test cases for raw string literals.
This commit is contained in:
@@ -11,4 +11,28 @@ public class MyTestClass
|
||||
_ => "something else"
|
||||
}}.";
|
||||
}
|
||||
|
||||
public void M2()
|
||||
{
|
||||
// Raw string literal.
|
||||
var message1 = """
|
||||
This is my very long
|
||||
text message that spans
|
||||
accross multiple lines
|
||||
and is very useful.
|
||||
""";
|
||||
|
||||
// String interpolation using a raw string literal.
|
||||
var message2 = $"""
|
||||
The nested message
|
||||
is "{message1}" and everything
|
||||
spans multiple lines.
|
||||
""";
|
||||
|
||||
// String interpolation using a raw string literal that requires double curly braces.
|
||||
var message3 = $$"""
|
||||
Show no curly braces: {{message1}}
|
||||
Show matching set of curly braces: {{{message2}}}
|
||||
""";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
interpolatedstrings
|
||||
| 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 | "." |
|
||||
| Strings.cs:26:24:30:11 | $"..." | Strings.cs:27:1:28:14 | "The nested message\n is \\"" |
|
||||
| Strings.cs:26:24:30:11 | $"..." | Strings.cs:28:16:28:23 | access to local variable message1 |
|
||||
| Strings.cs:26:24:30:11 | $"..." | Strings.cs:28:25:29:29 | "\\" and everything\nspans multiple lines." |
|
||||
| Strings.cs:33:24:36:11 | $"..." | Strings.cs:34:1:34:30 | "Show no curly braces: " |
|
||||
| Strings.cs:33:24:36:11 | $"..." | Strings.cs:34:33:34:40 | access to local variable message1 |
|
||||
| Strings.cs:33:24:36:11 | $"..." | Strings.cs:34:43:35:44 | "\nShow matching set of curly braces: {" |
|
||||
| Strings.cs:33:24:36:11 | $"..." | Strings.cs:35:47:35:54 | access to local variable message2 |
|
||||
| Strings.cs:33:24:36:11 | $"..." | Strings.cs:35:57:35:57 | "}" |
|
||||
stringliterals
|
||||
| Strings.cs:18:24:23:11 | "This is my very long\n text message that spans\n accross multiple lines\nand is very useful." |
|
||||
| Strings.cs:27:1:28:14 | "The nested message\n is \\"" |
|
||||
| Strings.cs:28:25:29:29 | "\\" and everything\nspans multiple lines." |
|
||||
| Strings.cs:34:1:34:30 | "Show no curly braces: " |
|
||||
| Strings.cs:34:43:35:44 | "\nShow matching set of curly braces: {" |
|
||||
| Strings.cs:35:57:35:57 | "}" |
|
||||
|
||||
@@ -4,3 +4,7 @@ query predicate interpolatedstrings(InterpolatedStringExpr se, Expr e) {
|
||||
se.getFile().getStem() = "Strings" and
|
||||
(e = se.getAText() or e = se.getAnInsert())
|
||||
}
|
||||
|
||||
query predicate stringliterals(StringLiteral s) {
|
||||
s.getFile().getStem() = "Strings" and s.getEnclosingCallable().getName() = "M2"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user