mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
C#: Add test for file scoped namespace.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace MyFileScopedNamespace;
|
||||
public class MyFileScopedNamespaceClass
|
||||
{
|
||||
private readonly object myField = new object();
|
||||
public object MyProp { get; set; }
|
||||
public void MyMethod() { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:2:14:2:39 | MyFileScopedNamespaceClass |
|
||||
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:4:29:4:35 | myField |
|
||||
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:5:19:5:24 | MyProp |
|
||||
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:6:17:6:24 | MyMethod |
|
||||
10
csharp/ql/test/library-tests/csharp10/fileScopedNamespace.ql
Normal file
10
csharp/ql/test/library-tests/csharp10/fileScopedNamespace.ql
Normal file
@@ -0,0 +1,10 @@
|
||||
import csharp
|
||||
|
||||
query predicate fileScopedNamespace(Namespace n, Member m) {
|
||||
n.hasQualifiedName("MyFileScopedNamespace") and
|
||||
exists(Class c |
|
||||
c.getNamespace() = n and
|
||||
c.hasMember(m) and
|
||||
m.getLocation().toString().matches("%FileScopedNamespace.cs%")
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user