What is the accepted pattern for CmdLets and disposable fields?
The FxCop rule is: Types that own disposable fields should be disposable
But unless PowerShell calls the dispose method…. it wont really help to implement the pattern.
so far I go with Begin/EndProcessing methods to set up and clear out the fields.
I could sadly not find any documentation on whether PowerShell properly calls the Dispose method.
When implementing a Cmdlet (or PSCmdlet) derived command, implement IDisposable and PowerShell will dispose your command for you when the pipeline completes. It’s as simple as that. Are you seeing behaviour that contradicts this?
Update, a la LetMeGoogleThatForYou:
From: http://msdn.microsoft.com/en-us/library/windows/desktop/ms714463(v=vs.85).aspx