In Visual Studio, when I type the line "Implements IDisposable
", the IDE automatically adds:
- a
disposedValue
member variable - a
Sub Dispose() Implements IDisposable.Dispose
- a
Sub Dispose(ByVal disposing As Boolean)
The Dispose()
should be left alone, and the clean up code should be put in Dispose(disposing)
.
However the Dispose Finalize Pattern says you should also override Sub Finalize()
to call Dispose(False)
. Why doesn't the IDE also add this? Must I add it myself, or is it somehow called implicitly?
EDIT: Any idea why the IDE automatically adds 80% of the required stuff but leaves out the Finalize method? Isn't the whole point of this kind of feature to help you not forget these things?
EDIT2: Thank you all for your excellent answers, this now makes perfect sense!