Hi,
Hilton said:
The original argument that you assign to me (and that you say is nonsense)
was "This is, by Microsoft's definition, a breaking change." My claim is
that MICROSOFT says that it is a breaking change, not me, Microsoft - go
back and re-read all my posts in this thread - I always attribute the
"breaking change" to Microsoft. I even quoted MS with a URL and
everything.
The full statement within MSDN is as follows:
"It is a version breaking change to add the IDisposable interface to an
existing class, as it changes the semantics of the class."
My interpretation of this is that it doesn't say you shouldn't do it, only
that before doing it you should consider the possible impact/changes it will
cause on clients of your class.
This particular example was a change between version 1 and version 2 of the
..NET CF (so was part of a version change), but it doesn't really have too
much of an impact on end user code. I assume Microsoft considered the
possible impacts of this change when they implemented it and considered it
minimal.
Code originally designed for .NET CF 1.0 will still compile without
alterations and run without error if you place it in a .NET CF 2.0 project.
Obviously it will not call Dispose(). Instead you'll just get the old
behaviour where the objects hang around for a little while longer and are
tidied up within the object's finalizer.
Obviously you can't place a using statement for these objects within a .NET
CF 1.0 application, but you shouldn't expect to be able to use features of a
later version of a runtime, base class library or language while targeting
an older version. In general Microsoft (and most other companies) develop
things with backwards compatibility in mind and not forwards compatability
(i.e. the possibility to use new features in an older environments).
This "breaking change" means that newer applications that are aware that
these objects implement IDisposable can free up resources quicker in a
standardised and well understood manor, while not breaking older
applications that are not aware (or have not been updated). Any application
which doesn't take advantage of these objects implementing IDisposable will
free the resources when the garbage collector kicks in to finalize the
objects, so no resources are leaked etc.
Hope this helps,
Christopher Fairbairn