dotPeek is a new free .NET decompiler from JetBrains, the makers of ReSharper, dotTrace, and dotCover for .NET developers, as well as a family of IDEs for Java, Ruby, Python, PHP, and other languages, plus team development tools: TeamCity for continuous integration and build management and YouTrack for issue tracking.
The main idea behind dotPeek is to make high-quality decompiling coupled with powerful ReSharper-like navigation and search features to everyone in the .NET community, free of charge.
dotPeek goes public for the first time on Wednesday, May 11, as JetBrains open an Early Access Program that implies regular publishing of pre-release builds. dotPeek web site will be made available at http://www.jetbrains.com/decompiler
JetBrains are also about to include decompiling functionality into their forthcoming release of ReSharper 6. In fact, decompiling has been announced as part of ReSharper 6 back in February 2011, and available in ReSharper 6 pre-release nightly builds since then.
For all features described below, default keyboard shortcuts are specified. By default, dotPeek uses the Visual Studio shortcut scheme derived from ReSharper. dotPeek also provides another shortcut scheme familiar to ReSharper users - that is, the IntelliJ IDEA scheme. You can switch between those schemes via File > Options.
dotPeek decompiles any .NET assemblies and presents them as C# code. Both libraries (.dll) and applications (.exe) can be opened via File > Open assembly.
In addition, assemblies from GlobaL Assembly Cache can be opened via File > Open from GAC. One thing to note about the Open from GAC dialog is that you can batch-select assembly items there, and you can also filter out assemblies by entering their CamelHumps - the capitals that different parts of assembly names start with. For example, to find all assemblies with names containing Microsoft.VisualStudio.Modeling in the list of GAC assemblies, you can type mvsm:
CamelHumps support is a significant concept that also spans multiple navigation features of dotPeek that are highlighted below.
dotPeek provides the Assembly Explorer to traverse the list of opened assemblies. Expanding an assembly node lists namespaces within the assembly that can be further expanded to types and type members, as well as assembly references. Note that the Assembly Explorer uses the same set of icons that are used in Visual Studio for member identification.
Clicking a reference loads the referenced assembly, if immediately available. Clicking a type or type member displays decompiled code in the source code view area.
Source code that dotPeek decompiles is presented as C#. The source code view area has the look-and-feel of editor tabs in Visual Studio, with line numbers, options for word wrap and outlining, white space marks, and tabs to open different types in.
Code syntax is highlighted ReSharper-style, with distinctive colors for properties, types, accessors, and methods.
When you put the caret on a delimiter, be it a brace or, say, parenthesis, it gets highlighted along with its counterpart, bringing focus to the scope of the particular code block you're in:
Similar to ReSharper, you can choose to highlight matching delimiters with a color or an outline. This and other code view area options can be set via File > Options.
Highlighting matching delimiters with an outline doesn't work in early dotPeek builds.
Another noticeable ReSharper-like feature gets handy when you want to select a part of decompiled code, and is called Extend/Shrink Selection. Using a dedicated shortcut (by default, Ctrl+Alt+Right) lets you successively select expanding blocks of code, starting from a substring of a symbol, on to a statement, line, code block, and all the way to the entire code file. A pair shortcut (Ctrl+Alt+Left) works the opposite way, successively narrowing a selection. Read more about this functionality as it is implemented in ReSharper.
Extend/Shrink Selection may be broken in early EAP builds.
When you explore decompiled code, you may be willing to learn more about referenced types and method calls without opening their declarations. Two coding assistance features from ReSharper will help you with that:
The primary idea behind dotPeek is to bring ReSharper experience to browsing external assemblies and make this available to everyone. The main thing that distinguishes dotPeek from other decompilers around is that the majority of ReSharper navigation features are available in dotPeek as well. Let's take a closer look at those:
When you're loading an assembly and you don't know what you're looking for and you want to find out how things are organized within the assembly, you start off with the Assembly Explorer and you probably proceed by navigating between symbol declarations in the code view area.
However, you go a different path if you know exactly (or even approximately) which part of the assembly you need to look at - in this case, you can use one of ReSharper's "go to" context-insensitive navigation features:
Use Navigate > Go to Type (Ctrl+T) to navigate to a specific class or interface. You type in the name of the type you want to find, and dotPeek searches for a match within all loaded assemblies. Here again, the concept of CamelHumps is applicable - you don't need to type DynamicMethodGenerator to open this class - typing dmg is enough:
Use Navigate > Go to Symbol (Shift+Alt+T) to navigate to a specific symbol declaration, which could be a type, method, field, or property. Again, use CamelHumps to narrow down the list of symbols that dotPeek presents:
Since the number of symbols is greatly higher than that of types, and there can possibly be multiple symbols with the same name, you may want to spend a little more time investigating the list of results. One way to do that is press the plus sign (Show in Find Results) while dotPeek shows symbols in the Go to Symbol drop-down list - this will allow you to flush all found results to the Find Results tool window where you can take your time to investigate the results, group based on different criteria, copy to clipboard or export to a file.
As soon as you've opened a specific type, use Navigate > Go to File Member (_Alt+_) for a quick overview of and navigation to members in this file.
Alternatively, you can open the File Structure tool window (Windows > File Structure, or Ctrl+Alt+F) for a static display of members in the current file.
File Structure provides additional file browsing capabilities: for example, if you set Automatically scroll to source in File Structure toolbar, every time you select a member in File Structure, the code view area scrolls to the declaration of this member.
The Track caret in editor option works the opposite way: as you move the caret within the code view area, the corresponding member is highlighted in File Structure.
You can learn more about File Structure options in ReSharper web help.
dotPeek also provides Go to File (Navigate > Go to File or Ctrl+Shift+T) to quickly open files and folders, and assemblies. There are two use cases for this feature:
Speaking of previously opened files, if you've recently closed a code file but you need to have it open again, there's an easy way to have it back: just choose Navigate > Recent Files (Ctrl+,) and in the resulting drop-down list, pick the file you're looking for:
dotPeek provides the same level of insight in context-sensitive navigation between decompiled code symbols as ReSharper does for source code. You navigate to symbol declarations, implementations, derived and base symbols, and any other applicable destinations just like you would in Visual Studio with ReSharper enabled.
Specifically, when you've landed the caret on a symbol, you can always get an overview of all possible navigation targets using the Navigate To drop-down menu (Navigate > Navigate To or Alt+`):
The majority of navigation destinations presented in the Navigate To drop-down menu are also available directly through the top-level Navigate menu.
The following context-sensitive navigation commands can be available depending on context:
For more details on these and other special-purpose commands available through the Navigate To drop-down menu, see ReSharper web help.
The Navigate To functionality is shared between ReSharper and dotPeek. As of early EAP, the Navigate To menu in dotPeek contains several items that are ReSharper-specific, such as Go to Related Files. These items will be removed in subsequent EAP builds.
dotPeek offers the same capabilities of searching for items in decompiled code as ReSharper offers in source code inside Visual Studio. Here's the list of features serving to find all references to a certain symbol:
We've already covered Go to Derived Symbols and Go to Base Symbols above but these two features are useful when you want to go to an inheritor or a base symbol right away. What if you're looking to plainly get an overview of a certain inheritance chain? That's where the Type Hierarchy view comes handy: press Ctrl+Alt+H on a usage of any type, and dotPeek will show you all types that are inherited from it, as well as types that it inherits itself - as a tree view, in a separate tool window.
Goodness doesn't end here, though: you can select nodes in the tool window, rebase hierarchies on them; show or hide previews of type members; and switch between several hierarchy views: for example, you can opt to only show subtypes or supertypes of a given type.
Decompiled code is better than nothing (especially if it's decompiled with dotPeek) but sometimes you want to explore an assembly exactly the way it had been originally written, and be able to read comments its developers have made. Sometimes dotPeek can help with that: it is able to get symbol information and recreate source code from Microsoft Reference Source Center and SymbolSource.org. You can try calling Navigate > Navigate To > Sources from Symbol Files on a type or member and see if symbol information for this particular assembly is available. Before you do that, though, go to File > Options and select Allow downloading from remote locations.
As of early EAP testing, Microsoft Reference Source Server frequently refuses download requests from dotPeek. One particular side effect of this behavior is that the EULA dialog box is shown multiple times before a PDB download is finally rejected. We're looking to find ways to improve this highly annoying behavior.
In the best traditions of JetBrains tools, you rarely need to use a mouse when working with dotPeek: switching between the Assembly Explorer and the code view area; opening File Structure, Find Results, Type Hierarchy and other tool windows doesn't require mouse clicks: every tool window is assigned a shortcut of its own (see the Windows menu for shortcut hints), and getting back to the code view area is as easy as pressing Esc.
When it comes to customizing your workspace within dotPeek, you do need the mouse but otherwise, it's plain easy and familiar. Tool windows behave the same way they do in Visual Studio: they can be left floating or docked in multiple positions. Find Results and Type Hierarchy support multiple tabs, allowing you to have several sets of search results or hierarchies open at the same time, and File Structure content can be filtered to only display results that match a search string: