Skip to content

Commit b8f6d17

Browse files
committed
C#: Add test for file scoped namespace.
1 parent a6d847b commit b8f6d17

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace MyFileScopedNamespace;
2+
public class MyFileScopedNamespaceClass
3+
{
4+
private readonly object myField = new object();
5+
public object MyProp { get; set; }
6+
public void MyMethod() { }
7+
8+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:2:14:2:39 | MyFileScopedNamespaceClass |
2+
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:4:29:4:35 | myField |
3+
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:5:19:5:24 | MyProp |
4+
| FileScopedNamespace.cs:1:11:1:31 | MyFileScopedNamespace | FileScopedNamespace.cs:6:17:6:24 | MyMethod |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import csharp
2+
3+
query predicate fileScopedNamespace(Namespace n, Member m) {
4+
n.hasQualifiedName("MyFileScopedNamespace") and
5+
exists(Class c |
6+
c.getNamespace() = n and
7+
c.hasMember(m) and
8+
m.getLocation().toString().matches("%FileScopedNamespace.cs%")
9+
)
10+
}

0 commit comments

Comments
 (0)