Skip to content

Commit 18d6138

Browse files
committed
C#: Address review comment.
1 parent e990bea commit 18d6138

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

csharp/ql/src/semmle/code/csharp/AnnotatedType.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class AnnotatedArrayType extends AnnotatedType {
378378
private string getDimensionString(AnnotatedType elementType) {
379379
exists(AnnotatedType et, string res |
380380
et = getElementType() and
381-
res = "[" + type.getRankString(0) + "]" and
381+
res = type.getArraySuffix() and
382382
if et.getUnderlyingType() instanceof ArrayType and not et.isNullableRefType()
383383
then result = res + et.(AnnotatedArrayType).getDimensionString(elementType)
384384
else (

csharp/ql/src/semmle/code/csharp/Type.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,21 @@ class ArrayType extends DotNet::ArrayType, RefType, @array_type {
827827
getRank() = that.getRank()
828828
}
829829

830-
string getRankString(int i) {
830+
private string getRankString(int i) {
831831
i in [0 .. getRank() - 1] and
832832
if i = getRank() - 1 then result = "" else result = "," + getRankString(i + 1)
833833
}
834834

835+
/**
836+
* INTERNAL: Do not use.
837+
* Gets a string representing the array suffix, for example `[,,,]`.
838+
*/
839+
string getArraySuffix() { result = "[" + getRankString(0) + "]" }
840+
835841
private string getDimensionString(Type elementType) {
836842
exists(Type et, string res |
837843
et = this.getElementType() and
838-
res = "[" + getRankString(0) + "]" and
844+
res = getArraySuffix() and
839845
if et instanceof ArrayType
840846
then result = res + et.(ArrayType).getDimensionString(elementType)
841847
else (

0 commit comments

Comments
 (0)