From f412d49ba4e703af09c4fdfd126eeca176c71daf Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Fri, 28 Jan 2022 09:15:59 +0100 Subject: [PATCH] C#: Add some examples lambdas with different kind of attributes and update existing testcases. --- .../library-tests/csharp10/LambdaAttributes.cs | 18 ++++++++++++++++++ .../library-tests/csharp10/lambda.expected | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 csharp/ql/test/library-tests/csharp10/LambdaAttributes.cs diff --git a/csharp/ql/test/library-tests/csharp10/LambdaAttributes.cs b/csharp/ql/test/library-tests/csharp10/LambdaAttributes.cs new file mode 100644 index 00000000000..0dff83a8885 --- /dev/null +++ b/csharp/ql/test/library-tests/csharp10/LambdaAttributes.cs @@ -0,0 +1,18 @@ +using System; + +public class Example : Attribute +{ + public Example(int x) { } +} + +public class LambdaAttributes +{ + + public void M1() + { + // Examples needed for attributes. + var f7 = ([Example(1)] int x) => x.ToString(); // Parameter attribute + var f8 =[Example(2)] (int x) => x.ToString(); // Lambda attribute + var f9 =[return: Example(3)] (int x) => x.ToString(); // Return value attribute + } +} \ No newline at end of file diff --git a/csharp/ql/test/library-tests/csharp10/lambda.expected b/csharp/ql/test/library-tests/csharp10/lambda.expected index f97a3c8ca04..64db00fa57f 100644 --- a/csharp/ql/test/library-tests/csharp10/lambda.expected +++ b/csharp/ql/test/library-tests/csharp10/lambda.expected @@ -5,11 +5,17 @@ lambdaDeclaration | Func | Lambda.cs:17:13:17:14 | f6 | Lambda.cs:17:18:17:45 | (...) => ... | | Func | Lambda.cs:8:27:8:28 | f1 | Lambda.cs:8:32:8:54 | (...) => ... | | Func | Lambda.cs:9:13:9:14 | f2 | Lambda.cs:9:18:9:40 | (...) => ... | +| Func | LambdaAttributes.cs:14:13:14:14 | f7 | LambdaAttributes.cs:14:18:14:53 | (...) => ... | +| Func | LambdaAttributes.cs:15:13:15:14 | f8 | LambdaAttributes.cs:15:17:15:52 | (...) => ... | +| Func | LambdaAttributes.cs:16:13:16:14 | f9 | LambdaAttributes.cs:16:17:16:60 | (...) => ... | lambdaDeclarationNatural | Func | Lambda.cs:16:13:16:14 | f5 | Lambda.cs:16:18:16:42 | (...) => ... | | Func | Lambda.cs:12:13:12:14 | f3 | Lambda.cs:12:18:12:47 | (...) => ... | | Func | Lambda.cs:17:13:17:14 | f6 | Lambda.cs:17:18:17:45 | (...) => ... | | Func | Lambda.cs:9:13:9:14 | f2 | Lambda.cs:9:18:9:40 | (...) => ... | +| Func | LambdaAttributes.cs:14:13:14:14 | f7 | LambdaAttributes.cs:14:18:14:53 | (...) => ... | +| Func | LambdaAttributes.cs:15:13:15:14 | f8 | LambdaAttributes.cs:15:17:15:52 | (...) => ... | +| Func | LambdaAttributes.cs:16:13:16:14 | f9 | LambdaAttributes.cs:16:17:16:60 | (...) => ... | lambdaDeclarationExplicitReturnType | Func | int | int | Lambda.cs:16:13:16:14 | f5 | Lambda.cs:16:18:16:42 | (...) => ... | | Func | object | object | Lambda.cs:12:13:12:14 | f3 | Lambda.cs:12:18:12:47 | (...) => ... |