Skip to content

Commit 25019eb

Browse files
committed
C#: Add testcase for CIL generic attribute extraction.
1 parent e57f381 commit 25019eb

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace Assembly
4+
{
5+
public class MyAssemblyGeneric1Attribute<T> : Attribute { }
6+
public class MyAssemblyGeneric2Attribute<T, U> : Attribute { }
7+
8+
public class TestAssemblyGenericAttribute
9+
{
10+
[MyAssemblyGeneric1Attribute<object>()]
11+
public void M1() { }
12+
13+
[MyAssemblyGeneric2<int, string>()]
14+
public void M2() { }
15+
}
16+
}
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System;
2+
using Assembly;
3+
4+
public class Class1
5+
{
6+
public static void Main(string[] args) { }
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| assembly.dll:0:0:0:0 | [MyAssemblyGeneric1Attribute<Object>(...)] | MyAssemblyGeneric1Attribute<Object> | 1 | (Object) |
2+
| assembly.dll:0:0:0:0 | [MyAssemblyGeneric2Attribute<Int32,String>(...)] | MyAssemblyGeneric2Attribute<Int32,String> | 2 | (Int32,String) |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import semmle.code.cil.CIL
2+
3+
private string getTypeArguments(GenericAttribute a) {
4+
result = "(" + concat(Type t | t = a.getATypeArgument() | t.getName(), ",") + ")"
5+
}
6+
7+
from GenericAttribute a
8+
where a.getFile().getStem() = "assembly"
9+
select a, a.getType().getName(), a.getNumberOfTypeArguments(), getTypeArguments(a)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: --cil

0 commit comments

Comments
 (0)