ImplementIDisposableCorrectly
The rule “ImplementIDisposableCorrectly” should not be displayed in sealed classes as the Dispose(bool) method cannot be declared as protected or virtual.
Also, the help page for this rule has no text for this rule and when clicking the feedback button, it generates an e-mail with the subject ofInterfaceNamesHaveIPrefix
Cheers,Steve
Can you post a code example that shows the class that FxCop is picking up?
The only way I can FxCop to pick up a sealed class is by doing the following:
| |
public sealed class Disposable : IDisposable { void IDisposable.Dispose() { } } |
However, this is a violation of the Dispose pattern, where Dispose should be public.
Thanks for posting this pattern. I think the core problem here is that you shouldn't be declaring a public Dispose(bool) method. Why give an object client the opportunity to call this with an incorrect argument? Since you're the originator of the dispose implementation and since you're defining a sealed type, you should simply implement Dispose() and call it good.
We should either modify the rule to flag this as a problem or fix the issue as originally described (stop firing this specific message on a sealed type). I'll talk to our in-house expert on this rule and get some guidance on which approach is best. In any case, we'll certainly take some kind of fix. Thanks again for taking the time to submit a repro,
Michael