Skip to content

Commit 8b231c5

Browse files
committed
C#: Improve printing of constructed generic CIL types.
1 parent b680795 commit 8b231c5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

csharp/ql/lib/semmle/code/cil/Generics.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class ConstructedGeneric extends Generic, DotNet::ConstructedGeneric {
2828
final override Type getTypeArgument(int n) { cil_type_argument(this, n, result) }
2929
}
3030

31+
/** Gets the concatenation of the `getName()` of type arguments. */
32+
language[monotonicAggregates]
33+
private string getTypeArgumentsNames(ConstructedGeneric cg) {
34+
result = strictconcat(Type t, int i | t = cg.getTypeArgument(i) | t.getName(), "," order by i)
35+
}
36+
3137
/** An unbound generic type. */
3238
class UnboundGenericType extends UnboundGeneric, Type { }
3339

@@ -41,6 +47,10 @@ class ConstructedType extends ConstructedGeneric, Type {
4147
override predicate isInterface() { this.getUnboundType().isInterface() }
4248

4349
override predicate isClass() { this.getUnboundType().isClass() }
50+
51+
final override string getName() {
52+
result = this.getUndecoratedName() + "<" + getTypeArgumentsNames(this) + ">"
53+
}
4454
}
4555

4656
/** A constructed generic method. */

0 commit comments

Comments
 (0)