Merge pull request #7559 from michaelnebel/csharp/const-interpolatedstring

C#: Constant string interpolation (test only).
This commit is contained in:
Michael Nebel
2022-01-11 14:01:55 +01:00
committed by GitHub
3 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
using System;
public class MyConstStringInterpolationClass
{
public const string hello = "Hello";
public const string helloWorld = $"{hello} World";
public const string reallyHelloWorld = $"Really {helloWorld}";
}

View File

@@ -0,0 +1,6 @@
inserts
| ConstInterpolatedString.cs:6:38:6:53 | $"..." | ConstInterpolatedString.cs:6:41:6:45 | access to constant hello |
| ConstInterpolatedString.cs:7:44:7:65 | $"..." | ConstInterpolatedString.cs:7:54:7:63 | access to constant helloWorld |
texts
| ConstInterpolatedString.cs:6:38:6:53 | $"..." | ConstInterpolatedString.cs:6:47:6:52 | " World" |
| ConstInterpolatedString.cs:7:44:7:65 | $"..." | ConstInterpolatedString.cs:7:46:7:52 | "Really " |

View File

@@ -0,0 +1,7 @@
import csharp
query predicate inserts(InterpolatedStringExpr expr, Expr e) { expr.getAnInsert() = e }
query predicate texts(InterpolatedStringExpr expr, StringLiteral literal) {
expr.getAText() = literal
}