This project is read-only.
1
Vote

BuildComponent: Provide standard IDisposable implementation

description

Providing the standard disposable pattern implementation will enable custom build components that
create and maintain objects that must be disposed to properly clean up.
 
Disposable Pattern: http://msdn.microsoft.com/en-us/library/system.idisposable.aspx

comments

davedev wrote Jun 3, 2008 at 3:20 AM

This is already in place.

BuildComponent implements IDisposable and the BuildAssembler class's Dispose method disposes of every component in the stack. BuildAssembler.exe disposes of its BuildAssembler instance before the process ends.

If you're looking for the component disposable pattern you can implement the finalizer in your own component and call GC.SupressFinalize from your component's Dispose method.

SelormeyPaul wrote Jun 3, 2008 at 5:40 AM

Dave: BuildComponent implements IDisposable and the BuildAssembler class's Dispose method
I know, as I have mentioned it is the standard disposable pattern, which makes you aware what initiated
the dispose process.
Dave: BuildAssembler.exe disposes of its BuildAssembler instance before the process ends.
How did you know that? I used Reflector, since that is the only way you can have some assurance in this case,
and I believed you also used the Reflector for similar reason.
Dave: call GC.SupressFinalize from your component's Dispose method.
Which is useless, if all that is needed is to follow the pattern defined by MS itself.
If you run their implementation through Code Analysis or FxCop, you will get CA1063 warning.

davedev wrote Jun 3, 2008 at 1:25 PM

Well it couldn't hurt to have Dispose(bool). I'm just saying that if you need to dispose of unmanaged resources now you can use the BuildComponent.Dispose method and the process will end shortly after, so I don't see what the problem is.

You don't have to dispose of managed resources because: A. the process ends immediately after BuildAssembler disposes of the components and B. if disposable objects with unmanaged resources have implemented finalizers, as they should, their unmanaged resources will be disposed automatically at shutdown. You can do the same in your build component.

The only reason for the standard pattern's Dispose(bool) method is to be able to forcefully dispose of managed resources that may contain unmanaged resources while the process remains alive - by calling Dispose() from your own code - but since you'll never be calling it on a build component it really doesn't matter.

wrote Feb 22, 2013 at 1:40 AM