Skip to content

Commit 77763d7

Browse files
authored
Merge pull request #7559 from michaelnebel/csharp/const-interpolatedstring
C#: Constant string interpolation (test only).
2 parents 2a36744 + 1d8f8f7 commit 77763d7

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
public class MyConstStringInterpolationClass
4+
{
5+
public const string hello = "Hello";
6+
public const string helloWorld = $"{hello} World";
7+
public const string reallyHelloWorld = $"Really {helloWorld}";
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
inserts
2+
| ConstInterpolatedString.cs:6:38:6:53 | $"..." | ConstInterpolatedString.cs:6:41:6:45 | access to constant hello |
3+
| ConstInterpolatedString.cs:7:44:7:65 | $"..." | ConstInterpolatedString.cs:7:54:7:63 | access to constant helloWorld |
4+
texts
5+
| ConstInterpolatedString.cs:6:38:6:53 | $"..." | ConstInterpolatedString.cs:6:47:6:52 | " World" |
6+
| ConstInterpolatedString.cs:7:44:7:65 | $"..." | ConstInterpolatedString.cs:7:46:7:52 | "Really " |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import csharp
2+
3+
query predicate inserts(InterpolatedStringExpr expr, Expr e) { expr.getAnInsert() = e }
4+
5+
query predicate texts(InterpolatedStringExpr expr, StringLiteral literal) {
6+
expr.getAText() = literal
7+
}

0 commit comments

Comments
 (0)