This project is read-only.

Introduction to the .NET Reflector Add-In Model

A Reflector add-in is a dll/exe assembly file that contains packages. A package is a class that implements the IPackage interface which defines a Load and Unload method. An IServiceProvider is passed during loading and gives access to a set of services which are part of the Reflector object model (see below).

HelloWorld Add-In

A simple "HelloWorld" add-in can be created by implementing the IPackage interface. The Load method is implemented to ask the IServiceProvider for the IWindowManager service which allows you to communicate with Reflector's windowing system. The ShowMessage method is used to show a message to the user.

using System;
using Reflector;

internal class HelloWorldPackage : IPackage
    private IWindowManager windowManager;

    public void Load(IServiceProvider serviceProvider)
        this.windowManager = (IWindowManager) serviceProvider.GetService(typeof(IWindowManager));
        this.windowManager.ShowMessage("Loading HelloWorld!");

    public void Unload()
        this.windowManager.ShowMessage("Unloading HelloWorld!");

The code can be compiled into an add-in dll which is referencing Reflector.exe as a library.

    csc.exe /target:library /out:HelloWorld.dll *.cs /r:Reflector.exe

The add-in can be copied to your Reflector directory and loaded using the View | Add-Ins menu.

Services Available to Add-In Authors

The following table lists the most commonly used services that can be accessed through the GetService method on IServiceProvider.

Service Description
IAssemblyBrowser Maintains the currently selected Code Model object in the ActiveItem property. You can assign a Code Model object like IMethodDeclaration to the ActiveItem to programatically change the currently selected item in the browser window. ActiveItemChanged notifies that the selected item has changed.
IWindowManager Manages the application window and pane windows. You can add your own pane windows to the Windows collection which will create an IWindow hosting frame. ShowMessage can be used to show notification messages to the user.
ICommandBarManager Manages the Reflector menu bar, tool bar and context menus. You can lookup a context menu by its identifier and add items to it.
IConfigurationManager Manages the sections from the Reflector configuration file as a set of IConfiguration objects. Lists of items are represeted as properties named "0", "1", "2", ...
IAssemblyManager Maintains the list of currently loaded assemblies. LoadFile can be used to load an assembly file from disk. Unload allows to unload an assembly from memory. The Assemblies collection holds all the currently loaded assemblies.
ILanguageManager Manages formatting modules for different programming languages. The ActiveLanguage property exposes the ILanguage object currently used for rendering. You can add your own language rendering code by implementing the ILanguage interface. Use RegisterLanguage to add your add-in to ILanguageManager.

Adding Items to Command Bars and Context Menus

The ICommandBarManager service allows you do add menu items to the Reflector main menu and context menus. Each submenu and context menu is registered in the CommandBars collection with an identifier name. The following table lists the most commonly used identifiers:

Identifier Description
Tools The tools menu shown as part of the main menu.
Browser.Assembly The context menu for the currently selected assembly.
Browser.Namespace The context menu for the currently selected namespace.
Browser.TypeDeclaration The context menu for the currently selected type declaration.
Browser.MethodDeclaration The context menu for the currently selected method declaration.

Disclaimer: The content of this website is provided "AS IS" with no warranties, and confers no rights.

Last edited May 6, 2007 at 12:01 AM by lutzroeder, version 7


RipTornRic Jan 11, 2012 at 9:04 PM is similar and free

kphani_prasad Oct 8, 2011 at 2:23 AM 
.NET Reflector piece of software was free, now its not free, Does this article have any link to free .net reflector, please?

ramiljoaquin Nov 21, 2008 at 11:56 AM