C#: Add test case with recursive generics

This commit is contained in:
Tamas Vajk
2023-08-31 13:12:43 +02:00
parent 756886808d
commit 3476437bfe
7 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import csharp
import semmle.code.csharp.commons.Diagnostics
query predicate extractorMessages(ExtractorMessage msg, int severity, string elementText) {
msg.getSeverity() = severity and msg.getElementText() = elementText
}

View File

@@ -0,0 +1,5 @@
import csharp
from Class c
where c.fromSource()
select c, c.getBaseClass().getQualifiedName()

View File

@@ -0,0 +1,23 @@
public class GenA<U> { };
public class GenB<T> : GenA<GenB<GenB<T>>> { };
class P<T> { }
class C<U, V> : P<D<V, U>> { }
class D<W, X> : P<C<W, X>> { }
class A<T> : System.IEquatable<A<T>>
{
public bool Equals(A<T> other) { return true; }
}
public class Class
{
public static int Main()
{
GenB<string> a = new GenB<string>();
P<D<string, int>> b = new C<int, string>();
A<string> c = new A<string>();
return 0;
}
}

View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
<RemoveDir Directories=".\bin" />
<RemoveDir Directories=".\obj" />
</Target>
</Project>

View File

@@ -0,0 +1,3 @@
from create_database_utils import *
run_codeql_database_create(['dotnet build'], lang="csharp", extra_args=["--extractor-option=cil=false"])