Problem with Dispose() and C++/CLI

Nov 4, 2008 at 12:38 AM
I have an assembly built using C++/CLI (.NET binding for a native code library).  Many components of our library take up considerable system resources, so we generally implement IDisposable, so users can explicitly free resources if they need to.  All features of the library are exposed via interfaces, so the regular pattern is something like:

public interface class IMyInterface : public IDisposable
  /// some methods

ref class MyImplementation : public IMyInterface
  /// implements IDisposable

  /// some methods

Now the problem is that I would like to document IMyInterface::Dispose, since it's pretty important to point out to users that they should call it to free up resources.  The problem is that I can't add a Dispose method, since it's a reserved symbol in C++/CLI, and I can't add a destructor (the regular way to document Dispose() in sandcastle), since you can't have a destructor in an interface class.  I am stuck.  Is there any way to force documentation for a method I know is available?  Can I somehow get around this?

Nov 4, 2008 at 1:04 AM
Read this thread:

Best regards,
Nov 4, 2008 at 6:07 PM
Hello Paul, thanks for replying,

Indeed it's possible to document Dispose() by documenting the C++/CLI destructor.  I've done this in the few ref classes we publish in our assembly and it works well.  The problem I'm having, however, is that most of what we export is interfaces, for which I can't document Dispose(), because interfaces can't have a destructor (or, in C++/CLI, a Dispose override).