I have a number of test classes in C# (NUnit Test scripts, compiling on Mono).
Instead of compiling all unit tests into one big assembly, as usual, I’d like to compile the individual class files into separate assemblies. To do so, I’d like to do a dependency analysis, so I can generate the separate assemblies automatically.
What I’m looking for is similar to class dependency analyser which exists for Java
Have a look at Mono Cecil.
This library has the capability to ‘reflect’ (not a very good name for it) on the actual assembly image to do analysis. This assumes that you would be willing to compile down to a ‘big’ assembly in order to run the dependency analysis using Mono.Cecil.
I have previously published quite extensive examples of how to use Mono Cecil for ‘advanced’ searches (static call tree search, in essence):
The absolute bare minimum that would be most useful to you would probably be:
Note the commented line optionally filters out things from the framework (
System.String,System.Charetc.).This will list required types per declared type. To list types used, simply tag on the lookup to assembly name:
Sample output of the first kind (types required):
Similar query but using the assembly name lookup: