Pages

Thursday, November 20, 2008

Using .NET Reflector Add-ins

Andrew Clarke

Using .NET Reflector Add-ins

19 November 2008

by Andrew Clarke

.NET Reflector by itself is great, but it really comes into its own with the help of some add-ins. Here we provide you with an introduction to the Add-ins, explain briefly what they do, and encourage you to write your own in order to get .NET Reflector to work the way you want it to!

Introduction

Whereas .NET Reflector aims to provide all the basic functionality for browsing assemblies and their contents, it has been designed from the start to encourage others to add functionality to it.  Some of these add-ins were written initially by Lutz Roeder as an illustration of the ways that Reflector can be extended, but there have been many other contributions that have turned .NET Reflector into a much more versatile tool that has kept up with all the diverse ways that the NET platform has developed, and has evolved to meet the needs of development teams. It also means that a ‘power’ user can add functionality for particular, almost unique, requirements.

Downloading an add-in

The latest version of most of the add-ins are available from the Codeplex site, and can be retrieved by clicking the Download link next to the listed Add-in, or going direct to the downloads page

Installing an Add-In

Installing an add-in is generally very easy. It is just a matter of copying the add-in to the directory in which you installed .NET Reflector and then registering it on NET Reflector using  the View->Add-ins… Menu item

Clicking on the Add-Ins… menu item displays the Add-ins maintenance dialog box. Clicking on the Add… button allows you to select the DLL file that represents the Add-in you want to register with .Net Reflector.

It really is that simple.

The Add-ins

The existing add-ins are all worth trying out. All the ones listed here are free to download. Some, such as CodeModelView and ClassView are really no more than learning tools for anyone wanting to write an Add-in. Some are ‘alpha’ projects that are awaiting completion, whereas many are complete and would be difficult to improve upon. Not all Add-ins will be useful to the average developer; some were written for a specific use which is unlikely to cause general excitement, and others are useful only very occasionally. Others are essential. It is difficult to make hard-and-fast rules about this, but, for example, anyone developing CLR routines for SQL Server will need  SQL2005Browser, and probably also the  FileGenerator For Reflector, whereas anyone working with Silverlight would do well to have  either SilverlightLoader or SilverlightBrowser.  By using Add-ins, one can make .NET Reflector a far better fit with the architecture you are developing with. We have included those add-ins for IDEs such as Visual Studio and SharpDevelop that allow Net Reflector to be used as part of the IDE, so that, by right-clicking a method or class, it can be examined in .NET Reflector.

The Add-ins can be categorized in the following ways

Languages for the disassembler.
These add to the built-in languages. Each language that is installed is added to the language drop-down list in the icon bar.
McppLanguage, Delphi Language for Net Reflector, PowerShellLanguage, ReflectionEmitLanguage, CppCliLanguage
File Writers.
As .NET Reflector has no built-in way of writing decompiled assemblies out to file, these addins are geared to do this
FileDisassembler, FileGenerator For Reflector
Browser extensions.
These allow assemblies to be fetched from  Silverlight, SQL Server,  running assemblies, zipped files etc.
BizTalk Disassembler, Running Assembly Reflector Add-in, OpenZip, ComLoader,
IDE Addin-managers.
These allow .NET Reflector to be invoked from within Visual Studio and other IDEs.
Building the reflector Add-in, SharpDevelop Community, TestDriven, Hawkeye add-in, Scout
Assembly diagramming and metrics.
E.g. Graph, SequenceViz, CodeMetrics, XMI4dotnet, Autodiagrammer, DependencyStructureMatrix, TreeMap
Sample Add-ins
These were written primarily as example add-ins 
CodeModelViewer, Classview
Comparing assemblies
Diff
Searching and sorting
AssemblyCollection.Sort, CodeSearch
Team-working
Review
Resource Viewers
BamlViewer, Enums, RuleSetEditor
Debugging and modifying assemblies
Reflexil, Deblector
Testing
Doubler, Pex

Author

Name

What

Jason Haley

AssemblyCollection.Sort

This add-in sorts (or reorders) the assembly listing in Reflector alphabetically.

AssemblyListEx

The AssemblyListEx add-in allows you to create assembly list files (.ref) and load a set of assemblies directly into reflector by double clicking on the file.

Sacha Barber

Autodiagrammer

This add-in draws class diagrams. provides the class diagramming capabilities. It is well-documented on  CodeProject

Lutz Roeder.

BamlViewer

This add-in loads assemblies containing BAML resources (e.g. localized resource assemblies) and shows the corresponding XAML.

Gilles Zunino

BizTalk Disassembler

This Add-in will list, and optionally extract, BizTalk artifacts from within an assembly. You can see a list of all artifacts, with their type, name, and the namespace they were compiled into, by rBy then clicking the "Decompile..." button, you can decompile all selected artifacts into source files.

Jamie Cansdale

Building the reflector Add-in

This is a Visual Studio addin called ManagedAddIns that  makes Reflector  into an Add-In for Visual Studio.NET . It allows almost any Windows Forms application to be run as an add-in to Visual Studio

RemObjects

ChromeLanguage

This add-in extended Reflector with a Chrome language rendering module. Now withdrawn.

Lutz Roeder

Classview

Shows class definitions as plain text with color

Coding.  It is a sample add-in which is designed to  illustrate how to add a view window to reflector and to demonstrate using the code model, code translation and language writer APIs

Jonathan de Halleux

CodeMetrics

The CodeMetrics add-in analyses and computes several code quality metrics on your assemblies. This add-in uses Reflector to compute classic metrics such as cyclomatic complexity or more straightforward ones such as the number of local variables in a method. All results can be saved to a file.  When you explore the result, you can double-click on an item to show the item in the browser window. Selecting a column will size the items in the tree map to the values in that column. Using shift+click will assign the values as colors.

Lutz Roeder

CodeModelViewer

This add-in shows the underlying code model objects for a selected node in .NET Reflector. The menu item is registered under the "Tools" menu.

Herve Chapalain

CodeSearch

Code Search is an add-in for .Net Reflector that allows searching within the source code.
You can either search using plain text or using regular expressions like such as … (try).+(catch)?
You can search from the Assembly to the Function level, which means that  you can't search within all loaded assemblies at the same

Jason Haley

CodeShortcut

This provides a 'Create Shortcut' context menu item for creating a ‘code://’ shortcut on your desktop to the item you currently have selected. URI Shortcuts can be transmitted to anyone with Reflector, and the same .dll/.exe that you created a shortcut to. They can also be put on the clipboard by selecting the item and pressing Cntl Alt C

Jonathan de Halleux

ComLoader

Allows importing COM/OLE type libraries using Reflector's file menu. It lists the COM components for browsing and converts them into managed interop assemblies.

Dean Wills,

CppCliLanguage

This is a C++/CLI language rendering module.

Falice Pollano

Deblector

Deblector is an add-in that allows debugging from NET Reflector

Peter Sawatzki, Hallvard Vassbotn

Delphi Language for Net Reflector

This add-in extends Reflector with a Delphi language rendering module.

Tom Carter.

DependencyStructureMatrix

This add-in generates and manipulates Dependency Structure Matrices (DSMs) in order to untangle complex inter-module dependencies, Identify design violations  and Identify cyclic dependencies

Sean Hederman

Diff

This add-in shows differences between two versions of the same assembly. If you select a Framework DLL  in the tree node in the Reflector main window, and then choose Tools->Assembly Diff from the menu, it will display  the Diff automatically. If you select anything else,  you will need to select an assembly from an Assembly selection screen. The Diff utility will remember the match, and will always select that destination assembly when you next select the source assembly, up to 20 matches by default.

Jay Flowers

Doubler

