views:

105

answers:

5

Our group has a "tools library" DLL that several of our internal projects (all C#) make use of. I've developed the intuition that a good chunk of the tools library is used only by one of the projects -- let's call that project "Project A". Are there any .NET tools that can examine the tools DLL and all the projects (maybe the project EXEs), and enumerate all the methods and classes in the tools library that are indeed used only by Project A? I think some refactoring is in order (moving parts of the tools library back into Project A's own codebase), and such a list sounds like it would be very helpful.

Because of reflection, I don't think a tool can do the job 100% correctly. But let's say I know that none of our projects invoke the tools library with any clever reflection techniques; they invoke it only with normal method calls that should be amenable to static analysis.

A: 

.NET Reflector - Technically will not give you a list, but if you load all your DLLs/Exes into it you can use the "Analyze" function on each type you think is only used from one place and it will confirm that or show you other places that use the type.

Rob McCready
+2  A: 

Sounds like the tool NDepend could determine that for you. Also for a quick check if you are using ReSharper in Visual Studio you can right-click on the dll in the project references and select 'Find dependent code' and this will list the usages within a single project.

Joel Briggs
A: 

Assuming that the tools library DLL is referenced in Project A, you could use the "Find Usages' feature in Resharper, which would tell you everywhere that the referenced assembly (in this case, your tools library) is being used.

Mun
A: 

Just a suggestion here.... I am sure one can be written, but you probably don't have to unless you have a huge # of dlls. I would try this:

  • Get "Reflector"

    • Open it :)
    • Add all your DLLs to the list
    • Go to the class/method you care about
    • Right click
    • Select "Analyze"
    • You should get an entry in the analyzer showing "depends on" and "used by"
  • Create a new soltion

    • Include all of your existing projects
    • Use the "find all references" command in the right click on the methods in the tools project to see who uses them.
    • If there is only one, then you know

Hope this helps.

Andrew Backer
+1  A: 

For an exhaustive list from the point of view of used/used by broken down by each type/namespace (or method if you really want) NDepend is probably the best bet. You can get a free limited version which should be able to do this.

The query will be based around IsUsedBy and IsUsing

If the projects each had a separate namespace (lets say Foo.A and Foo.B)

SELECT TYPES WHERE IsUsedBy "Foo.A"

and

SELECT TYPES WHERE IsUsedBy "Foo.B"

And you'll get a nice list of the types that are being used by each. Drop the results into a spreadsheet table and what is shared/separate will drop out nicely

ShuggyCoUk