detecting assembly references we don't directly depend on

Topics: Metadata Model, PE reader
Aug 22, 2010 at 1:08 PM
Edited Aug 22, 2010 at 1:11 PM

Hi, 

Let's say *some* compiler is given more assembly references (in the command-line) than actually needed for the compiled program to run (this happens all the time in Visual Studio). 

While emitting bytecode, the compiler could keep track of external types actually used. Has been the algorithm for that documented somewhere? 

At least one tool (NDepend) tells which assem-refs to prune, 

http://codebetter.com/blogs/patricksmacchia/archive/2010/02/12/rationalizing-assembly-reference.aspx

In case the link above doesn't work: 

http://codebetter.com/blogs/patricksmacchia/archive/2010/02/12/rationalizing-assembly-reference.aspx

 

So I know that it's possible :) Anybody been there before?

 


Miguel 

http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/

Coordinator
Aug 30, 2010 at 5:42 AM

If you give PeWriter an assembly with list of assembly references that does not include all of the assemblies actually referenced, it will add the missing references. Thus, given an assembly with an empty list of references, you'll get exactly those references that you need.

The algorith used is simply to traverse the object model and to enter each assembly reference encountered into a table.