How can I easily define classes that implement IDispose in Visual Studio?

Is it possible to identify classes that implement IDisposable. I was hoping to do this in the Visual Studio Color preferences or using an addon.

I am not using Resharper and I heard that FXcop has this feature. I was looking for something other than these options.

+1


source to share


4 answers


You can use Class View and Object Browser to define it. But jumping to the definition is a better idea, as the generated MetaData will show you all the methods and inheritance of the class



+2


source


You can right click on the type and select go to definition. It should show you the public members of the class and the interfaces that it implements. The object browser can also be used to view this.



However, Brody's answer is generally the simplest way and works until someone has implemented Dispose but has not implemented the IDisposable interface.

+3


source


Find the Dispose () method for the class.

+2


source


Without risking being wrong (so please don't take it that way), but the best way is to learn your code and learn the Framework. You just need to look at something a couple of times to find out which ones. There is not a very reliable way other than checking if .Dispose () is a method (which always fails, as Dispose can be private on some of the framework classes like ManualResetEvent where it is protected), or by going to the definition. to find it.

This does not mean that someone could not write an add-on that would do it. I don't see any problem with the technical feasibility of this. A quick Google search did not include any existing add-ons that do this, but there may be something already there.

-1


source







All Articles