Skip to content

Commit fc689ef

Browse files
committed
C#: Add debug version of the getFullyQualifiedName predicate.
1 parent 8fbfafc commit fc689ef

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

csharp/ql/lib/semmle/code/csharp/Element.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,33 @@ class NamedElement extends Element, @named_element {
124124
)
125125
}
126126

127+
/**
128+
* INTERNAL: Do not use.
129+
*
130+
* This is intended for DEBUG ONLY.
131+
* Constructing the fully qualified name for all elements in a large codebase
132+
* puts severe stress on the string pool.
133+
*
134+
* Gets the fully qualified name of this element, for example the
135+
* fully qualified name of `M` on line 3 is `N.C.M` in
136+
*
137+
* ```csharp
138+
* namespace N {
139+
* class C {
140+
* void M(int i, string s) { }
141+
* }
142+
* }
143+
* ```
144+
*
145+
* Unbound generic types, such as `IList<T>`, are represented as
146+
* ``System.Collections.Generic.IList`1``.
147+
*/
148+
final string getFullyQualifiedNameDebug() {
149+
exists(string qualifier, string name | this.hasFullyQualifiedName(qualifier, name) |
150+
if qualifier = "" then result = name else result = qualifier + "." + name
151+
)
152+
}
153+
127154
/** Holds if this element has the fully qualified name `qualifier`.`name`. */
128155
cached
129156
predicate hasFullyQualifiedName(string qualifier, string name) {

0 commit comments

Comments
 (0)