views:

430

answers:

5

What kind of a tool could examine source or assemblies and tell if StringBuilder was ever used? or if the ObjectDataSource was used?

I'm open to source analysis or reflection, but also need to know the right way to do this against Web Applications.

UPDATE: I guess I'm looking for a tool that you could insert into a build process that would output a report telling me if certain assemblies or patterns were used. I'd also like to be able to tell if inheritance is used anywhere in the code (on the non-Framework classes in the build). A simple way to tell me if any OOP was used.

+2  A: 

Reflector has many add-ins including a code search. Obviously this is a text search but it might help. Other solutions may work better but might not be as inexpensive.

Andrew Hare
+1, because Reflector is always the right tool for code that you didn't write
STW
+13  A: 

Look into NDepend - it has this capability and more.

I've successfully used it to analyze very large projects. It has a built-in code query language that allows you to find code based on dependencies and usages of other code.

It can also be used against both source code or binary-assemblies - although the analysis of binaries will be more limited (no cyclomatic complexity analysis, and the such).

LBushkin
NDepend is a pretty killer tool, only 5 more months till I can put it on my budget wishlist for next year :)
STW
A: 

I don't know if I correctly understood your question, but if you are using Visual Studio, you can right click a type name on your source code and select "Find All References".

Fernando
Want it a little more automated. See update.
tyndall
Then I believe that NDepend (http://www.ndepend.com/) is your guy.
Fernando
+1  A: 

You can use StyleCop and create custom rules for the constraints for which you want to scan.

Out of the box, StyleCop can be automated if you are using MSBUILD. If you use nant, you can use something like StyleCopCmd to use StyleCop in your build process. I use StyleCop and StyleCopCmd in my nant builds and it works pretty well.

Steven Lyons
+1  A: 

If you're looking to integrate it with a build then then FxCop comes to mind as an option. It's extensible and not too hard to write your own rules, however finding documentation can be tricky.

A great starting doc is "FxCop and Code Analysis: Writing Your Own Custom Rules" from Jason at BinaryCoder.net

Edit: The other big benefit of going the FxCop route is that VSTS Code Analysis is FxCop--and I believe (though haven't done it first-hand) that you can use your custom rules with TFS 2008's Gated check-in feature to help keep non-compliant out.

STW