Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have a look at Mono Cecil. </p> <p>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.</p> <blockquote> <p><strong>Edit</strong> In fact, you might simply use Cecil to copy the 'big' assembly while filtering out parts of it. That way, you'll not have much of the complexity of compiling the separate assemblies; Look at <strong><a href="https://github.com/mono/cecil/tree/master/tools" rel="nofollow noreferrer">CecilRoundtrip sample</a></strong> for an example of how to roundtrip (<em>read -> manipulate -> save</em>) assemblies in Cecil.</p> </blockquote> <p>I have previously published quite extensive examples of how to use Mono Cecil for 'advanced' searches (static call tree search, in essence):</p> <ul> <li><a href="https://stackoverflow.com/questions/5667816/get-types-used-inside-c-sharp-method-body/5741926#5741926">Get types used inside a C# method body</a></li> <li><a href="https://stackoverflow.com/questions/5741350/look-if-a-method-is-called-inside-a-method-using-reflection/5741770#5741770">Look if a method is called inside a method using reflection</a></li> </ul> <p>The absolute bare minimum that would be most useful to you would probably be:</p> <pre><code>var types = assemblies .SelectMany(assembly =&gt; assembly.MainModule.Types.Cast&lt;TypeDefinition&gt;()); var dependencies = types.ToDictionary( key =&gt; key, typedef =&gt; new HashSet&lt;string&gt;(typedef.Methods.Cast&lt;MethodDefinition&gt;() .Where(method =&gt; null != method.Body) // ignore abstracts and generics .SelectMany(method =&gt; method.Body.Instructions.Cast&lt;Instruction&gt;()) .Select(instr =&gt; instr.Operand) .OfType&lt;TypeReference&gt;().Distinct() // .Where(type =&gt; !type.Namespace.StartsWith("System")) .Select(type =&gt; type.Name))); foreach (var entry in dependencies) { Console.WriteLine("{0}\t{1}", entry.Key.Name, string.Join(", ", entry.Value.ToArray())); } </code></pre> <p><strong>Note</strong> the commented line optionally filters out things from the framework (<code>System.String</code>, <code>System.Char</code> etc.).</p> <p>This will list required types per declared type. To list types used, simply tag on the lookup to assembly name:</p> <pre><code> .Select(type =&gt; type.Module.Assembly.Name.Name))); </code></pre> <p>Sample output of the first kind (types required):</p> <pre><code>SegmentSoortKenmerk SegmentSoortKenmerk OperatorValue Koppelpad Koppelpad, CodeLeidendVolgend RedenWaarschuwing RelExceptions GecontroleerdDocument GecontroleerdDocument, GecontroleerdDocument[] OwiExtraKenmerk OwiExtraKenmerk, Gegeven, BackofficeRelatie Entiteit Entiteit, SleutelSysteemObject[], EniteitType </code></pre> <p>Similar query but using the assembly name lookup:</p> <pre><code>SegmentSoortKenmerk Lspo.Business OperatorValue Koppelpad Lspo.Business RedenWaarschuwing RelExceptions GecontroleerdDocument Lspo.Business OwiExtraKenmerk Lspo.Business Entiteit Lspo.Business </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload