Login | Register
My pages Projects Community openCollabNet

Project home

If you were registered and logged in, you could join this project.

Summary Build process tool to enforce layering and dependency rules
Category process
License GNU General Public License
Owner(s) nblumhardt

Reference Inspector is a simple build-time tool to enforce layering and dependency rules between .NET assemblies.

When used with a continuous integration server like CruiseControl.NET, Reference Inspector helps you detect violations of a system's intended architectural dependencies as soon as they occur, rather than later when they may be much harder to back out.

The kinds of problems prevented by using Reference Inspector are:

  • Unwanted deployment dependencies on non-redistributable or bulky components

  • Violations of major layering objectives, such as dependencies between the business and user interface layers

  • Dependencies between new code and deprecated/legacy code

  • Reference spaghetti

An added advantage is that the reference rules can record and communicate the high-level intentions of a system's architects to new developers and future maintainers.

Reference Inspector is similar in intent to FxCop, however while FxCop is intended to enforce best practices through a vast number of generic rules, and at the level of a single assembly, Reference Inspector works on the relationships between assemblies to enforce rules that are highly specific to that particular project.


Beta. Still working out the finer points of implementation. The current rule language is very usable, however it would benefit from less verbosity and more flexibility. If major changes in the rule definition syntax are made, conversion tools will be available.

Download and Installation

The executable is available here. No installation is required, but the .NET Framework version 2.0 or above must be available.


Each system analysed by Reference Inspector requires a rules file, by convention named ProjectName.ri.xml. This is an XML document of the following form:

<?xml version="1.0" encoding="utf-8" ?>


   <IgnoreFrom Pattern="*.Tests" />

    <IgnoreTo Pattern="System.Xml*" />



            <Assembly Pattern="MyApp.Server"/>



            <Assembly Pattern="MyApp.Client"/>




        <Assembly Pattern="MyApp.Model*"/>


            <Assembly Pattern="MyApp.Interfaces"/>




        <Assembly Pattern="System.Windows*"/>

        <Assembly Pattern="System.Drawing"/>


            <Assembly Pattern="MyApp.UI" />

            <Assembly Pattern="MyApp.Controls" />





Assemblies matching IgnoreFrom rules will be ignored. This is handy for third-party components that are present in the binary deployment, or for unit test assemblies that may violate layering rules in order to provide stub functionality.


References to assemblies matched by IgnoreTo rules will not be checked. This is useful for libraries that are referenced by most of the project.


The simplest rule – forbids any of the assemblies in the From list to reference any of the assemblies in the To list.


These rules control the outgoing references of an assembly, and are the most useful for enforcing layering rules.


These rules prevent references to components that may be deprecated or require encapsulating behind wrapper assemblies (e.g. to prevent widespread dependencies on third-party components.)


ReferenceInspector works by recursively searching for assemblies in a specified directory. It is run from the command line with the following syntax:

ReferenceInspector.exe <rules> <searchDir>

The results of the check are printed to the console, with the app returning a non-zero exit code when rule violations are found.

Future Directions

If you'd like to suggest any improvements to Reference Inspector, email the developers. Some of the ideas so far are:

  • A CruiseControl.NET plugin

  • An FxCop plugin

  • Class/Namespace level analysis

  • An XSD for the rule file schema

Are you using Reference Inspector?

If so, we'd love to know! Email Nicholas Blumhardt to be listed here.