Skip to content

Commit c1c0432

Browse files
authored
Merge pull request github#11144 from michaelnebel/csharp/qualifiedname
C#: Deprecate hasQualifiedName/1 and prepare for deprecating getQualifiedName/0.
2 parents 1a9dd48 + 27efb0d commit c1c0432

File tree

198 files changed

+819
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+819
-584
lines changed

csharp/ql/examples/snippets/catch_exception.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
import csharp
1111

1212
from CatchClause catch
13-
where catch.getCaughtExceptionType().hasQualifiedName("System.IO.IOException")
13+
where catch.getCaughtExceptionType().hasQualifiedName("System.IO", "IOException")
1414
select catch

csharp/ql/examples/snippets/constructor_call.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
import csharp
1111

1212
from ObjectCreation new
13-
where new.getObjectType().hasQualifiedName("System.Exception")
13+
where new.getObjectType().hasQualifiedName("System", "Exception")
1414
select new

csharp/ql/examples/snippets/extend_class.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
import csharp
1414

1515
from RefType type
16-
where type.getABaseType+().hasQualifiedName("System.Collections.IEnumerator")
16+
where type.getABaseType+().hasQualifiedName("System.Collections", "IEnumerator")
1717
select type

csharp/ql/examples/snippets/field_read.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import csharp
1111
from Field f, FieldRead read
1212
where
1313
f.hasName("VirtualAddress") and
14-
f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE.Section") and
14+
f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE", "Section") and
1515
f = read.getTarget()
1616
select read

csharp/ql/examples/snippets/method_call.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ from MethodCall call, Method method
1212
where
1313
call.getTarget() = method and
1414
method.hasName("MethodName") and
15-
method.getDeclaringType().hasQualifiedName("Company.Class")
15+
method.getDeclaringType().hasQualifiedName("Company", "Class")
1616
select call

csharp/ql/examples/snippets/null_argument.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ where
1717
add.hasName("Add") and
1818
add.getDeclaringType()
1919
.getUnboundDeclaration()
20-
.hasQualifiedName("System.Collections.Generic.ICollection<>") and
20+
.hasQualifiedName("System.Collections.Generic", "ICollection<>") and
2121
call.getAnArgument() instanceof NullLiteral
2222
select call

csharp/ql/examples/snippets/override_method.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import csharp
1111
from Method override, Method base
1212
where
1313
base.hasName("ToString") and
14-
base.getDeclaringType().hasQualifiedName("System.Object") and
14+
base.getDeclaringType().hasQualifiedName("System", "Object") and
1515
base.getAnOverrider() = override
1616
select override

csharp/ql/examples/snippets/throw_exception.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
import csharp
1010

1111
from ThrowStmt throw
12-
where throw.getThrownExceptionType().getBaseClass*().hasQualifiedName("System.IO.IOException")
12+
where throw.getThrownExceptionType().getBaseClass*().hasQualifiedName("System.IO", "IOException")
1313
select throw

csharp/ql/lib/Linq/Helpers.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ private int numStmts(ForeachStmt fes) {
1919
}
2020

2121
/** Holds if the type's qualified name is "System.Linq.Enumerable" */
22-
predicate isEnumerableType(ValueOrRefType t) { t.hasQualifiedName("System.Linq.Enumerable") }
22+
predicate isEnumerableType(ValueOrRefType t) { t.hasQualifiedName("System.Linq", "Enumerable") }
2323

2424
/** Holds if the type's qualified name starts with "System.Collections.Generic.IEnumerable" */
2525
predicate isIEnumerableType(ValueOrRefType t) {
26-
t.getQualifiedName().matches("System.Collections.Generic.IEnumerable%")
26+
exists(string type |
27+
t.hasQualifiedName("System.Collections.Generic", type) and
28+
type.matches("IEnumerable%")
29+
)
2730
}
2831

2932
/**
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* `Element::hasQualifiedName/1` has been deprecated. Use `hasQualifiedName/2` or `hasQualifiedName/3` instead.

0 commit comments

Comments
 (0)