For some reason FXCop seems to think I should be calling GC.SuppressFinalize in Dispose, regardless of whether I have a finalizer or not.
Am I missing something? Is there a reason to call GC.SuppressFinalize on objects that have no finalizer defined?
There is always a finalizer in IL – System.Object.Finalize() exists in every class, so if you make a custom class, it has a finalizer you want to suppress. That being said, not all objects are put on the finalization queue, so you only techncially should need to suppress finalization if you implement your own finalizer.
If you’re implementing
IDisposableto wrap unmanaged resources, you should include a finalizer, and you should prevent this from running, since in theory you’re doing the cleanup already whenDisposeis called.