Looking for simple code analysis tool

B

beantaxi

Hello all,

I'm looking for a very simple code analysis tool. I have a large
codebase to analyze, and all I really need to do is to find all uses
of all methods in a few interfaces.

Many tools (e.g. Resharper) obviously do this internally, but I can't
seem to find any that expose this simple functionality. Command line
would be fine -- in fact I'd prefer that but its not necessary.

Does anyone have any suggestion?

Thanks much,
b. taxi
 
P

Peter Duniho

Hello all,

I'm looking for a very simple code analysis tool. I have a large
codebase to analyze, and all I really need to do is to find all uses
of all methods in a few interfaces.

Many tools (e.g. Resharper) obviously do this internally, but I can't
seem to find any that expose this simple functionality. Command line
would be fine -- in fact I'd prefer that but its not necessary.

Does anyone have any suggestion?

Maybe you could be more clear about your question. As stated, it's
difficult to understand why the "findstr" NT command prompt command or
some grep implementation (including the "find in files" feature in
Visual Studio) wouldn't accomplish what you're asking for.

Pete
 
B

beantaxi

Fair question. Short answer: because findstr and grep (or Find in
Files) won't work :)

Simple example: I have interface IFoo with method GetName(). I want to
find all invocations of IFoos GetName() method, on all
implementations. If if I grep on GetName() I'll get all calls to *any*
GetName() method, and in a large codebase I might have many methods
called GetName().

The functionality I want is exactly what's provided by Resharper's
"Find Usages" command, except that command is only available from the
IDE, one method at a time. I need something that can give me all the
usages on all methods on whatever interfacea or classes I specify.
This functionality obviously exists under the hood of any number of
code analysis tools, so I assume it exists somewhere in the simple
form I need, rather than an cyclometric analysis report generator.

Thanks,
Chris
 
B

bryan

Put all the code into a Visual Studio Solution and use Find All References
for each method you're interested in. The Find Symbol output window will
list file and line where the reference is.
 
C

chris.lalos

Sorry if I'm not being clear . . . I'm not just looking for something
I can do in a GUI, one method at a time. I can do that now. I'm
looking for something that can operate over a number of interfaces. To
give you an example, some of these interfaces have over 100 methods.
Yep, that's wayyyyyyy too many, which is why I'm doing the analysis in
the first place, so I can find out which methods are used and which I
can kill. Oh, I can't just delete all methods, build, and see what
breaks, because we have dozens of solutions which may be using the
interface.

Thanks,
b. taxi
 
P

Peter Duniho

Sorry if I'm not being clear . . . I'm not just looking for something
I can do in a GUI, one method at a time. I can do that now. I'm
looking for something that can operate over a number of interfaces.

For what it's worth, your follow-up to my post did clarify things.

Unfortunately, I'm not aware of a tool that does this. However, that's
not to say one doesn't exist. I think it's possible that one or more
of the third-party tools that are often mentioned in this newsgroup may
do what you're looking for. The Resharper tool comes to mind, for
example. Maybe even Reflector.

Barring that, it might not be hard to implement yourself. Again,
lacking first-hand experience I can't offer much advice. But I know
from discussions with other C# coders that you can write a C# program
that compiles code, and I know that you can write a C# program that
uses reflection to inspect that code.

So it seems to me that you could write a program that, given a target
directory, enumerates the .cs files or projects in the directory
(optionally enumerating directories within directories, of course),
compiles what it finds, and then inspects the compiled results looking
for the desired interface methods.

Pete
 
C

chris.lalos

Hmmm . . . this sounds promising. I was figuring I might have to write
it myself, but I hadn't thought of using any compilation tools to help
out. That's definitely interesting.

Thanks Peter,
b. taxi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top