mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Add QL overlay tests.
This commit is contained in:
66
csharp/ql/test/library-tests/overlay/base/A.cs
Normal file
66
csharp/ql/test/library-tests/overlay/base/A.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public class A
|
||||
{
|
||||
private string name;
|
||||
public A(string x)
|
||||
{
|
||||
name = x;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~A()
|
||||
{
|
||||
Console.WriteLine("Destructor called!");
|
||||
}
|
||||
|
||||
public string Prop { get; set; } = "Hello";
|
||||
|
||||
public object this[int i]
|
||||
{
|
||||
get { return new object(); }
|
||||
set { }
|
||||
}
|
||||
|
||||
/*
|
||||
* An example event
|
||||
*/
|
||||
public event EventHandler Clicked
|
||||
{
|
||||
add
|
||||
{
|
||||
Console.WriteLine("Handler added");
|
||||
}
|
||||
remove
|
||||
{
|
||||
Console.WriteLine("Handler removed");
|
||||
}
|
||||
}
|
||||
|
||||
public static A operator +(A a, A b)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
[MyObsolete]
|
||||
public void ObsoleteMethod() { }
|
||||
|
||||
public int OldMethod(int x)
|
||||
{
|
||||
var y = x + 1;
|
||||
return y;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var x = $"A: {name}";
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
public class MyObsoleteAttribute : Attribute { }
|
||||
|
||||
public class B { }
|
||||
}
|
||||
65
csharp/ql/test/library-tests/overlay/base/Program.cs
Normal file
65
csharp/ql/test/library-tests/overlay/base/Program.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Console.WriteLine("Print usage instructions here.");
|
||||
return;
|
||||
}
|
||||
var x = args[0];
|
||||
var a = new A(x);
|
||||
Console.WriteLine(a.ToString());
|
||||
}
|
||||
|
||||
private string programName;
|
||||
|
||||
public Program(string x)
|
||||
{
|
||||
programName = x;
|
||||
}
|
||||
|
||||
// Program destructor
|
||||
~Program()
|
||||
{
|
||||
Console.WriteLine("Program destructor called!");
|
||||
}
|
||||
|
||||
public string ProgramProp { get; set; } = "Hello World!";
|
||||
|
||||
public string this[int i]
|
||||
{
|
||||
get { return string.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
/*
|
||||
* A program event.
|
||||
*/
|
||||
public event EventHandler ProgramClicked
|
||||
{
|
||||
add
|
||||
{
|
||||
Console.WriteLine("Program handler added");
|
||||
}
|
||||
remove
|
||||
{
|
||||
Console.WriteLine("Program handler removed");
|
||||
}
|
||||
}
|
||||
|
||||
public static Program operator -(Program a, Program b)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
[Program]
|
||||
public void AnnotatedMethod() { }
|
||||
}
|
||||
|
||||
public class ProgramAttribute : Attribute { }
|
||||
}
|
||||
1
csharp/ql/test/library-tests/overlay/base/options
Normal file
1
csharp/ql/test/library-tests/overlay/base/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --standalone
|
||||
263
csharp/ql/test/library-tests/overlay/base/test.expected
Normal file
263
csharp/ql/test/library-tests/overlay/base/test.expected
Normal file
@@ -0,0 +1,263 @@
|
||||
expressions
|
||||
| A.cs:8:16:8:16 | call to constructor Object |
|
||||
| A.cs:10:13:10:16 | access to field name |
|
||||
| A.cs:10:13:10:16 | this access |
|
||||
| A.cs:10:13:10:20 | ... = ... |
|
||||
| A.cs:10:20:10:20 | access to parameter x |
|
||||
| A.cs:16:13:16:19 | access to type Console |
|
||||
| A.cs:16:13:16:51 | call to method WriteLine |
|
||||
| A.cs:16:31:16:50 | "Destructor called!" |
|
||||
| A.cs:19:23:19:26 | access to property Prop |
|
||||
| A.cs:19:23:19:26 | this access |
|
||||
| A.cs:19:42:19:50 | ... = ... |
|
||||
| A.cs:19:44:19:50 | "Hello" |
|
||||
| A.cs:23:26:23:37 | object creation of type Object |
|
||||
| A.cs:34:17:34:23 | access to type Console |
|
||||
| A.cs:34:17:34:50 | call to method WriteLine |
|
||||
| A.cs:34:35:34:49 | "Handler added" |
|
||||
| A.cs:38:17:38:23 | access to type Console |
|
||||
| A.cs:38:17:38:52 | call to method WriteLine |
|
||||
| A.cs:38:35:38:51 | "Handler removed" |
|
||||
| A.cs:44:20:44:20 | access to parameter a |
|
||||
| A.cs:52:17:52:17 | access to local variable y |
|
||||
| A.cs:52:17:52:25 | Int32 y = ... |
|
||||
| A.cs:52:21:52:21 | access to parameter x |
|
||||
| A.cs:52:21:52:25 | ... + ... |
|
||||
| A.cs:52:25:52:25 | 1 |
|
||||
| A.cs:53:20:53:20 | access to local variable y |
|
||||
| A.cs:58:17:58:17 | access to local variable x |
|
||||
| A.cs:58:17:58:32 | String x = ... |
|
||||
| A.cs:58:21:58:32 | $"..." |
|
||||
| A.cs:58:23:58:25 | "A: " |
|
||||
| A.cs:58:26:58:31 | {...} |
|
||||
| A.cs:58:27:58:30 | access to field name |
|
||||
| A.cs:58:27:58:30 | this access |
|
||||
| A.cs:59:20:59:20 | access to local variable x |
|
||||
| A.cs:63:18:63:36 | call to constructor Attribute |
|
||||
| A.cs:65:18:65:18 | call to constructor Object |
|
||||
| Program.cs:9:17:9:20 | access to parameter args |
|
||||
| Program.cs:9:17:9:27 | access to property Length |
|
||||
| Program.cs:9:17:9:32 | ... == ... |
|
||||
| Program.cs:9:32:9:32 | 0 |
|
||||
| Program.cs:11:17:11:23 | access to type Console |
|
||||
| Program.cs:11:17:11:67 | call to method WriteLine |
|
||||
| Program.cs:11:35:11:66 | "Print usage instructions here." |
|
||||
| Program.cs:14:17:14:17 | access to local variable x |
|
||||
| Program.cs:14:17:14:27 | String x = ... |
|
||||
| Program.cs:14:21:14:24 | access to parameter args |
|
||||
| Program.cs:14:21:14:27 | access to array element |
|
||||
| Program.cs:14:26:14:26 | 0 |
|
||||
| Program.cs:15:17:15:17 | access to local variable a |
|
||||
| Program.cs:15:17:15:28 | A a = ... |
|
||||
| Program.cs:15:21:15:28 | object creation of type A |
|
||||
| Program.cs:15:27:15:27 | access to local variable x |
|
||||
| Program.cs:16:13:16:19 | access to type Console |
|
||||
| Program.cs:16:13:16:43 | call to method WriteLine |
|
||||
| Program.cs:16:31:16:31 | access to local variable a |
|
||||
| Program.cs:16:31:16:42 | call to method ToString |
|
||||
| Program.cs:21:16:21:22 | call to constructor Object |
|
||||
| Program.cs:23:13:23:23 | access to field programName |
|
||||
| Program.cs:23:13:23:23 | this access |
|
||||
| Program.cs:23:13:23:27 | ... = ... |
|
||||
| Program.cs:23:27:23:27 | access to parameter x |
|
||||
| Program.cs:29:13:29:19 | access to type Console |
|
||||
| Program.cs:29:13:29:59 | call to method WriteLine |
|
||||
| Program.cs:29:31:29:58 | "Program destructor called!" |
|
||||
| Program.cs:32:23:32:33 | access to property ProgramProp |
|
||||
| Program.cs:32:23:32:33 | this access |
|
||||
| Program.cs:32:49:32:64 | ... = ... |
|
||||
| Program.cs:32:51:32:64 | "Hello World!" |
|
||||
| Program.cs:36:26:36:31 | access to type String |
|
||||
| Program.cs:36:26:36:37 | access to field Empty |
|
||||
| Program.cs:47:17:47:23 | access to type Console |
|
||||
| Program.cs:47:17:47:58 | call to method WriteLine |
|
||||
| Program.cs:47:35:47:57 | "Program handler added" |
|
||||
| Program.cs:51:17:51:23 | access to type Console |
|
||||
| Program.cs:51:17:51:60 | call to method WriteLine |
|
||||
| Program.cs:51:35:51:59 | "Program handler removed" |
|
||||
| Program.cs:57:20:57:20 | access to parameter b |
|
||||
| Program.cs:64:18:64:33 | call to constructor Attribute |
|
||||
statements
|
||||
| A.cs:9:9:11:9 | {...} |
|
||||
| A.cs:10:13:10:21 | ...; |
|
||||
| A.cs:15:9:17:9 | {...} |
|
||||
| A.cs:16:13:16:52 | ...; |
|
||||
| A.cs:23:17:23:40 | {...} |
|
||||
| A.cs:23:19:23:38 | return ...; |
|
||||
| A.cs:24:17:24:19 | {...} |
|
||||
| A.cs:33:13:35:13 | {...} |
|
||||
| A.cs:34:17:34:51 | ...; |
|
||||
| A.cs:37:13:39:13 | {...} |
|
||||
| A.cs:38:17:38:53 | ...; |
|
||||
| A.cs:43:9:45:9 | {...} |
|
||||
| A.cs:44:13:44:21 | return ...; |
|
||||
| A.cs:48:38:48:40 | {...} |
|
||||
| A.cs:51:9:54:9 | {...} |
|
||||
| A.cs:52:13:52:26 | ... ...; |
|
||||
| A.cs:53:13:53:21 | return ...; |
|
||||
| A.cs:57:9:60:9 | {...} |
|
||||
| A.cs:58:13:58:33 | ... ...; |
|
||||
| A.cs:59:13:59:21 | return ...; |
|
||||
| A.cs:63:18:63:36 | {...} |
|
||||
| A.cs:65:18:65:18 | {...} |
|
||||
| Program.cs:8:9:17:9 | {...} |
|
||||
| Program.cs:9:13:13:13 | if (...) ... |
|
||||
| Program.cs:10:13:13:13 | {...} |
|
||||
| Program.cs:11:17:11:68 | ...; |
|
||||
| Program.cs:12:17:12:23 | return ...; |
|
||||
| Program.cs:14:13:14:28 | ... ...; |
|
||||
| Program.cs:15:13:15:29 | ... ...; |
|
||||
| Program.cs:16:13:16:44 | ...; |
|
||||
| Program.cs:22:9:24:9 | {...} |
|
||||
| Program.cs:23:13:23:28 | ...; |
|
||||
| Program.cs:28:9:30:9 | {...} |
|
||||
| Program.cs:29:13:29:60 | ...; |
|
||||
| Program.cs:36:17:36:40 | {...} |
|
||||
| Program.cs:36:19:36:38 | return ...; |
|
||||
| Program.cs:37:17:37:19 | {...} |
|
||||
| Program.cs:46:13:48:13 | {...} |
|
||||
| Program.cs:47:17:47:59 | ...; |
|
||||
| Program.cs:50:13:52:13 | {...} |
|
||||
| Program.cs:51:17:51:61 | ...; |
|
||||
| Program.cs:56:9:58:9 | {...} |
|
||||
| Program.cs:57:13:57:21 | return ...; |
|
||||
| Program.cs:61:39:61:41 | {...} |
|
||||
| Program.cs:64:18:64:33 | {...} |
|
||||
methods
|
||||
| A.cs:48:21:48:34 | ObsoleteMethod |
|
||||
| A.cs:50:20:50:28 | OldMethod |
|
||||
| A.cs:56:32:56:39 | ToString |
|
||||
| Program.cs:7:28:7:31 | Main |
|
||||
| Program.cs:61:21:61:35 | AnnotatedMethod |
|
||||
types
|
||||
| A.cs:5:18:5:18 | A |
|
||||
| A.cs:63:18:63:36 | MyObsoleteAttribute |
|
||||
| A.cs:65:18:65:18 | B |
|
||||
| Program.cs:5:20:5:26 | Program |
|
||||
| Program.cs:64:18:64:33 | ProgramAttribute |
|
||||
parameters
|
||||
| A.cs:8:25:8:25 | x |
|
||||
| A.cs:19:35:19:37 | value |
|
||||
| A.cs:21:32:21:32 | i |
|
||||
| A.cs:21:32:21:32 | i |
|
||||
| A.cs:21:32:21:32 | i |
|
||||
| A.cs:24:13:24:15 | value |
|
||||
| A.cs:32:13:32:15 | value |
|
||||
| A.cs:36:13:36:18 | value |
|
||||
| A.cs:42:38:42:38 | a |
|
||||
| A.cs:42:43:42:43 | b |
|
||||
| A.cs:50:34:50:34 | x |
|
||||
| Program.cs:7:42:7:45 | args |
|
||||
| Program.cs:21:31:21:31 | x |
|
||||
| Program.cs:32:42:32:44 | value |
|
||||
| Program.cs:34:32:34:32 | i |
|
||||
| Program.cs:34:32:34:32 | i |
|
||||
| Program.cs:34:32:34:32 | i |
|
||||
| Program.cs:37:13:37:15 | value |
|
||||
| Program.cs:45:13:45:15 | value |
|
||||
| Program.cs:49:13:49:18 | value |
|
||||
| Program.cs:55:50:55:50 | a |
|
||||
| Program.cs:55:61:55:61 | b |
|
||||
operators
|
||||
| A.cs:42:34:42:34 | + |
|
||||
| Program.cs:55:40:55:40 | - |
|
||||
constructors
|
||||
| A.cs:8:16:8:16 | A |
|
||||
| Program.cs:21:16:21:22 | Program |
|
||||
destructors
|
||||
| A.cs:14:10:14:10 | ~A |
|
||||
| Program.cs:27:10:27:16 | ~Program |
|
||||
fields
|
||||
| A.cs:7:24:7:27 | name |
|
||||
| Program.cs:19:24:19:34 | programName |
|
||||
properties
|
||||
| A.cs:19:23:19:26 | Prop |
|
||||
| Program.cs:32:23:32:33 | ProgramProp |
|
||||
indexers
|
||||
| A.cs:21:23:21:26 | Item |
|
||||
| Program.cs:34:23:34:26 | Item |
|
||||
accessors
|
||||
| A.cs:19:30:19:32 | get_Prop |
|
||||
| A.cs:19:35:19:37 | set_Prop |
|
||||
| A.cs:23:13:23:15 | get_Item |
|
||||
| A.cs:24:13:24:15 | set_Item |
|
||||
| A.cs:32:13:32:15 | add_Clicked |
|
||||
| A.cs:36:13:36:18 | remove_Clicked |
|
||||
| Program.cs:32:37:32:39 | get_ProgramProp |
|
||||
| Program.cs:32:42:32:44 | set_ProgramProp |
|
||||
| Program.cs:36:13:36:15 | get_Item |
|
||||
| Program.cs:37:13:37:15 | set_Item |
|
||||
| Program.cs:45:13:45:15 | add_ProgramClicked |
|
||||
| Program.cs:49:13:49:18 | remove_ProgramClicked |
|
||||
attributes
|
||||
| A.cs:47:10:47:19 | [MyObsolete(...)] |
|
||||
| Program.cs:60:10:60:16 | [Program(...)] |
|
||||
events
|
||||
| A.cs:30:35:30:41 | Clicked |
|
||||
| Program.cs:43:35:43:48 | ProgramClicked |
|
||||
eventAccessors
|
||||
| A.cs:32:13:32:15 | add_Clicked |
|
||||
| A.cs:36:13:36:18 | remove_Clicked |
|
||||
| Program.cs:45:13:45:15 | add_ProgramClicked |
|
||||
| Program.cs:49:13:49:18 | remove_ProgramClicked |
|
||||
usingDirectives
|
||||
| A.cs:1:1:1:13 | using ...; |
|
||||
| Program.cs:1:1:1:13 | using ...; |
|
||||
commentLines
|
||||
| A.cs:13:9:13:21 | // ... |
|
||||
| A.cs:27:9:27:10 | /* ... */ |
|
||||
| A.cs:28:1:28:27 | /* ... */ |
|
||||
| A.cs:29:1:29:11 | /* ... */ |
|
||||
| Program.cs:26:9:26:29 | // ... |
|
||||
| Program.cs:40:9:40:10 | /* ... */ |
|
||||
| Program.cs:41:1:41:27 | /* ... */ |
|
||||
| Program.cs:42:1:42:11 | /* ... */ |
|
||||
commentBlocks
|
||||
| A.cs:13:9:13:21 | // ... |
|
||||
| A.cs:27:9:29:11 | /* ... */ |
|
||||
| Program.cs:26:9:26:29 | // ... |
|
||||
| Program.cs:40:9:42:11 | /* ... */ |
|
||||
typeMentions
|
||||
| A.cs:7:17:7:22 | String |
|
||||
| A.cs:8:18:8:23 | String |
|
||||
| A.cs:16:13:16:19 | Console |
|
||||
| A.cs:19:16:19:21 | String |
|
||||
| A.cs:21:16:21:21 | Object |
|
||||
| A.cs:21:28:21:30 | Int32 |
|
||||
| A.cs:23:30:23:35 | Object |
|
||||
| A.cs:34:17:34:23 | Console |
|
||||
| A.cs:38:17:38:23 | Console |
|
||||
| A.cs:42:23:42:23 | A |
|
||||
| A.cs:42:36:42:36 | A |
|
||||
| A.cs:42:41:42:41 | A |
|
||||
| A.cs:47:10:47:19 | MyObsoleteAttribute |
|
||||
| A.cs:48:16:48:19 | Void |
|
||||
| A.cs:50:16:50:18 | Int32 |
|
||||
| A.cs:50:30:50:32 | Int32 |
|
||||
| A.cs:52:13:52:15 | Int32 |
|
||||
| A.cs:56:25:56:30 | String |
|
||||
| A.cs:58:13:58:15 | String |
|
||||
| A.cs:63:40:63:48 | Attribute |
|
||||
| Program.cs:7:23:7:26 | Void |
|
||||
| Program.cs:7:33:7:38 | String |
|
||||
| Program.cs:7:33:7:40 | String[] |
|
||||
| Program.cs:11:17:11:23 | Console |
|
||||
| Program.cs:14:13:14:15 | String |
|
||||
| Program.cs:15:13:15:15 | A |
|
||||
| Program.cs:15:25:15:25 | A |
|
||||
| Program.cs:16:13:16:19 | Console |
|
||||
| Program.cs:19:17:19:22 | String |
|
||||
| Program.cs:21:24:21:29 | String |
|
||||
| Program.cs:29:13:29:19 | Console |
|
||||
| Program.cs:32:16:32:21 | String |
|
||||
| Program.cs:34:16:34:21 | String |
|
||||
| Program.cs:34:28:34:30 | Int32 |
|
||||
| Program.cs:36:26:36:31 | String |
|
||||
| Program.cs:47:17:47:23 | Console |
|
||||
| Program.cs:51:17:51:23 | Console |
|
||||
| Program.cs:55:23:55:29 | Program |
|
||||
| Program.cs:55:42:55:48 | Program |
|
||||
| Program.cs:55:53:55:59 | Program |
|
||||
| Program.cs:60:10:60:16 | ProgramAttribute |
|
||||
| Program.cs:61:16:61:19 | Void |
|
||||
| Program.cs:64:37:64:45 | Attribute |
|
||||
1
csharp/ql/test/library-tests/overlay/base/test.qlref
Normal file
1
csharp/ql/test/library-tests/overlay/base/test.qlref
Normal file
@@ -0,0 +1 @@
|
||||
query: ../test.ql
|
||||
3
csharp/ql/test/library-tests/overlay/codeql-test.yml
Normal file
3
csharp/ql/test/library-tests/overlay/codeql-test.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
overlay:
|
||||
base: "base/"
|
||||
overlay: "overlay/"
|
||||
1
csharp/ql/test/library-tests/overlay/options
Normal file
1
csharp/ql/test/library-tests/overlay/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --standalone
|
||||
70
csharp/ql/test/library-tests/overlay/overlay/A.cs
Normal file
70
csharp/ql/test/library-tests/overlay/overlay/A.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public class C { }
|
||||
|
||||
public class A
|
||||
{
|
||||
private string name;
|
||||
public A(string x)
|
||||
{
|
||||
name = x;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~A()
|
||||
{
|
||||
Console.WriteLine("Destructor called!");
|
||||
}
|
||||
|
||||
public string Prop { get; set; } = "Hello";
|
||||
|
||||
public object this[int i]
|
||||
{
|
||||
get { return new object(); }
|
||||
set { }
|
||||
}
|
||||
|
||||
/*
|
||||
* An example event
|
||||
*/
|
||||
public event EventHandler Clicked
|
||||
{
|
||||
add
|
||||
{
|
||||
Console.WriteLine("Handler added");
|
||||
}
|
||||
remove
|
||||
{
|
||||
Console.WriteLine("Handler removed");
|
||||
}
|
||||
}
|
||||
|
||||
public static A operator +(A a, A b)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
[MyObsolete]
|
||||
public void ObsoleteMethod() { }
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string y;
|
||||
y = $"Name: {name}";
|
||||
return y;
|
||||
}
|
||||
|
||||
public void NewMethod()
|
||||
{
|
||||
if (name.EndsWith("test"))
|
||||
{
|
||||
name = name.ToUpper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MyObsoleteAttribute : Attribute { }
|
||||
}
|
||||
65
csharp/ql/test/library-tests/overlay/overlay/Program.cs
Normal file
65
csharp/ql/test/library-tests/overlay/overlay/Program.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Console.WriteLine("Print usage instructions here.");
|
||||
return;
|
||||
}
|
||||
var x = args[0];
|
||||
var a = new A(x);
|
||||
Console.WriteLine(a.ToString());
|
||||
}
|
||||
|
||||
private string programName;
|
||||
|
||||
public Program(string x)
|
||||
{
|
||||
programName = x;
|
||||
}
|
||||
|
||||
// Program destructor
|
||||
~Program()
|
||||
{
|
||||
Console.WriteLine("Program destructor called!");
|
||||
}
|
||||
|
||||
public string ProgramProp { get; set; } = "Hello World!";
|
||||
|
||||
public string this[int i]
|
||||
{
|
||||
get { return string.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
/*
|
||||
* A program event.
|
||||
*/
|
||||
public event EventHandler ProgramClicked
|
||||
{
|
||||
add
|
||||
{
|
||||
Console.WriteLine("Program handler added");
|
||||
}
|
||||
remove
|
||||
{
|
||||
Console.WriteLine("Program handler removed");
|
||||
}
|
||||
}
|
||||
|
||||
public static Program operator -(Program a, Program b)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
[Program]
|
||||
public void AnnotatedMethod() { }
|
||||
}
|
||||
|
||||
public class ProgramAttribute : Attribute { }
|
||||
}
|
||||
1
csharp/ql/test/library-tests/overlay/overlay/options
Normal file
1
csharp/ql/test/library-tests/overlay/overlay/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --standalone
|
||||
267
csharp/ql/test/library-tests/overlay/overlay/test.expected
Normal file
267
csharp/ql/test/library-tests/overlay/overlay/test.expected
Normal file
@@ -0,0 +1,267 @@
|
||||
expressions
|
||||
| A.cs:5:18:5:18 | call to constructor Object |
|
||||
| A.cs:10:16:10:16 | call to constructor Object |
|
||||
| A.cs:12:13:12:16 | access to field name |
|
||||
| A.cs:12:13:12:16 | this access |
|
||||
| A.cs:12:13:12:20 | ... = ... |
|
||||
| A.cs:12:20:12:20 | access to parameter x |
|
||||
| A.cs:18:13:18:19 | access to type Console |
|
||||
| A.cs:18:13:18:51 | call to method WriteLine |
|
||||
| A.cs:18:31:18:50 | "Destructor called!" |
|
||||
| A.cs:21:23:21:26 | access to property Prop |
|
||||
| A.cs:21:23:21:26 | this access |
|
||||
| A.cs:21:42:21:50 | ... = ... |
|
||||
| A.cs:21:44:21:50 | "Hello" |
|
||||
| A.cs:25:26:25:37 | object creation of type Object |
|
||||
| A.cs:36:17:36:23 | access to type Console |
|
||||
| A.cs:36:17:36:50 | call to method WriteLine |
|
||||
| A.cs:36:35:36:49 | "Handler added" |
|
||||
| A.cs:40:17:40:23 | access to type Console |
|
||||
| A.cs:40:17:40:52 | call to method WriteLine |
|
||||
| A.cs:40:35:40:51 | "Handler removed" |
|
||||
| A.cs:46:20:46:20 | access to parameter a |
|
||||
| A.cs:55:20:55:20 | String y |
|
||||
| A.cs:56:13:56:13 | access to local variable y |
|
||||
| A.cs:56:13:56:31 | ... = ... |
|
||||
| A.cs:56:17:56:31 | $"..." |
|
||||
| A.cs:56:19:56:24 | "Name: " |
|
||||
| A.cs:56:25:56:30 | {...} |
|
||||
| A.cs:56:26:56:29 | access to field name |
|
||||
| A.cs:56:26:56:29 | this access |
|
||||
| A.cs:57:20:57:20 | access to local variable y |
|
||||
| A.cs:62:17:62:20 | access to field name |
|
||||
| A.cs:62:17:62:20 | this access |
|
||||
| A.cs:62:17:62:37 | call to method EndsWith |
|
||||
| A.cs:62:31:62:36 | "test" |
|
||||
| A.cs:64:17:64:20 | access to field name |
|
||||
| A.cs:64:17:64:20 | this access |
|
||||
| A.cs:64:17:64:37 | ... = ... |
|
||||
| A.cs:64:24:64:27 | access to field name |
|
||||
| A.cs:64:24:64:27 | this access |
|
||||
| A.cs:64:24:64:37 | call to method ToUpper |
|
||||
| A.cs:69:18:69:36 | call to constructor Attribute |
|
||||
| Program.cs:9:17:9:20 | access to parameter args |
|
||||
| Program.cs:9:17:9:27 | access to property Length |
|
||||
| Program.cs:9:17:9:32 | ... == ... |
|
||||
| Program.cs:9:32:9:32 | 0 |
|
||||
| Program.cs:11:17:11:23 | access to type Console |
|
||||
| Program.cs:11:17:11:67 | call to method WriteLine |
|
||||
| Program.cs:11:35:11:66 | "Print usage instructions here." |
|
||||
| Program.cs:14:17:14:17 | access to local variable x |
|
||||
| Program.cs:14:17:14:27 | String x = ... |
|
||||
| Program.cs:14:21:14:24 | access to parameter args |
|
||||
| Program.cs:14:21:14:27 | access to array element |
|
||||
| Program.cs:14:26:14:26 | 0 |
|
||||
| Program.cs:15:17:15:17 | access to local variable a |
|
||||
| Program.cs:15:17:15:28 | A a = ... |
|
||||
| Program.cs:15:21:15:28 | object creation of type A |
|
||||
| Program.cs:15:27:15:27 | access to local variable x |
|
||||
| Program.cs:16:13:16:19 | access to type Console |
|
||||
| Program.cs:16:13:16:43 | call to method WriteLine |
|
||||
| Program.cs:16:31:16:31 | access to local variable a |
|
||||
| Program.cs:16:31:16:42 | call to method ToString |
|
||||
| Program.cs:21:16:21:22 | call to constructor Object |
|
||||
| Program.cs:23:13:23:23 | access to field programName |
|
||||
| Program.cs:23:13:23:23 | this access |
|
||||
| Program.cs:23:13:23:27 | ... = ... |
|
||||
| Program.cs:23:27:23:27 | access to parameter x |
|
||||
| Program.cs:29:13:29:19 | access to type Console |
|
||||
| Program.cs:29:13:29:59 | call to method WriteLine |
|
||||
| Program.cs:29:31:29:58 | "Program destructor called!" |
|
||||
| Program.cs:32:23:32:33 | access to property ProgramProp |
|
||||
| Program.cs:32:23:32:33 | this access |
|
||||
| Program.cs:32:49:32:64 | ... = ... |
|
||||
| Program.cs:32:51:32:64 | "Hello World!" |
|
||||
| Program.cs:36:26:36:31 | access to type String |
|
||||
| Program.cs:36:26:36:37 | access to field Empty |
|
||||
| Program.cs:47:17:47:23 | access to type Console |
|
||||
| Program.cs:47:17:47:58 | call to method WriteLine |
|
||||
| Program.cs:47:35:47:57 | "Program handler added" |
|
||||
| Program.cs:51:17:51:23 | access to type Console |
|
||||
| Program.cs:51:17:51:60 | call to method WriteLine |
|
||||
| Program.cs:51:35:51:59 | "Program handler removed" |
|
||||
| Program.cs:57:20:57:20 | access to parameter b |
|
||||
| Program.cs:64:18:64:33 | call to constructor Attribute |
|
||||
statements
|
||||
| A.cs:5:18:5:18 | {...} |
|
||||
| A.cs:11:9:13:9 | {...} |
|
||||
| A.cs:12:13:12:21 | ...; |
|
||||
| A.cs:17:9:19:9 | {...} |
|
||||
| A.cs:18:13:18:52 | ...; |
|
||||
| A.cs:25:17:25:40 | {...} |
|
||||
| A.cs:25:19:25:38 | return ...; |
|
||||
| A.cs:26:17:26:19 | {...} |
|
||||
| A.cs:35:13:37:13 | {...} |
|
||||
| A.cs:36:17:36:51 | ...; |
|
||||
| A.cs:39:13:41:13 | {...} |
|
||||
| A.cs:40:17:40:53 | ...; |
|
||||
| A.cs:45:9:47:9 | {...} |
|
||||
| A.cs:46:13:46:21 | return ...; |
|
||||
| A.cs:50:38:50:40 | {...} |
|
||||
| A.cs:54:9:58:9 | {...} |
|
||||
| A.cs:55:13:55:21 | ... ...; |
|
||||
| A.cs:56:13:56:32 | ...; |
|
||||
| A.cs:57:13:57:21 | return ...; |
|
||||
| A.cs:61:9:66:9 | {...} |
|
||||
| A.cs:62:13:65:13 | if (...) ... |
|
||||
| A.cs:63:13:65:13 | {...} |
|
||||
| A.cs:64:17:64:38 | ...; |
|
||||
| A.cs:69:18:69:36 | {...} |
|
||||
| Program.cs:8:9:17:9 | {...} |
|
||||
| Program.cs:9:13:13:13 | if (...) ... |
|
||||
| Program.cs:10:13:13:13 | {...} |
|
||||
| Program.cs:11:17:11:68 | ...; |
|
||||
| Program.cs:12:17:12:23 | return ...; |
|
||||
| Program.cs:14:13:14:28 | ... ...; |
|
||||
| Program.cs:15:13:15:29 | ... ...; |
|
||||
| Program.cs:16:13:16:44 | ...; |
|
||||
| Program.cs:22:9:24:9 | {...} |
|
||||
| Program.cs:23:13:23:28 | ...; |
|
||||
| Program.cs:28:9:30:9 | {...} |
|
||||
| Program.cs:29:13:29:60 | ...; |
|
||||
| Program.cs:36:17:36:40 | {...} |
|
||||
| Program.cs:36:19:36:38 | return ...; |
|
||||
| Program.cs:37:17:37:19 | {...} |
|
||||
| Program.cs:46:13:48:13 | {...} |
|
||||
| Program.cs:47:17:47:59 | ...; |
|
||||
| Program.cs:50:13:52:13 | {...} |
|
||||
| Program.cs:51:17:51:61 | ...; |
|
||||
| Program.cs:56:9:58:9 | {...} |
|
||||
| Program.cs:57:13:57:21 | return ...; |
|
||||
| Program.cs:61:39:61:41 | {...} |
|
||||
| Program.cs:64:18:64:33 | {...} |
|
||||
methods
|
||||
| A.cs:50:21:50:34 | ObsoleteMethod |
|
||||
| A.cs:53:32:53:39 | ToString |
|
||||
| A.cs:60:21:60:29 | NewMethod |
|
||||
| Program.cs:7:28:7:31 | Main |
|
||||
| Program.cs:61:21:61:35 | AnnotatedMethod |
|
||||
types
|
||||
| A.cs:5:18:5:18 | C |
|
||||
| A.cs:7:18:7:18 | A |
|
||||
| A.cs:69:18:69:36 | MyObsoleteAttribute |
|
||||
| Program.cs:5:20:5:26 | Program |
|
||||
| Program.cs:64:18:64:33 | ProgramAttribute |
|
||||
parameters
|
||||
| A.cs:10:25:10:25 | x |
|
||||
| A.cs:21:35:21:37 | value |
|
||||
| A.cs:23:32:23:32 | i |
|
||||
| A.cs:23:32:23:32 | i |
|
||||
| A.cs:23:32:23:32 | i |
|
||||
| A.cs:26:13:26:15 | value |
|
||||
| A.cs:34:13:34:15 | value |
|
||||
| A.cs:38:13:38:18 | value |
|
||||
| A.cs:44:38:44:38 | a |
|
||||
| A.cs:44:43:44:43 | b |
|
||||
| Program.cs:7:42:7:45 | args |
|
||||
| Program.cs:21:31:21:31 | x |
|
||||
| Program.cs:32:42:32:44 | value |
|
||||
| Program.cs:34:32:34:32 | i |
|
||||
| Program.cs:34:32:34:32 | i |
|
||||
| Program.cs:34:32:34:32 | i |
|
||||
| Program.cs:37:13:37:15 | value |
|
||||
| Program.cs:45:13:45:15 | value |
|
||||
| Program.cs:49:13:49:18 | value |
|
||||
| Program.cs:55:50:55:50 | a |
|
||||
| Program.cs:55:61:55:61 | b |
|
||||
operators
|
||||
| A.cs:44:34:44:34 | + |
|
||||
| Program.cs:55:40:55:40 | - |
|
||||
constructors
|
||||
| A.cs:10:16:10:16 | A |
|
||||
| Program.cs:21:16:21:22 | Program |
|
||||
destructors
|
||||
| A.cs:16:10:16:10 | ~A |
|
||||
| Program.cs:27:10:27:16 | ~Program |
|
||||
fields
|
||||
| A.cs:9:24:9:27 | name |
|
||||
| Program.cs:19:24:19:34 | programName |
|
||||
properties
|
||||
| A.cs:21:23:21:26 | Prop |
|
||||
| Program.cs:32:23:32:33 | ProgramProp |
|
||||
indexers
|
||||
| A.cs:23:23:23:26 | Item |
|
||||
| Program.cs:34:23:34:26 | Item |
|
||||
accessors
|
||||
| A.cs:21:30:21:32 | get_Prop |
|
||||
| A.cs:21:35:21:37 | set_Prop |
|
||||
| A.cs:25:13:25:15 | get_Item |
|
||||
| A.cs:26:13:26:15 | set_Item |
|
||||
| A.cs:34:13:34:15 | add_Clicked |
|
||||
| A.cs:38:13:38:18 | remove_Clicked |
|
||||
| Program.cs:32:37:32:39 | get_ProgramProp |
|
||||
| Program.cs:32:42:32:44 | set_ProgramProp |
|
||||
| Program.cs:36:13:36:15 | get_Item |
|
||||
| Program.cs:37:13:37:15 | set_Item |
|
||||
| Program.cs:45:13:45:15 | add_ProgramClicked |
|
||||
| Program.cs:49:13:49:18 | remove_ProgramClicked |
|
||||
attributes
|
||||
| A.cs:49:10:49:19 | [MyObsolete(...)] |
|
||||
| Program.cs:60:10:60:16 | [Program(...)] |
|
||||
events
|
||||
| A.cs:32:35:32:41 | Clicked |
|
||||
| Program.cs:43:35:43:48 | ProgramClicked |
|
||||
eventAccessors
|
||||
| A.cs:34:13:34:15 | add_Clicked |
|
||||
| A.cs:38:13:38:18 | remove_Clicked |
|
||||
| Program.cs:45:13:45:15 | add_ProgramClicked |
|
||||
| Program.cs:49:13:49:18 | remove_ProgramClicked |
|
||||
usingDirectives
|
||||
| A.cs:1:1:1:13 | using ...; |
|
||||
| Program.cs:1:1:1:13 | using ...; |
|
||||
commentLines
|
||||
| A.cs:15:9:15:21 | // ... |
|
||||
| A.cs:29:9:29:10 | /* ... */ |
|
||||
| A.cs:30:1:30:27 | /* ... */ |
|
||||
| A.cs:31:1:31:11 | /* ... */ |
|
||||
| Program.cs:26:9:26:29 | // ... |
|
||||
| Program.cs:40:9:40:10 | /* ... */ |
|
||||
| Program.cs:41:1:41:27 | /* ... */ |
|
||||
| Program.cs:42:1:42:11 | /* ... */ |
|
||||
commentBlocks
|
||||
| A.cs:15:9:15:21 | // ... |
|
||||
| A.cs:29:9:31:11 | /* ... */ |
|
||||
| Program.cs:26:9:26:29 | // ... |
|
||||
| Program.cs:40:9:42:11 | /* ... */ |
|
||||
typeMentions
|
||||
| A.cs:9:17:9:22 | String |
|
||||
| A.cs:10:18:10:23 | String |
|
||||
| A.cs:18:13:18:19 | Console |
|
||||
| A.cs:21:16:21:21 | String |
|
||||
| A.cs:23:16:23:21 | Object |
|
||||
| A.cs:23:28:23:30 | Int32 |
|
||||
| A.cs:25:30:25:35 | Object |
|
||||
| A.cs:36:17:36:23 | Console |
|
||||
| A.cs:40:17:40:23 | Console |
|
||||
| A.cs:44:23:44:23 | A |
|
||||
| A.cs:44:36:44:36 | A |
|
||||
| A.cs:44:41:44:41 | A |
|
||||
| A.cs:49:10:49:19 | MyObsoleteAttribute |
|
||||
| A.cs:50:16:50:19 | Void |
|
||||
| A.cs:53:25:53:30 | String |
|
||||
| A.cs:55:13:55:18 | String |
|
||||
| A.cs:60:16:60:19 | Void |
|
||||
| A.cs:69:40:69:48 | Attribute |
|
||||
| Program.cs:7:23:7:26 | Void |
|
||||
| Program.cs:7:33:7:38 | String |
|
||||
| Program.cs:7:33:7:40 | String[] |
|
||||
| Program.cs:11:17:11:23 | Console |
|
||||
| Program.cs:14:13:14:15 | String |
|
||||
| Program.cs:15:13:15:15 | A |
|
||||
| Program.cs:15:25:15:25 | A |
|
||||
| Program.cs:16:13:16:19 | Console |
|
||||
| Program.cs:19:17:19:22 | String |
|
||||
| Program.cs:21:24:21:29 | String |
|
||||
| Program.cs:29:13:29:19 | Console |
|
||||
| Program.cs:32:16:32:21 | String |
|
||||
| Program.cs:34:16:34:21 | String |
|
||||
| Program.cs:34:28:34:30 | Int32 |
|
||||
| Program.cs:36:26:36:31 | String |
|
||||
| Program.cs:47:17:47:23 | Console |
|
||||
| Program.cs:51:17:51:23 | Console |
|
||||
| Program.cs:55:23:55:29 | Program |
|
||||
| Program.cs:55:42:55:48 | Program |
|
||||
| Program.cs:55:53:55:59 | Program |
|
||||
| Program.cs:60:10:60:16 | ProgramAttribute |
|
||||
| Program.cs:61:16:61:19 | Void |
|
||||
| Program.cs:64:37:64:45 | Attribute |
|
||||
1
csharp/ql/test/library-tests/overlay/overlay/test.qlref
Normal file
1
csharp/ql/test/library-tests/overlay/overlay/test.qlref
Normal file
@@ -0,0 +1 @@
|
||||
query: ../test.ql
|
||||
39
csharp/ql/test/library-tests/overlay/test.ql
Normal file
39
csharp/ql/test/library-tests/overlay/test.ql
Normal file
@@ -0,0 +1,39 @@
|
||||
import csharp
|
||||
|
||||
query predicate expressions(Expr e) { e.fromSource() }
|
||||
|
||||
query predicate statements(Stmt s) { s.fromSource() }
|
||||
|
||||
query predicate methods(Method m) { m.fromSource() }
|
||||
|
||||
query predicate types(Type t) { t.fromSource() }
|
||||
|
||||
query predicate parameters(Parameter p) { p.fromSource() }
|
||||
|
||||
query predicate operators(Operator o) { o.fromSource() }
|
||||
|
||||
query predicate constructors(Constructor c) { c.fromSource() }
|
||||
|
||||
query predicate destructors(Destructor d) { d.fromSource() }
|
||||
|
||||
query predicate fields(Field f) { f.fromSource() }
|
||||
|
||||
query predicate properties(Property p) { p.fromSource() }
|
||||
|
||||
query predicate indexers(Indexer i) { i.fromSource() }
|
||||
|
||||
query predicate accessors(Accessor a) { a.fromSource() }
|
||||
|
||||
query predicate attributes(Attribute a) { a.fromSource() }
|
||||
|
||||
query predicate events(Event ev) { ev.fromSource() }
|
||||
|
||||
query predicate eventAccessors(EventAccessor ea) { ea.fromSource() }
|
||||
|
||||
query predicate usingDirectives(UsingDirective ud) { ud.fromSource() }
|
||||
|
||||
query predicate commentLines(CommentLine cl) { cl.getLocation().getFile().fromSource() }
|
||||
|
||||
query predicate commentBlocks(CommentBlock cb) { cb.getLocation().getFile().fromSource() }
|
||||
|
||||
query predicate typeMentions(TypeMention tm) { tm.getLocation().getFile().fromSource() }
|
||||
@@ -0,0 +1,5 @@
|
||||
elementsWithMultipleSourceLocations
|
||||
typeMentionsWithMultipleSourceLocations
|
||||
commentLinesWithMultipleSourceLocations
|
||||
commentBlocksWithMultipleSourceLocations
|
||||
removedEntities
|
||||
32
csharp/ql/test/library-tests/overlay/testlocations.ql
Normal file
32
csharp/ql/test/library-tests/overlay/testlocations.ql
Normal file
@@ -0,0 +1,32 @@
|
||||
import csharp
|
||||
|
||||
// This is a consistency check that the overlay mechanism for cleaning up locations
|
||||
// works correctly.
|
||||
query predicate elementsWithMultipleSourceLocations(Element e, SourceLocation loc) {
|
||||
e.fromSource() and
|
||||
not e instanceof Namespace and
|
||||
count(SourceLocation l0 | l0 = e.getALocation()) > 1 and
|
||||
loc = e.getALocation()
|
||||
}
|
||||
|
||||
query predicate typeMentionsWithMultipleSourceLocations(TypeMention tm, SourceLocation loc) {
|
||||
tm.getLocation().getFile().fromSource() and
|
||||
count(SourceLocation l0 | l0 = tm.getLocation()) > 1 and
|
||||
loc = tm.getLocation()
|
||||
}
|
||||
|
||||
query predicate commentLinesWithMultipleSourceLocations(CommentLine cl, SourceLocation loc) {
|
||||
cl.getLocation().getFile().fromSource() and
|
||||
count(SourceLocation l0 | l0 = cl.getLocation()) > 1 and
|
||||
loc = cl.getLocation()
|
||||
}
|
||||
|
||||
query predicate commentBlocksWithMultipleSourceLocations(CommentBlock cb, SourceLocation loc) {
|
||||
cb.getLocation().getFile().fromSource() and
|
||||
count(SourceLocation l0 | l0 = cb.getLocation()) > 1 and
|
||||
loc = cb.getLocation()
|
||||
}
|
||||
|
||||
// This is a consistency check that the entities that are removed as a part of
|
||||
// the changes in the overlay are indeed removed from the database.
|
||||
query predicate removedEntities(Element e) { e.(Method).getName() = "OldMethod" }
|
||||
Reference in New Issue
Block a user