-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathMissingDisposeCall.ql
More file actions
32 lines (30 loc) · 983 Bytes
/
MissingDisposeCall.ql
File metadata and controls
32 lines (30 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* @name Missing Dispose call
* @description Classes that implement 'IDisposable' and have members of 'IDisposable' type
* should dispose those members in their 'Dispose()' method.
* @kind problem
* @problem.severity warning
* @precision low
* @id cs/member-not-disposed
* @tags efficiency
* maintainability
* external/cwe/cwe-404
* external/cwe/cwe-459
*/
import csharp
import Dispose
import semmle.code.csharp.frameworks.System
from DisposableType t, DisposableField f, Method dispose
where
f.getDeclaringType() = t and
not f.isStatic() and
t.isSourceDeclaration() and
dispose = getInvokedDisposeMethod(t) and
dispose.getDeclaringType() = t and
not exists(MethodCall mc |
mc.getTarget() instanceof DisposeMethod and
mc.getQualifier() = f.getAnAccess() and
mc.getEnclosingCallable() = dispose
)
select dispose, "This 'Dispose()' method does not call 'Dispose()' on `IDisposable` field $@.", f,
f.getName()