- What is dotPeek
- General Features
- Navigation and Search
- Other Features
What is dotPeek
dotPeek: 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 and YouTrack.
dotPeek goes public for the first time on Tuesday, May 10, as JetBrains open an Early Access Program that implies regular publishing of pre-release builds.
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.
Opening and Browsing Assemblies
dotPeek decompiles any .NET assemblies and presents them as C# code. Both libraries (.dll) and applications (.exe) can be opened with 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 feautres of dotPeek that are highlighted below.
dotPeek provides an 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 we're used to 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.
Viewing the Source Code
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.
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+W) 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 file. A pair shortcut (Ctrl+Shift+W) works the opposite way, successively narrowing a selection. Read more about this functionality as it is implemented in ReSharper.
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: Parameter Info (Edit > Parameter Information) on a method call will display all available signatures of the given method, and Quick Documentation (Edit > Show Quick Documentation) on a usage of a type, method, property, or another type member will display an overview of its documentation comments:
Navigation and Search
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:
Context-Insensitive Navigation in Decompiled Code
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 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:
Navigating to a Type
Use Navigate > Go to Type (Ctrl+N) 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:
Navigating to a Specific Symbol
Use Navigate > Go to Symbol (Ctrl+Shift+Alt+N) to navigate to an specific declaration, which could be a type, method, field, or property. Again, use CamelHumps to narrow down the list of symbols that dotPeek presents:
Since symbols are a lot more numerous than 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 them, group based on different criteria, copy to clipboard or export to a file.
Navigating Between File Members
As soon as you've opened a specific type, use Navigate > Go to File Member 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+F11) 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.
Navigating to a Code File
dotPeek also provides Go to File (Navigate > Go to File or Ctrl+Shift+N) to quickly open files and folders. It is limited to temporary files from dotPeek decompiled code cache, so you can use it as an extended tab switcher that not only works with currently opened code files but also takes into account any tabs that you've ever opened before.
Context-Sensitive Navigation Between Symbols in Decompiled Code
dotPeek provides exactly the same level of insight in context-sensitive navigation between decompiled code symbols as ReSharper. 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 menu (Navigate > Navigate To or Ctrl+Shift+G):
The majority of navigation destination presented in 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:
- Go to Declaration (Ctrl+B): this takes you from a usage of any symbol to its declaration. Should the symbol be dependent on another assembly, the assembly will be loaded silently, if available.
- Go to Base Symbols (Ctrl+U): this takes you to corresponding symbols upwards the inheritance hierarchy:
- Go to Derived Symbols (Ctrl+Alt+B): the opposite of base symbols, this command lets you go to any of implementing/overriding members or implementing/derived types:
- Go to Implementation (Ctrl+Shift+Alt+B): allowing navigating to end implementations of types and type members, bypassing intermediate inheritance steps in the inheritance chain, such as abstract classes.
- Go to Extension Methods (only available through Navigate To): shows all extension methods for a certain type.
- Go to Assembly Explorer (only available through Navigate To): navigates from a type or type member in source code view to the corresponding node in Assembly Explorer. Interestingly, this command is duplicated by another shortcut, Shift+Alt+L, that, when applied in ReSharper, locates the current file in Solution Explorer.
For more details on other special-purpose commands available through the Navigate To drop-down menu, see ReSharper help.
Searching in Decompiled Code
- Find Usages: The ability to see easily all the places where a type is used. This is similar to the Used By in REflector..
- Highlight usages in file
- Find usages advanced
- Quick Find
Keyboard-Driven Navigation Between Tool Windows
In the best traditions of JetBrains tools, you rarely need to use a mouse when working with dotPeek: switching between Assembly Explorer and code view; opening File Structure, Find Results, Type Hierarchy and other tool windows doesn't require clicking: every tool window is assigned a shortcut of its own (see the Windows menu for shortcut hints, and getting back to the code view is as easy as pressing Esc.
Customizable, Rich Tool Windows
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 set 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:
- Type Hierarchy
- External Sources (Need confirmation from Ilya is this is allowed to be talked about)
- Same Extensibility Model that of ReSharper in terms of plug-in development. You can develop plug-ins for dotPeek in the same way you can for ReSharper.