mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
C#: Add testcase for CIL generic attribute extraction.
This commit is contained in:
16
csharp/ql/test/library-tests/csharp11/cil/Assembly.cs_
Normal file
16
csharp/ql/test/library-tests/csharp11/cil/Assembly.cs_
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Assembly
|
||||
{
|
||||
public class MyAssemblyGeneric1Attribute<T> : Attribute { }
|
||||
public class MyAssemblyGeneric2Attribute<T, U> : Attribute { }
|
||||
|
||||
public class TestAssemblyGenericAttribute
|
||||
{
|
||||
[MyAssemblyGeneric1Attribute<object>()]
|
||||
public void M1() { }
|
||||
|
||||
[MyAssemblyGeneric2<int, string>()]
|
||||
public void M2() { }
|
||||
}
|
||||
}
|
||||
BIN
csharp/ql/test/library-tests/csharp11/cil/assembly.dll
Normal file
BIN
csharp/ql/test/library-tests/csharp11/cil/assembly.dll
Normal file
Binary file not shown.
7
csharp/ql/test/library-tests/csharp11/cil/class1.cs
Normal file
7
csharp/ql/test/library-tests/csharp11/cil/class1.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
using Assembly;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public static void Main(string[] args) { }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
| assembly.dll:0:0:0:0 | [MyAssemblyGeneric1Attribute<Object>(...)] | MyAssemblyGeneric1Attribute<Object> | 1 | (Object) |
|
||||
| assembly.dll:0:0:0:0 | [MyAssemblyGeneric2Attribute<Int32,String>(...)] | MyAssemblyGeneric2Attribute<Int32,String> | 2 | (Int32,String) |
|
||||
@@ -0,0 +1,9 @@
|
||||
import semmle.code.cil.CIL
|
||||
|
||||
private string getTypeArguments(GenericAttribute a) {
|
||||
result = "(" + concat(Type t | t = a.getATypeArgument() | t.getName(), ",") + ")"
|
||||
}
|
||||
|
||||
from GenericAttribute a
|
||||
where a.getFile().getStem() = "assembly"
|
||||
select a, a.getType().getName(), a.getNumberOfTypeArguments(), getTypeArguments(a)
|
||||
1
csharp/ql/test/library-tests/csharp11/cil/options
Normal file
1
csharp/ql/test/library-tests/csharp11/cil/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --cil
|
||||
Reference in New Issue
Block a user