The new Reflector AddIn for SharpDevelop has been released. It has been integrated into the SharpDevelop 3.0 tree in build 3249 and it is also available for download for SharpDevelop 2.2.1.
The Reflector AddIn provides the ability to open Lutz Roeder's free .NET Reflector directly from the source code editor and position it on the selected code element.
For those who do not already know Reflector, it is an excellent .NET assembly browser and also a disassembler and decompiler for various .NET languages. It really comes in handy when you are working with a poorly documented library, for instance.
I recently wanted to make use of the SharpSvn library which is essentially a managed wrapper for the Subversion client API. During development I came across the following situation:
Now there is obviously no documentation available for the GetStatus method, and I do not want to go and download the whole source code either. But I would like to know whether the "statuses" collection can be null when that method returns. So what can we do? Open Reflector. The Reflector AddIn provides that command in the refactoring context menu:
When you select that command, Reflector will be started up automatically if it is not running. Then Reflector will load the required assembly and directly go to the selected method (of course this is also supported for classes and other types of class members):
Now we want to see the code. Press space bar (or select "Disassemble" from the "Tools" menu). There it is:
Now we can see that the "items" variable is always initialised and assigned to the out parameter in question within the finally block. This means that we will never get a null value.
Of course you can also use the combo box at the top where it says "C#" in the screenshot to change the output to your favourite .NET language. Reflector currently supports C#, VB.NET, Delphi, Managed C++ , Chrome and raw IL out of the box.
The "Open .NET Reflector" command is also available through the class and class member bookmarks on the left margin of the source code editor and also through the context menu in the class browser of SharpDevelop:
When you use the Reflector AddIn for the first time, you have to tell it where to find Reflector. For this purpose, the following dialog will pop up:
There you can also find the download link for Reflector in case you do not have it already. Then you have to click the Browse button and locate Reflector.exe.
As soon as you click OK, the location is saved. This dialog will automatically reappear if the add-in can no longer find Reflector.exe at the saved location.
Please note that SharpDevelop must have write access to the directory containing Reflector.exe because it has to copy some files there and modify the configuration of Reflector to load them automatically on startup. This is needed so that Reflector exposes a remoting service which SharpDevelop can connect to.
More Reflector functionality
Reflector can also list all the callers of a method, property etc. and all code elements that are in use by a certain member. This function is available through "Tools" -> "Analyze":
Reflector itself also has its own add-in architecture and a great variety of add-ins is available. For example, there are add-ins which can draw class diagrams, sequence diagrams or dependency graphs.
Download for SharpDevelop 2.2.1
The Reflector AddIn for SharpDevelop 2.2.1 is available for download on my web site: