From 5b89f0e0b8f7b62fe72b4c892f5ab45041ba9e03 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Tue, 11 Jan 2022 12:01:40 +0100 Subject: [PATCH 1/2] C#: Add example of const interpolated string. --- .../library-tests/csharp10/ConstInterpolatedString.cs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 csharp/ql/test/library-tests/csharp10/ConstInterpolatedString.cs diff --git a/csharp/ql/test/library-tests/csharp10/ConstInterpolatedString.cs b/csharp/ql/test/library-tests/csharp10/ConstInterpolatedString.cs new file mode 100644 index 00000000000..1dba25d5182 --- /dev/null +++ b/csharp/ql/test/library-tests/csharp10/ConstInterpolatedString.cs @@ -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}"; +} \ No newline at end of file From 1d8f8f79bb61799768ab037042f4bdabc7dc2472 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Tue, 11 Jan 2022 12:02:07 +0100 Subject: [PATCH 2/2] C#: Add const interpolated string test case. --- .../csharp10/constInterpolatedString.expected | 6 ++++++ .../test/library-tests/csharp10/constInterpolatedString.ql | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 csharp/ql/test/library-tests/csharp10/constInterpolatedString.expected create mode 100644 csharp/ql/test/library-tests/csharp10/constInterpolatedString.ql diff --git a/csharp/ql/test/library-tests/csharp10/constInterpolatedString.expected b/csharp/ql/test/library-tests/csharp10/constInterpolatedString.expected new file mode 100644 index 00000000000..849ded1bb57 --- /dev/null +++ b/csharp/ql/test/library-tests/csharp10/constInterpolatedString.expected @@ -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 " | diff --git a/csharp/ql/test/library-tests/csharp10/constInterpolatedString.ql b/csharp/ql/test/library-tests/csharp10/constInterpolatedString.ql new file mode 100644 index 00000000000..8f3ef221828 --- /dev/null +++ b/csharp/ql/test/library-tests/csharp10/constInterpolatedString.ql @@ -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 +}