Skip to content

Commit 915770b

Browse files
committed
C#: Add QL overlay tests.
1 parent fccbb8a commit 915770b

File tree

15 files changed

+880
-0
lines changed

15 files changed

+880
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
3+
namespace ConsoleApp1
4+
{
5+
public class A
6+
{
7+
private string name;
8+
public A(string x)
9+
{
10+
name = x;
11+
}
12+
13+
// Destructor
14+
~A()
15+
{
16+
Console.WriteLine("Destructor called!");
17+
}
18+
19+
public string Prop { get; set; } = "Hello";
20+
21+
public object this[int i]
22+
{
23+
get { return new object(); }
24+
set { }
25+
}
26+
27+
/*
28+
* An example event
29+
*/
30+
public event EventHandler Clicked
31+
{
32+
add
33+
{
34+
Console.WriteLine("Handler added");
35+
}
36+
remove
37+
{
38+
Console.WriteLine("Handler removed");
39+
}
40+
}
41+
42+
public static A operator +(A a, A b)
43+
{
44+
return a;
45+
}
46+
47+
[MyObsolete]
48+
public void ObsoleteMethod() { }
49+
50+
public int OldMethod(int x)
51+
{
52+
var y = x + 1;
53+
return y;
54+
}
55+
56+
public override string ToString()
57+
{
58+
var x = $"A: {name}";
59+
return x;
60+
}
61+
}
62+
63+
public class MyObsoleteAttribute : Attribute { }
64+
65+
public class B { }
66+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
3+
namespace ConsoleApp1
4+
{
5+
internal class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
if (args.Length == 0)
10+
{
11+
Console.WriteLine("Print usage instructions here.");
12+
return;
13+
}
14+
var x = args[0];
15+
var a = new A(x);
16+
Console.WriteLine(a.ToString());
17+
}
18+
19+
private string programName;
20+
21+
public Program(string x)
22+
{
23+
programName = x;
24+
}
25+
26+
// Program destructor
27+
~Program()
28+
{
29+
Console.WriteLine("Program destructor called!");
30+
}
31+
32+
public string ProgramProp { get; set; } = "Hello World!";
33+
34+
public string this[int i]
35+
{
36+
get { return string.Empty; }
37+
set { }
38+
}
39+
40+
/*
41+
* A program event.
42+
*/
43+
public event EventHandler ProgramClicked
44+
{
45+
add
46+
{
47+
Console.WriteLine("Program handler added");
48+
}
49+
remove
50+
{
51+
Console.WriteLine("Program handler removed");
52+
}
53+
}
54+
55+
public static Program operator -(Program a, Program b)
56+
{
57+
return b;
58+
}
59+
60+
[Program]
61+
public void AnnotatedMethod() { }
62+
}
63+
64+
public class ProgramAttribute : Attribute { }
65+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: --standalone
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
expressions
2+
| A.cs:8:16:8:16 | call to constructor Object |
3+
| A.cs:10:13:10:16 | access to field name |
4+
| A.cs:10:13:10:16 | this access |
5+
| A.cs:10:13:10:20 | ... = ... |
6+
| A.cs:10:20:10:20 | access to parameter x |
7+
| A.cs:16:13:16:19 | access to type Console |
8+
| A.cs:16:13:16:51 | call to method WriteLine |
9+
| A.cs:16:31:16:50 | "Destructor called!" |
10+
| A.cs:19:23:19:26 | access to property Prop |
11+
| A.cs:19:23:19:26 | this access |
12+
| A.cs:19:42:19:50 | ... = ... |
13+
| A.cs:19:44:19:50 | "Hello" |
14+
| A.cs:23:26:23:37 | object creation of type Object |
15+
| A.cs:34:17:34:23 | access to type Console |
16+
| A.cs:34:17:34:50 | call to method WriteLine |
17+
| A.cs:34:35:34:49 | "Handler added" |
18+
| A.cs:38:17:38:23 | access to type Console |
19+
| A.cs:38:17:38:52 | call to method WriteLine |
20+
| A.cs:38:35:38:51 | "Handler removed" |
21+
| A.cs:44:20:44:20 | access to parameter a |
22+
| A.cs:52:17:52:17 | access to local variable y |
23+
| A.cs:52:17:52:25 | Int32 y = ... |
24+
| A.cs:52:21:52:21 | access to parameter x |
25+
| A.cs:52:21:52:25 | ... + ... |
26+
| A.cs:52:25:52:25 | 1 |
27+
| A.cs:53:20:53:20 | access to local variable y |
28+
| A.cs:58:17:58:17 | access to local variable x |
29+
| A.cs:58:17:58:32 | String x = ... |
30+
| A.cs:58:21:58:32 | $"..." |
31+
| A.cs:58:23:58:25 | "A: " |
32+
| A.cs:58:26:58:31 | {...} |
33+
| A.cs:58:27:58:30 | access to field name |
34+
| A.cs:58:27:58:30 | this access |
35+
| A.cs:59:20:59:20 | access to local variable x |
36+
| A.cs:63:18:63:36 | call to constructor Attribute |
37+
| A.cs:65:18:65:18 | call to constructor Object |
38+
| Program.cs:9:17:9:20 | access to parameter args |
39+
| Program.cs:9:17:9:27 | access to property Length |
40+
| Program.cs:9:17:9:32 | ... == ... |
41+
| Program.cs:9:32:9:32 | 0 |
42+
| Program.cs:11:17:11:23 | access to type Console |
43+
| Program.cs:11:17:11:67 | call to method WriteLine |
44+
| Program.cs:11:35:11:66 | "Print usage instructions here." |
45+
| Program.cs:14:17:14:17 | access to local variable x |
46+
| Program.cs:14:17:14:27 | String x = ... |
47+
| Program.cs:14:21:14:24 | access to parameter args |
48+
| Program.cs:14:21:14:27 | access to array element |
49+
| Program.cs:14:26:14:26 | 0 |
50+
| Program.cs:15:17:15:17 | access to local variable a |
51+
| Program.cs:15:17:15:28 | A a = ... |
52+
| Program.cs:15:21:15:28 | object creation of type A |
53+
| Program.cs:15:27:15:27 | access to local variable x |
54+
| Program.cs:16:13:16:19 | access to type Console |
55+
| Program.cs:16:13:16:43 | call to method WriteLine |
56+
| Program.cs:16:31:16:31 | access to local variable a |
57+
| Program.cs:16:31:16:42 | call to method ToString |
58+
| Program.cs:21:16:21:22 | call to constructor Object |
59+
| Program.cs:23:13:23:23 | access to field programName |
60+
| Program.cs:23:13:23:23 | this access |
61+
| Program.cs:23:13:23:27 | ... = ... |
62+
| Program.cs:23:27:23:27 | access to parameter x |
63+
| Program.cs:29:13:29:19 | access to type Console |
64+
| Program.cs:29:13:29:59 | call to method WriteLine |
65+
| Program.cs:29:31:29:58 | "Program destructor called!" |
66+
| Program.cs:32:23:32:33 | access to property ProgramProp |
67+
| Program.cs:32:23:32:33 | this access |
68+
| Program.cs:32:49:32:64 | ... = ... |
69+
| Program.cs:32:51:32:64 | "Hello World!" |
70+
| Program.cs:36:26:36:31 | access to type String |
71+
| Program.cs:36:26:36:37 | access to field Empty |
72+
| Program.cs:47:17:47:23 | access to type Console |
73+
| Program.cs:47:17:47:58 | call to method WriteLine |
74+
| Program.cs:47:35:47:57 | "Program handler added" |
75+
| Program.cs:51:17:51:23 | access to type Console |
76+
| Program.cs:51:17:51:60 | call to method WriteLine |
77+
| Program.cs:51:35:51:59 | "Program handler removed" |
78+
| Program.cs:57:20:57:20 | access to parameter b |
79+
| Program.cs:64:18:64:33 | call to constructor Attribute |
80+
statements
81+
| A.cs:9:9:11:9 | {...} |
82+
| A.cs:10:13:10:21 | ...; |
83+
| A.cs:15:9:17:9 | {...} |
84+
| A.cs:16:13:16:52 | ...; |
85+
| A.cs:23:17:23:40 | {...} |
86+
| A.cs:23:19:23:38 | return ...; |
87+
| A.cs:24:17:24:19 | {...} |
88+
| A.cs:33:13:35:13 | {...} |
89+
| A.cs:34:17:34:51 | ...; |
90+
| A.cs:37:13:39:13 | {...} |
91+
| A.cs:38:17:38:53 | ...; |
92+
| A.cs:43:9:45:9 | {...} |
93+
| A.cs:44:13:44:21 | return ...; |
94+
| A.cs:48:38:48:40 | {...} |
95+
| A.cs:51:9:54:9 | {...} |
96+
| A.cs:52:13:52:26 | ... ...; |
97+
| A.cs:53:13:53:21 | return ...; |
98+
| A.cs:57:9:60:9 | {...} |
99+
| A.cs:58:13:58:33 | ... ...; |
100+
| A.cs:59:13:59:21 | return ...; |
101+
| A.cs:63:18:63:36 | {...} |
102+
| A.cs:65:18:65:18 | {...} |
103+
| Program.cs:8:9:17:9 | {...} |
104+
| Program.cs:9:13:13:13 | if (...) ... |
105+
| Program.cs:10:13:13:13 | {...} |
106+
| Program.cs:11:17:11:68 | ...; |
107+
| Program.cs:12:17:12:23 | return ...; |
108+
| Program.cs:14:13:14:28 | ... ...; |
109+
| Program.cs:15:13:15:29 | ... ...; |
110+
| Program.cs:16:13:16:44 | ...; |
111+
| Program.cs:22:9:24:9 | {...} |
112+
| Program.cs:23:13:23:28 | ...; |
113+
| Program.cs:28:9:30:9 | {...} |
114+
| Program.cs:29:13:29:60 | ...; |
115+
| Program.cs:36:17:36:40 | {...} |
116+
| Program.cs:36:19:36:38 | return ...; |
117+
| Program.cs:37:17:37:19 | {...} |
118+
| Program.cs:46:13:48:13 | {...} |
119+
| Program.cs:47:17:47:59 | ...; |
120+
| Program.cs:50:13:52:13 | {...} |
121+
| Program.cs:51:17:51:61 | ...; |
122+
| Program.cs:56:9:58:9 | {...} |
123+
| Program.cs:57:13:57:21 | return ...; |
124+
| Program.cs:61:39:61:41 | {...} |
125+
| Program.cs:64:18:64:33 | {...} |
126+
methods
127+
| A.cs:48:21:48:34 | ObsoleteMethod |
128+
| A.cs:50:20:50:28 | OldMethod |
129+
| A.cs:56:32:56:39 | ToString |
130+
| Program.cs:7:28:7:31 | Main |
131+
| Program.cs:61:21:61:35 | AnnotatedMethod |
132+
types
133+
| A.cs:5:18:5:18 | A |
134+
| A.cs:63:18:63:36 | MyObsoleteAttribute |
135+
| A.cs:65:18:65:18 | B |
136+
| Program.cs:5:20:5:26 | Program |
137+
| Program.cs:64:18:64:33 | ProgramAttribute |
138+
parameters
139+
| A.cs:8:25:8:25 | x |
140+
| A.cs:19:35:19:37 | value |
141+
| A.cs:21:32:21:32 | i |
142+
| A.cs:21:32:21:32 | i |
143+
| A.cs:21:32:21:32 | i |
144+
| A.cs:24:13:24:15 | value |
145+
| A.cs:32:13:32:15 | value |
146+
| A.cs:36:13:36:18 | value |
147+
| A.cs:42:38:42:38 | a |
148+
| A.cs:42:43:42:43 | b |
149+
| A.cs:50:34:50:34 | x |
150+
| Program.cs:7:42:7:45 | args |
151+
| Program.cs:21:31:21:31 | x |
152+
| Program.cs:32:42:32:44 | value |
153+
| Program.cs:34:32:34:32 | i |
154+
| Program.cs:34:32:34:32 | i |
155+
| Program.cs:34:32:34:32 | i |
156+
| Program.cs:37:13:37:15 | value |
157+
| Program.cs:45:13:45:15 | value |
158+
| Program.cs:49:13:49:18 | value |
159+
| Program.cs:55:50:55:50 | a |
160+
| Program.cs:55:61:55:61 | b |
161+
operators
162+
| A.cs:42:34:42:34 | + |
163+
| Program.cs:55:40:55:40 | - |
164+
constructors
165+
| A.cs:8:16:8:16 | A |
166+
| Program.cs:21:16:21:22 | Program |
167+
destructors
168+
| A.cs:14:10:14:10 | ~A |
169+
| Program.cs:27:10:27:16 | ~Program |
170+
fields
171+
| A.cs:7:24:7:27 | name |
172+
| Program.cs:19:24:19:34 | programName |
173+
properties
174+
| A.cs:19:23:19:26 | Prop |
175+
| Program.cs:32:23:32:33 | ProgramProp |
176+
indexers
177+
| A.cs:21:23:21:26 | Item |
178+
| Program.cs:34:23:34:26 | Item |
179+
accessors
180+
| A.cs:19:30:19:32 | get_Prop |
181+
| A.cs:19:35:19:37 | set_Prop |
182+
| A.cs:23:13:23:15 | get_Item |
183+
| A.cs:24:13:24:15 | set_Item |
184+
| A.cs:32:13:32:15 | add_Clicked |
185+
| A.cs:36:13:36:18 | remove_Clicked |
186+
| Program.cs:32:37:32:39 | get_ProgramProp |
187+
| Program.cs:32:42:32:44 | set_ProgramProp |
188+
| Program.cs:36:13:36:15 | get_Item |
189+
| Program.cs:37:13:37:15 | set_Item |
190+
| Program.cs:45:13:45:15 | add_ProgramClicked |
191+
| Program.cs:49:13:49:18 | remove_ProgramClicked |
192+
attributes
193+
| A.cs:47:10:47:19 | [MyObsolete(...)] |
194+
| Program.cs:60:10:60:16 | [Program(...)] |
195+
events
196+
| A.cs:30:35:30:41 | Clicked |
197+
| Program.cs:43:35:43:48 | ProgramClicked |
198+
eventAccessors
199+
| A.cs:32:13:32:15 | add_Clicked |
200+
| A.cs:36:13:36:18 | remove_Clicked |
201+
| Program.cs:45:13:45:15 | add_ProgramClicked |
202+
| Program.cs:49:13:49:18 | remove_ProgramClicked |
203+
usingDirectives
204+
| A.cs:1:1:1:13 | using ...; |
205+
| Program.cs:1:1:1:13 | using ...; |
206+
commentLines
207+
| A.cs:13:9:13:21 | // ... |
208+
| A.cs:27:9:27:10 | /* ... */ |
209+
| A.cs:28:1:28:27 | /* ... */ |
210+
| A.cs:29:1:29:11 | /* ... */ |
211+
| Program.cs:26:9:26:29 | // ... |
212+
| Program.cs:40:9:40:10 | /* ... */ |
213+
| Program.cs:41:1:41:27 | /* ... */ |
214+
| Program.cs:42:1:42:11 | /* ... */ |
215+
commentBlocks
216+
| A.cs:13:9:13:21 | // ... |
217+
| A.cs:27:9:29:11 | /* ... */ |
218+
| Program.cs:26:9:26:29 | // ... |
219+
| Program.cs:40:9:42:11 | /* ... */ |
220+
typeMentions
221+
| A.cs:7:17:7:22 | String |
222+
| A.cs:8:18:8:23 | String |
223+
| A.cs:16:13:16:19 | Console |
224+
| A.cs:19:16:19:21 | String |
225+
| A.cs:21:16:21:21 | Object |
226+
| A.cs:21:28:21:30 | Int32 |
227+
| A.cs:23:30:23:35 | Object |
228+
| A.cs:34:17:34:23 | Console |
229+
| A.cs:38:17:38:23 | Console |
230+
| A.cs:42:23:42:23 | A |
231+
| A.cs:42:36:42:36 | A |
232+
| A.cs:42:41:42:41 | A |
233+
| A.cs:47:10:47:19 | MyObsoleteAttribute |
234+
| A.cs:48:16:48:19 | Void |
235+
| A.cs:50:16:50:18 | Int32 |
236+
| A.cs:50:30:50:32 | Int32 |
237+
| A.cs:52:13:52:15 | Int32 |
238+
| A.cs:56:25:56:30 | String |
239+
| A.cs:58:13:58:15 | String |
240+
| A.cs:63:40:63:48 | Attribute |
241+
| Program.cs:7:23:7:26 | Void |
242+
| Program.cs:7:33:7:38 | String |
243+
| Program.cs:7:33:7:40 | String[] |
244+
| Program.cs:11:17:11:23 | Console |
245+
| Program.cs:14:13:14:15 | String |
246+
| Program.cs:15:13:15:15 | A |
247+
| Program.cs:15:25:15:25 | A |
248+
| Program.cs:16:13:16:19 | Console |
249+
| Program.cs:19:17:19:22 | String |
250+
| Program.cs:21:24:21:29 | String |
251+
| Program.cs:29:13:29:19 | Console |
252+
| Program.cs:32:16:32:21 | String |
253+
| Program.cs:34:16:34:21 | String |
254+
| Program.cs:34:28:34:30 | Int32 |
255+
| Program.cs:36:26:36:31 | String |
256+
| Program.cs:47:17:47:23 | Console |
257+
| Program.cs:51:17:51:23 | Console |
258+
| Program.cs:55:23:55:29 | Program |
259+
| Program.cs:55:42:55:48 | Program |
260+
| Program.cs:55:53:55:59 | Program |
261+
| Program.cs:60:10:60:16 | ProgramAttribute |
262+
| Program.cs:61:16:61:19 | Void |
263+
| Program.cs:64:37:64:45 | Attribute |

0 commit comments

Comments
 (0)