Doubler is a code generator (C# and VB.NET)for unit testing ,especially legacy code. It helps cleave dependencies apart, create test doubles, and write unit tests . It features a

  • Recording Generator – Use against an abstract type. It will create a Recording Test Stub.
  • Fake Generator - Use against an abstract type. It will create a Fake Object.
  • Test Generator – Use against a concrete type. It will generate a unit test fixture and test methods for each public method on the test subject..

Jason Haley

Enums

Enums provides a Bit Flag Converter for helping to determine which bits are turned on by providing an integer or vice versa. This addin also includes an Enum Viewer that is a custom enum disassembler (for VB and C# only) that allows the user to decide whether enum fields should be shown in alphabetical order or by value.

Denis Bauer

FileDisassembler

The Reflector.FileDisassembler can be activated from the Tools-File disassembler menu and is used to  dump the decompiler output to files of any language supported by Reflector (e.g. C#, VB.NET, Delphi). This will then allow file-based searching or  help to convert a class from one language to another.

Jason Bock

FileGenerator For Reflector

This Add-In generates code and resource files for a selected assembly, module, namespace, or type. It also creates a VS project file to see the generated files in Visual Studio.

Jonathan de Halleux

Graph

This add-in draws assembly dependency graphs, IL flow graphs and class diagrams. Recommended.

Hawkeye add-in

HawkEye, a free tool for debugging the UI tree of Windows Forms applications, is able to use Reflector by means of an Add-in . If you select your element,  and select ‘Show source code’ on the context menu, Hawkeye will immediately ask Reflector to show you the source code of the selected element, whether it is a field, property, event, method or class.

McppLanguage

A Managed C++ language add-in for .NET Reflector.

Jason Haley

OpenZip

The OpenZip addin makes it easier to add a dll/exe from a zip file into Reflector's list of assemblies. The addin places itself on the File menu with the other Open commands. When you choose it, a dialog will open allowing you to browse to a zip file. Once you have chosen a zip file, any dlls or exe's will show up in the list box allowing you to select it. Once you have selected all the assemblies you want to extract and add to Reflector, you can open it as usual.

Jonathan 'Peli' de Halleux

Pex

This add-in allows you to start the Pex wizard directly from Reflector. The wizard generates a suite of parameterized unit tests from any assembly. This suite can later be run through Pex to generate unit tests.

Daniel Cazzulino

PowerShellLanguage

This provides an extra entry in the language list for Powershell. If selected, It will decompile the IL into Powershell

Jonathan de Halleux

ReflectionEmitLanguage

This add-in translates the IL code of a given method into the C# code that would be needed to generate the same IL code using System.Reflection.Emit

Sebastien LEBRETON

Reflexil

Reflexil is an assembly editor and runs as a plug-in for Reflector. Using Mono.Cecil, written by Jb Evain, Reflexil is able to manipulate IL code and save the modified assemblies to disk. Reflexil also supports 'on the fly' C# and VB.NET code injection.

Jonathan 'Peli' de Halleux

Review

This is a lightweight code annotation tool for Reflector that can be used during code reviews or API reviews to take notes and pass them to other project members. It stores the annotations in an XML-based Review file.  These Review files can be merged.

Review files consist of code annotations. These consist of a list of changes. Each change consists of a comment, a date, a user, a status and resolution. To avoid losing any information, changes are written to disk after each 'commit'.

RuleSetEditor

This allows editing, assign, or removing rules from a rule set in Windows Workflow Foundation

Kevin Dente

Running Assembly Reflector Add-in

This Add-in will open an assembly or dependency from a process that is running on the system. The add-in adds a new menu to the Tools menu called “Open Running Assembly“. When you select it, the add-in displays a dialog that displays a list of managed processes running on the system. You can choose the process, or any managed assembly loaded in that process, and the selections will be loaded  into Reflector.

pbludov

Scout

Integrates Reflector into Resharper

Nauman Leghari

SequenceViz

This is a reflector addin using the WPF renderer to generate a sequence diagram or code flow

Christian Hornung

SharpDevelop Community

This is an add-in to the free SharpDevelop  source-code editor. It opens NET Reflector directly from the SharpDevelop 221 and positions it on the selected code element. Reflector will load the required assembly and directly go to the selected method (or classes and other types of class members). This is now integral to the current SharpDevelop 3.0 so is no longer required

Ernie Booth

SilverlightBrowser

This loads and shows the files associated with a Silverlight website. It takes a URL to a Silverlight page and finds the assembly for that page. It also loads up the JavaScript and root Xaml for the page.

SilverlightLoader

This add-in adds an item in the File menu to allow you to  browse a Silverlight website and load assemblies from it.

Denis Bauer

SQL2005Browser

This allows you browse of .NET assemblies within databases stored in a local or remote SQL Server 2005 instance, and download them directly into .NET Reflector

Jamie Cansdale

TestDriven

This is a Visual Studio add-in. Within Visual Studio,  Right click and 'Test With... Reflector' to navigate to any code element inside Reflector. This works with methods, types, fields, events, enums and delegates.

Jonathan de Halleux

TreeMap

This is Peli's bid to use an Add-in to  compute and visualize coverage, and inspire others to write  Reflector Addins for code coverage visualization.

Andrew Cain

XMI4dotnet

This is an Add-in that allows you to export an assembly to an XMI file that can then be imported into a variety of UML tools. Xmi4DotNet examines your assembly and exports XMI  It is useful for exporting your code model into a UML package to simplify drawing.


Writing or modifying an Add-in.

Writing an Add-in, or modifying an Add-in, is reasonably easy, and will not tax any experienced .NET programmer.  Because most of the Add-ins are available in source-code on CodePlex, one can get a long way by modifying these for particular requirements, or to change the interface to suit the way you work.  There is also Jason Haley’s great resource for Add-In writers, that includes templates and walkthroughs to make the work even easier. He includes easily-followed instructions on getting started.  Lutz has even provided a ‘Hello world’ add-in to get started with.  If you write anything that could be of use to another .NET Reflector users, then please add it to the Codeplex archive

This article has been viewed 252 times.

Andrew Clarke

Author profile: Andrew Clarke

Andrew Clarke has been developing software applications for over 25 years. He is a database expert, but has a particular interest in website-publishing and ECommerce. He recently worked with the first two winners of the 'Apprentice' program at Amstrad, creating various business applications, and since worked with Tim Campbell setting up the 'Bright Ideas Trust'. He also subedits and reviews articles for Simple-Talk.

Search for other articles by Andrew Clarke