C#: Add test for file scoped namespace.

This commit is contained in:
Michael Nebel
2022-01-07 11:52:17 +01:00
parent a6d847b532
commit b8f6d17bc1
3 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
namespace MyFileScopedNamespace;
public class MyFileScopedNamespaceClass
{
private readonly object myField = new object();
public object MyProp { get; set; }
public void MyMethod() { }
}

View File

@@ -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 |

View 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%")
)
}