Skip to content

Commit 3476437

Browse files
committed
C#: Add test case with recursive generics
1 parent 7568868 commit 3476437

File tree

7 files changed

+49
-0
lines changed

7 files changed

+49
-0
lines changed

csharp/ql/integration-tests/all-platforms/diag_recursive_generics/ExtractortMessages.expected

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import csharp
2+
import semmle.code.csharp.commons.Diagnostics
3+
4+
query predicate extractorMessages(ExtractorMessage msg, int severity, string elementText) {
5+
msg.getSeverity() = severity and msg.getElementText() = elementText
6+
}

csharp/ql/integration-tests/all-platforms/diag_recursive_generics/Types.expected

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import csharp
2+
3+
from Class c
4+
where c.fromSource()
5+
select c, c.getBaseClass().getQualifiedName()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class GenA<U> { };
2+
public class GenB<T> : GenA<GenB<GenB<T>>> { };
3+
4+
class P<T> { }
5+
class C<U, V> : P<D<V, U>> { }
6+
class D<W, X> : P<C<W, X>> { }
7+
8+
class A<T> : System.IEquatable<A<T>>
9+
{
10+
public bool Equals(A<T> other) { return true; }
11+
}
12+
13+
public class Class
14+
{
15+
public static int Main()
16+
{
17+
GenB<string> a = new GenB<string>();
18+
P<D<string, int>> b = new C<int, string>();
19+
A<string> c = new A<string>();
20+
21+
return 0;
22+
}
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net7.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
9+
<RemoveDir Directories=".\bin" />
10+
<RemoveDir Directories=".\obj" />
11+
</Target>
12+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from create_database_utils import *
2+
3+
run_codeql_database_create(['dotnet build'], lang="csharp", extra_args=["--extractor-option=cil=false"])

0 commit comments

Comments
 (0)