Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

quick way to determine number of methods in an interface / class

is there a quick way to tell the number of methods in an interface/class in VS2008? using Resharper? Using NDepend?

like image 492
Yonatan Karni Avatar asked Sep 06 '25 03:09

Yonatan Karni


2 Answers

Try the immediate window (Debug -> Windows -> Immediate)

typeof(System.Windows.Input.ICommand).GetMethods().GetLength(0);

In design time, the immediate window has scope to the currently selected project in the solution explorer - if that makes it tricky to access the interface you're after, then set a breakpoint somewhere you know you can access this interface, debug the application and try again in the immediate window.

like image 79
Rob Church Avatar answered Sep 07 '25 22:09

Rob Church


(Assuming you don't mean programatically.) In Resharper, from the Resharper menu, select Windows then File Structure. This gives you an overview of the entire file you are in, listing the regions, types, fields, properties, events and methods in a hierarchy.

See the feature description which includes a screenshot.

Edit: just noticed this window has an 'export' function on the toolbar, so you could export to your favourite text editor and use editor's line count functionality (or use a command-line tool, such as 'wc -l').

Alternatively, especially if you don't have Resharper, you can just view the assembly in the Visual Studio Object Browser.

like image 36
Paul Ruane Avatar answered Sep 07 '25 20:09

Paul Ruane