https://learn.microsoft.com/en-us/dotnet/api/system.idisposable[IDisposable] is an interface implemented by all types which need to provide a mechanism for https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/unmanaged[releasing unmanaged resources].
Unlike managed memory, which is taken care of by the https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals[garbage collection],
First, it is important to determine whether instances of the type defining the `Dispose` method should support the https://learn.microsoft.com/en-us/dotnet/api/system.idisposable[IDisposable] interface or not.
The decision would be based on whether the instance can have unmanaged resources which have to be dealt with, upon destruction or earlier in the lifetime of the object.
If the type should not support the pattern, the `Dispose` method should be renamed to something which is different than `Dispose`, but still relevant and possibly more specific to the context.
\[~ann.campbell.2] I've changed all occurrences of "override" to "implement". I think it is better this way.
=== on 9 Jun 2015, 13:46:11 Ann Campbell wrote:
okay, thanks [~tamas.vajk]
=== on 18 Jun 2015, 11:41:33 Tamas Vajk wrote:
\[~ann.campbell.2] I've added an exception. This is a usual pattern in C#. You can read about it here: \https://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.110).aspx
=== on 18 Jun 2015, 12:00:49 Ann Campbell wrote:
okay [~tamas.vajk]
=== on 4 Aug 2015, 18:14:10 Ann Campbell wrote:
\[~tamas.vajk] I've just mapped this to FxCop's ImplementIDisposableCorrectly, but I believe that rule is broader than this one.
=== on 5 Aug 2015, 13:23:50 Tamas Vajk wrote:
\[~ann.campbell.2] Yes, it seems to me too that it is doing more. I'm not sure if we would want to add more disposable rules, or cover all the cases of this FxCop rule in this RSPEC.
=== on 20 Nov 2019, 10:31:27 Costin Zaharia wrote:
We should add an exception in this rule for https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#disposable-ref-structs[disposable ref structs] introduced in C# 8.