mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Autoformat cookbook examples.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
import csharp
|
||||
|
||||
from CastExpr c
|
||||
where c.getExpr().getType() instanceof FloatingPointType
|
||||
and c.getType() instanceof IntegralType
|
||||
where
|
||||
c.getExpr().getType() instanceof FloatingPointType and
|
||||
c.getType() instanceof IntegralType
|
||||
select c
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* try
|
||||
* exception
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from CatchClause catch
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* constructor
|
||||
* new
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from ObjectCreation new
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* test
|
||||
* boolean
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from EqualityOperation eq
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* subtype
|
||||
* supertype
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from RefType type
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* @tags field
|
||||
* read
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from Field f, FieldRead read
|
||||
where f.hasName("VirtualAddress")
|
||||
and f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE.Section")
|
||||
and f = read.getTarget()
|
||||
where
|
||||
f.hasName("VirtualAddress") and
|
||||
f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE.Section") and
|
||||
f = read.getTarget()
|
||||
select read
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags integer
|
||||
* literal
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from IntegerLiteral literal
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* @tags call
|
||||
* method
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from MethodCall call, Method method
|
||||
where call.getTarget() = method
|
||||
and method.hasName("MethodName")
|
||||
and method.getDeclaringType().hasQualifiedName("Company.Class")
|
||||
where
|
||||
call.getTarget() = method and
|
||||
method.hasName("MethodName") and
|
||||
method.getDeclaringType().hasQualifiedName("Company.Class")
|
||||
select call
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
import csharp
|
||||
|
||||
from Method m, Method n
|
||||
where m.calls(n)
|
||||
and n.calls(m)
|
||||
and m != n
|
||||
where
|
||||
m.calls(n) and
|
||||
n.calls(m) and
|
||||
m != n
|
||||
select m, n
|
||||
|
||||
|
||||
@@ -8,12 +8,16 @@
|
||||
* collection
|
||||
* add
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from MethodCall call, Method add
|
||||
where call.getTarget() = add.getAnUltimateImplementor*()
|
||||
and add.hasName("Add")
|
||||
and add.getDeclaringType().getSourceDeclaration().hasQualifiedName("System.Collections.Generic.ICollection<>")
|
||||
and call.getAnArgument() instanceof NullLiteral
|
||||
where
|
||||
call.getTarget() = add.getAnUltimateImplementor*() and
|
||||
add.hasName("Add") and
|
||||
add
|
||||
.getDeclaringType()
|
||||
.getSourceDeclaration()
|
||||
.hasQualifiedName("System.Collections.Generic.ICollection<>") and
|
||||
call.getAnArgument() instanceof NullLiteral
|
||||
select call
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* @tags method
|
||||
* override
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from Method override, Method base
|
||||
where base.hasName("ToString")
|
||||
and base.getDeclaringType().hasQualifiedName("System.Object")
|
||||
and base.getAnOverrider() = override
|
||||
where
|
||||
base.hasName("ToString") and
|
||||
base.getDeclaringType().hasQualifiedName("System.Object") and
|
||||
base.getAnOverrider() = override
|
||||
select override
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
import csharp
|
||||
|
||||
from SwitchStmt switch, Enum enum, EnumConstant missing
|
||||
where switch.getCondition().getType() = enum
|
||||
and missing.getDeclaringType() = enum
|
||||
and not switch.getAConstCase().getExpr() = missing.getAnAccess()
|
||||
and not exists(switch.getDefaultCase())
|
||||
where
|
||||
switch.getCondition().getType() = enum and
|
||||
missing.getDeclaringType() = enum and
|
||||
not switch.getAConstCase().getExpr() = missing.getAnAccess() and
|
||||
not exists(switch.getDefaultCase())
|
||||
select switch
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
import csharp
|
||||
|
||||
from ConditionalExpr e
|
||||
where e.getThen().stripImplicitCasts() != e.getElse().stripImplicitCasts()
|
||||
and not e.getThen().getType() instanceof NullType
|
||||
and not e.getElse().getType() instanceof NullType
|
||||
where
|
||||
e.getThen().stripImplicitCasts() != e.getElse().stripImplicitCasts() and
|
||||
not e.getThen().getType() instanceof NullType and
|
||||
not e.getElse().getType() instanceof NullType
|
||||
select e
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags throw
|
||||
* exception
|
||||
*/
|
||||
|
||||
|
||||
import csharp
|
||||
|
||||
from ThrowStmt throw
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import csharp
|
||||
|
||||
from TryStmt t
|
||||
where exists(t.getFinally())
|
||||
and not exists(t.getACatchClause())
|
||||
where
|
||||
exists(t.getFinally()) and
|
||||
not exists(t.getACatchClause())
|
||||
select t
|
||||
|
||||
Reference in New Issue
Block a user