Skip to content

Commit bcdbd6e

Browse files
committed
C#: Use the fully qualified name for the extension type when printing extension types.
1 parent fe94b3b commit bcdbd6e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

csharp/ql/lib/semmle/code/csharp/commons/QualifiedName.qll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ module QualifiedName<QualifiedNameInputSig Input> {
6767
)
6868
}
6969

70+
private string getName(ValueOrRefType t) {
71+
not t instanceof ExtensionType and result = t.getUndecoratedName()
72+
or
73+
result = "extension(" + getFullName(t.(ExtensionType).getExtendedType()) + ")"
74+
}
75+
7076
/** Holds if declaration `d` has the qualified name `qualifier`.`name`. */
7177
predicate hasQualifiedName(Declaration d, string qualifier, string name) {
7278
d =
@@ -86,12 +92,12 @@ module QualifiedName<QualifiedNameInputSig Input> {
8692
exists(string name0 | name = name0 + Input::getUnboundGenericSuffix(ugt) |
8793
exists(string enclosing |
8894
hasQualifiedName(ugt.getDeclaringType(), qualifier, enclosing) and
89-
name0 = enclosing + "+" + ugt.getUndecoratedName()
95+
name0 = enclosing + "+" + getName(ugt)
9096
)
9197
or
9298
not exists(ugt.getDeclaringType()) and
9399
qualifier = ugt.getNamespace().getFullName() and
94-
name0 = ugt.getUndecoratedName()
100+
name0 = getName(ugt)
95101
)
96102
)
97103
or
@@ -100,12 +106,12 @@ module QualifiedName<QualifiedNameInputSig Input> {
100106
exists(string name0 | name = name0 + "<" + getTypeArgumentsQualifiedNames(ct) + ">" |
101107
exists(string enclosing |
102108
hasQualifiedName(ct.getDeclaringType(), qualifier, enclosing) and
103-
name0 = enclosing + "+" + ct.getUndecoratedName()
109+
name0 = enclosing + "+" + getName(ct)
104110
)
105111
or
106112
not exists(ct.getDeclaringType()) and
107113
qualifier = ct.getNamespace().getFullName() and
108-
name0 = ct.getUndecoratedName()
114+
name0 = getName(ct)
109115
)
110116
)
111117
or
@@ -116,12 +122,12 @@ module QualifiedName<QualifiedNameInputSig Input> {
116122
(
117123
exists(string enclosing |
118124
hasQualifiedName(vort.getDeclaringType(), qualifier, enclosing) and
119-
name = enclosing + "+" + vort.getUndecoratedName()
125+
name = enclosing + "+" + getName(vort)
120126
)
121127
or
122128
not exists(vort.getDeclaringType()) and
123129
qualifier = vort.getNamespace().getFullName() and
124-
name = vort.getUndecoratedName()
130+
name = getName(vort)
125131
)
126132
)
127133
or

csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ module ModelValidation {
214214
not namespace.regexpMatch("[a-zA-Z0-9_\\.]+") and
215215
result = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
216216
or
217-
not type.regexpMatch("[a-zA-Z0-9_<>,\\(\\)\\+]+") and
217+
not type.regexpMatch("[a-zA-Z0-9_<>,\\(\\)\\+\\.]+") and
218218
result = "Dubious type \"" + type + "\" in " + pred + " model."
219219
or
220220
not name.regexpMatch("[a-zA-Z0-9_<>,\\.]*") and

0 commit comments

Comments
 (0)