-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathMissingDisposeCall.qhelp
31 lines (26 loc) · 1.02 KB
/
MissingDisposeCall.qhelp
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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Classes that implement <code>IDisposable</code> and have members of <code>IDisposable</code> type should
dispose those members in their <code>Dispose()</code> method.</p>
</overview>
<recommendation>
<p>Add a call to <code>m.Dispose()</code> in your <code>Dispose</code> method for each member <code>m</code> that implements <code>IDisposable</code>.</p>
</recommendation>
<example>
<p>In this example, the class <code>Bad</code> contains two disposable fields <code>stream1</code> and
<code>stream2</code>, but only <code>stream1</code> is disposed in <code>Bad</code>'s <code>Dispose()</code>
method.
</p>
<sample src="MissingDisposeCallBad.cs" />
<p>
In the revised example, both <code>stream1</code> and <code>stream2</code> are disposed.
</p>
<sample src="MissingDisposeCallGood.cs" />
</example>
<references>
<li>MSDN: <a href="https://msdn.microsoft.com/en-us/library/system.idisposable.aspx">IDisposable Interface</a>.</li>
</references>
</qhelp>