Skip to content

Commit 31a70a1

Browse files
committed
C#: Add attribute tests for delegate types.
1 parent 8ee27be commit 31a70a1

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

csharp/ql/test/library-tests/attributes/AttributeArguments.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ arguments
7676
| attributes.cs:81:14:81:17 | [Args(...)] | 3 | attributes.cs:81:56:81:60 | (...) ... |
7777
| attributes.cs:81:14:81:17 | [Args(...)] | 4 | attributes.cs:81:63:81:66 | null |
7878
| attributes.cs:81:14:81:17 | [Args(...)] | 5 | attributes.cs:81:76:81:106 | array creation of type Object[] |
79+
| attributes.cs:96:2:96:13 | [My3(...)] | 0 | attributes.cs:96:15:96:15 | 1 |
80+
| attributes.cs:97:10:97:21 | [My3(...)] | 0 | attributes.cs:97:23:97:23 | 2 |
81+
| attributes.cs:100:10:100:21 | [My3(...)] | 0 | attributes.cs:100:23:100:23 | 3 |
82+
| attributes.cs:101:8:101:19 | [My3(...)] | 0 | attributes.cs:101:21:101:21 | 4 |
7983
constructorArguments
8084
| Assembly1.dll:0:0:0:0 | [Custom(...)] | 0 | Assembly1.dll:0:0:0:0 | 1 |
8185
| Assembly1.dll:0:0:0:0 | [Custom(...)] | 0 | Assembly1.dll:0:0:0:0 | 3 |
@@ -142,6 +146,10 @@ constructorArguments
142146
| attributes.cs:81:14:81:17 | [Args(...)] | 2 | attributes.cs:81:50:81:53 | null |
143147
| attributes.cs:81:14:81:17 | [Args(...)] | 3 | attributes.cs:81:56:81:60 | (...) ... |
144148
| attributes.cs:81:14:81:17 | [Args(...)] | 4 | attributes.cs:81:63:81:66 | null |
149+
| attributes.cs:96:2:96:13 | [My3(...)] | 0 | attributes.cs:96:15:96:15 | 1 |
150+
| attributes.cs:97:10:97:21 | [My3(...)] | 0 | attributes.cs:97:23:97:23 | 2 |
151+
| attributes.cs:100:10:100:21 | [My3(...)] | 0 | attributes.cs:100:23:100:23 | 3 |
152+
| attributes.cs:101:8:101:19 | [My3(...)] | 0 | attributes.cs:101:21:101:21 | 4 |
145153
namedArguments
146154
| Assembly1.dll:0:0:0:0 | [Custom(...)] | Prop2 | Assembly1.dll:0:0:0:0 | array creation of type Object[] |
147155
| Assembly1.dll:0:0:0:0 | [Custom(...)] | Prop2 | Assembly1.dll:0:0:0:0 | array creation of type Object[] |

csharp/ql/test/library-tests/attributes/AttributeElements.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
| attributes.cs:78:14:78:14 | X | attributes.cs:77:2:77:5 | [Args(...)] | ArgsAttribute |
1919
| attributes.cs:82:9:82:18 | SomeMethod | attributes.cs:80:6:80:9 | [Args(...)] | ArgsAttribute |
2020
| attributes.cs:82:9:82:18 | SomeMethod | attributes.cs:81:14:81:17 | [Args(...)] | ArgsAttribute |
21+
| attributes.cs:98:14:98:24 | Invoke | attributes.cs:97:10:97:21 | [My3(...)] | My3Attribute |
22+
| attributes.cs:98:14:98:24 | My1Delegate | attributes.cs:96:2:96:13 | [My3(...)] | My3Attribute |
23+
| attributes.cs:102:17:102:27 | Invoke | attributes.cs:100:10:100:21 | [My3(...)] | My3Attribute |
24+
| attributes.cs:102:17:102:27 | My2Delegate | attributes.cs:101:8:101:19 | [My3(...)] | My3Attribute |
2125
| attributes.dll:0:0:0:0 | attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | attributes.cs:10:12:10:24 | [AssemblyTitle(...)] | System.Reflection.AssemblyTitleAttribute |
2226
| attributes.dll:0:0:0:0 | attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | attributes.cs:11:12:11:30 | [AssemblyDescription(...)] | System.Reflection.AssemblyDescriptionAttribute |
2327
| attributes.dll:0:0:0:0 | attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | attributes.cs:12:12:12:32 | [AssemblyConfiguration(...)] | System.Reflection.AssemblyConfigurationAttribute |

csharp/ql/test/library-tests/attributes/PrintAst.expected

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,27 @@ attributes.cs:
300300
# 88| -1: [TypeMention] int
301301
# 88| 1: [IntLiteral] 13
302302
# 88| 4: [BlockStmt] {...}
303+
# 91| [Class] My3Attribute
304+
#-----| 3: (Base types)
305+
# 91| 0: [TypeMention] Attribute
306+
# 93| 4: [InstanceConstructor] My3Attribute
307+
#-----| 2: (Parameters)
308+
# 93| 0: [Parameter] x
309+
# 93| -1: [TypeMention] int
310+
# 93| 4: [BlockStmt] {...}
311+
# 98| [DelegateType] My1Delegate
312+
#-----| 0: (Attributes)
313+
# 96| 1: [DefaultAttribute] [My3(...)]
314+
# 96| -1: [TypeMention] My3Attribute
315+
# 96| 0: [IntLiteral] 1
316+
#-----| 2: (Parameters)
317+
# 98| 0: [Parameter] message
318+
# 98| -1: [TypeMention] string
319+
# 102| [DelegateType] My2Delegate
320+
#-----| 0: (Attributes)
321+
# 101| 1: [DefaultAttribute] [My3(...)]
322+
# 101| -1: [TypeMention] My3Attribute
323+
# 101| 0: [IntLiteral] 4
324+
#-----| 2: (Parameters)
325+
# 102| 0: [Parameter] message
326+
# 102| -1: [TypeMention] string

csharp/ql/test/library-tests/attributes/attributes.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,17 @@ class My2Attribute : Attribute
8686
{
8787
public int X { get; set; }
8888
public My2Attribute(bool a, bool b, int i = 12, int j = 13) { }
89-
}
89+
}
90+
91+
class My3Attribute : Attribute
92+
{
93+
public My3Attribute(int x) { }
94+
}
95+
96+
[My3Attribute(1)]
97+
[return: My3Attribute(2)]
98+
delegate int My1Delegate(string message);
99+
100+
[return: My3Attribute(3)]
101+
[type: My3Attribute(4)]
102+
delegate string My2Delegate(string message);

0 commit comments

Comments
 (0)