Circular assembly references in the .NET framework

It was a surprise to me when I discovered that a lot of assemblies in the .NET BCL reference each other in a circular manner:


Cycles in the reference graph are in red. Apparently there is special MSBuild magic used when compiling these assemblies. My guess would be that proper factoring of the assemblies into a DAG without cycles would create too many assemblies and the .NET team opted against that.

I’ve generated this .dgml file to play with the assembly reference graph. You can open it in Visual Studio, and use the Layout –> Analyzers –> Circular References Analyzer on the graph to highlight the cycles in red like I did in the image above. Find Hubs and Unreferenced Nodes are also interesting.

Here’s a fragment of the file with just the 4 assemblies:

 <DirectedGraph xmlns="">
    <Node Id="mscorlib" />
    <Node Id="System" />
    <Node Id="System.Core" />
    <Node Id="System.Xml" />
    <Link Source="System" Target="mscorlib" />
    <Link Source="System" Target="System.Xml" />
    <Link Source="System.Core" Target="mscorlib" />
    <Link Source="System.Core" Target="System" />
    <Link Source="System.Core" Target="System.Xml" />
    <Link Source="System.Xml" Target="mscorlib" />
    <Link Source="System.Xml" Target="System.Core" />
    <Link Source="System.Xml" Target="System" />