Skip to content

Commit 990dec6

Browse files
committed
C#: Address more review comments.
1 parent 43ee62a commit 990dec6

File tree

7 files changed

+33
-62
lines changed

7 files changed

+33
-62
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ private import TypeRef
2222
*/
2323
class Callable extends Parameterizable, ExprOrStmtParent, @callable {
2424
pragma[noinline]
25-
private string getDeclaringTypeLabel() { result = this.getDeclaringType().getLabel() }
25+
deprecated private string getDeclaringTypeLabel() { result = this.getDeclaringType().getLabel() }
2626

2727
pragma[noinline]
28-
private string getParameterTypeLabelNonGeneric(int p) {
28+
deprecated private string getParameterTypeLabelNonGeneric(int p) {
2929
not this instanceof Generic and
3030
result = this.getParameter(p).getType().getLabel()
3131
}
3232

3333
language[monotonicAggregates]
3434
pragma[nomagic]
35-
private string getMethodParamListNonGeneric() {
35+
deprecated private string getMethodParamListNonGeneric() {
3636
result =
3737
concat(int p |
3838
p in [0 .. this.getNumberOfParameters() - 1]
@@ -42,14 +42,14 @@ class Callable extends Parameterizable, ExprOrStmtParent, @callable {
4242
}
4343

4444
pragma[noinline]
45-
private string getParameterTypeLabelGeneric(int p) {
45+
deprecated private string getParameterTypeLabelGeneric(int p) {
4646
this instanceof Generic and
4747
result = this.getParameter(p).getType().getLabel()
4848
}
4949

5050
language[monotonicAggregates]
5151
pragma[nomagic]
52-
private string getMethodParamListGeneric() {
52+
deprecated private string getMethodParamListGeneric() {
5353
result =
5454
concat(int p |
5555
p in [0 .. this.getNumberOfParameters() - 1]
@@ -59,27 +59,27 @@ class Callable extends Parameterizable, ExprOrStmtParent, @callable {
5959
}
6060

6161
pragma[noinline]
62-
private string getLabelNonGeneric() {
62+
deprecated private string getLabelNonGeneric() {
6363
not this instanceof Generic and
6464
result =
6565
this.getReturnTypeLabel() + " " + this.getDeclaringTypeLabel() + "." +
6666
this.getUndecoratedName() + "(" + this.getMethodParamListNonGeneric() + ")"
6767
}
6868

6969
pragma[noinline]
70-
private string getLabelGeneric() {
70+
deprecated private string getLabelGeneric() {
7171
result =
7272
this.getReturnTypeLabel() + " " + this.getDeclaringTypeLabel() + "." +
7373
this.getUndecoratedName() + getGenericsLabel(this) + "(" + this.getMethodParamListGeneric() +
7474
")"
7575
}
7676

77-
final override string getLabel() {
77+
deprecated final override string getLabel() {
7878
result = this.getLabelNonGeneric() or
7979
result = this.getLabelGeneric()
8080
}
8181

82-
private string getReturnTypeLabel() {
82+
deprecated private string getReturnTypeLabel() {
8383
result = this.getReturnType().getLabel()
8484
or
8585
not exists(this.getReturnType()) and result = "System.Void"
@@ -579,8 +579,8 @@ class RecordCloneMethod extends Method {
579579
this.hasName("<Clone>$") and
580580
this.getNumberOfParameters() = 0 and
581581
this.getReturnType() = getARecordBaseType(this.getDeclaringType()) and
582-
this.(Member).isPublic() and
583-
not this.(Member).isStatic()
582+
this.isPublic() and
583+
not this.isStatic()
584584
}
585585

586586
/** Gets the constructor that this clone method calls. */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Element extends @element {
3131
* Gets the "language" of this program element, as defined by the extension of the filename.
3232
* For example, C# has language "cs", and Visual Basic has language "vb".
3333
*/
34-
final string getLanguage() { result = this.getLocation().getFile().getExtension() }
34+
deprecated final string getLanguage() { result = this.getLocation().getFile().getExtension() }
3535

3636
/**
3737
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
@@ -160,10 +160,10 @@ class NamedElement extends Element, @named_element {
160160

161161
/** Gets a unique string label for this element. */
162162
cached
163-
string getLabel() { none() }
163+
deprecated string getLabel() { none() }
164164

165165
/** Holds if `other` has the same metadata handle in the same assembly. */
166-
predicate matchesHandle(NamedElement other) {
166+
deprecated predicate matchesHandle(NamedElement other) {
167167
exists(Assembly asm, int handle |
168168
metadata_handle(this, asm, handle) and
169169
metadata_handle(other, asm, handle)
@@ -174,7 +174,7 @@ class NamedElement extends Element, @named_element {
174174
* Holds if this element was compiled from source code that is also present in the
175175
* database. That is, this element corresponds to another element from source.
176176
*/
177-
predicate compiledFromSource() {
177+
deprecated predicate compiledFromSource() {
178178
not this.fromSource() and
179179
exists(NamedElement other | other != this |
180180
this.matchesHandle(other) and

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,20 @@ class ConstructedGeneric extends Generic {
108108
*
109109
* Constructs the label suffix for a generic method or type.
110110
*/
111-
string getGenericsLabel(Generic g) {
111+
deprecated string getGenericsLabel(Generic g) {
112112
result = "`" + g.(UnboundGeneric).getNumberOfTypeParameters()
113113
or
114114
result = "<" + typeArgs(g) + ">"
115115
}
116116

117117
pragma[noinline]
118-
private string getTypeArgumentLabel(ConstructedGeneric generic, int p) {
118+
deprecated private string getTypeArgumentLabel(ConstructedGeneric generic, int p) {
119119
result = generic.getTypeArgument(p).getLabel()
120120
}
121121

122122
language[monotonicAggregates]
123123
pragma[nomagic]
124-
private string typeArgs(ConstructedGeneric generic) {
124+
deprecated private string typeArgs(ConstructedGeneric generic) {
125125
result =
126126
concat(int p |
127127
p in [0 .. generic.getNumberOfTypeArguments() - 1]
@@ -264,7 +264,7 @@ class TypeParameter extends Type, @type_parameter {
264264
/** Gets the index of this type parameter. For example the index of `U` in `Func<T,U>` is 1. */
265265
override int getIndex() { type_parameters(this, result, _, _) }
266266

267-
final override string getLabel() { result = "!" + this.getIndex() }
267+
deprecated final override string getLabel() { result = "!" + this.getIndex() }
268268

269269
override string getUndecoratedName() { result = "!" + this.getIndex() }
270270

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -263,33 +263,6 @@ class Member extends Modifiable, @member {
263263
/** Gets an access to this member. */
264264
MemberAccess getAnAccess() { result.getTarget() = this }
265265

266-
/** Holds if this member is declared `public`. */
267-
override predicate isPublic() { Modifiable.super.isPublic() }
268-
269-
/** Holds if this member is declared `protected.` */
270-
override predicate isProtected() { Modifiable.super.isProtected() }
271-
272-
/** Holds if this member is `private`. */
273-
override predicate isPrivate() { Modifiable.super.isPrivate() }
274-
275-
/** Holds if this member is `internal`. */
276-
override predicate isInternal() { Modifiable.super.isInternal() }
277-
278-
/** Holds if this member is `sealed`. */
279-
override predicate isSealed() { Modifiable.super.isSealed() }
280-
281-
/** Holds if this member is `abstract`. */
282-
override predicate isAbstract() { Modifiable.super.isAbstract() }
283-
284-
/** Holds if this member is `static`. */
285-
override predicate isStatic() { Modifiable.super.isStatic() }
286-
287-
/** Holds if this member is declared `required`. */
288-
override predicate isRequired() { Modifiable.super.isRequired() }
289-
290-
/** Holds if this member is declared `file` local. */
291-
override predicate isFile() { Modifiable.super.isFile() }
292-
293266
/**
294267
* DEPRECATED: Use `hasFullyQualifiedName` instead.
295268
*

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ValueOrRefType extends Type, Attributable, @value_or_ref_type {
7676
/** Gets a nested child type, if any. */
7777
NestedType getAChildType() { nested_types(result, this, _) }
7878

79-
private string getPrefixWithTypes() {
79+
deprecated private string getPrefixWithTypes() {
8080
result = this.getDeclaringType().getLabel() + "."
8181
or
8282
if this.getDeclaringNamespace().isGlobalNamespace()
@@ -85,17 +85,17 @@ class ValueOrRefType extends Type, Attributable, @value_or_ref_type {
8585
}
8686

8787
pragma[noinline]
88-
private string getLabelNonGeneric() {
88+
deprecated private string getLabelNonGeneric() {
8989
not this instanceof Generic and
9090
result = this.getPrefixWithTypes() + this.getUndecoratedName()
9191
}
9292

9393
pragma[noinline]
94-
private string getLabelGeneric() {
94+
deprecated private string getLabelGeneric() {
9595
result = this.getPrefixWithTypes() + this.getUndecoratedName() + getGenericsLabel(this)
9696
}
9797

98-
override string getLabel() {
98+
deprecated override string getLabel() {
9999
result = this.getLabelNonGeneric() or
100100
result = this.getLabelGeneric()
101101
}
@@ -997,7 +997,7 @@ class FunctionPointerType extends Type, Parameterizable, @function_pointer_type
997997

998998
override string getAPrimaryQlClass() { result = "FunctionPointerType" }
999999

1000-
override string getLabel() { result = this.getName() }
1000+
deprecated override string getLabel() { result = this.getName() }
10011001
}
10021002

10031003
/**
@@ -1116,7 +1116,7 @@ class ArrayType extends RefType, @array_type {
11161116
array_element_type(this, _, _, getTypeRef(result))
11171117
}
11181118

1119-
final override string getLabel() { result = this.getElementType().getLabel() + "[]" }
1119+
deprecated final override string getLabel() { result = this.getElementType().getLabel() + "[]" }
11201120

11211121
/** Holds if this array type has the same shape (dimension and rank) as `that` array type. */
11221122
predicate hasSameShapeAs(ArrayType that) {
@@ -1180,7 +1180,7 @@ class PointerType extends Type, @pointer_type {
11801180

11811181
final override string getName() { types(this, _, result) }
11821182

1183-
final override string getLabel() { result = this.getReferentType().getLabel() + "*" }
1183+
deprecated final override string getLabel() { result = this.getReferentType().getLabel() + "*" }
11841184

11851185
final override string getUndecoratedName() {
11861186
result = this.getReferentType().getUndecoratedName()
@@ -1271,7 +1271,7 @@ class TupleType extends ValueType, @tuple_type {
12711271
")"
12721272
}
12731273

1274-
override string getLabel() { result = this.getUnderlyingType().getLabel() }
1274+
deprecated override string getLabel() { result = this.getUnderlyingType().getLabel() }
12751275

12761276
override Type getChild(int i) { result = this.getUnderlyingType().getChild(i) }
12771277

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ private import semmle.code.csharp.frameworks.system.collections.Generic
1414
* a flow summary.
1515
*/
1616
Callable getCallableForDataFlow(Callable c) {
17-
exists(Callable unboundDecl | unboundDecl = c.getUnboundDeclaration() |
18-
unboundDecl.hasBody() and
19-
unboundDecl.getFile().fromSource() and
20-
result = unboundDecl
21-
)
17+
result = c.getUnboundDeclaration() and
18+
result.hasBody() and
19+
result.getFile().fromSource()
2220
}
2321

2422
newtype TReturnKind =
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import csharp
22

3-
from NamedElement ne
4-
where ne.fromSource()
5-
select ne, ne.getLabel()
3+
deprecated query predicate labels(NamedElement ne, string label) {
4+
ne.getLabel() = label and ne.fromSource()
5+
}

0 commit comments

Comments
 (0)