Introducing JetBrains dotPeek

compared with
Version 24 by Hadi Hariri
on May 09, 2011 21:32.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (18)

View Page History

h3. 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.


h4. 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_:
!open_from_gac.png|thumbnail,border=1!
CamelHumps support is a significant concept that also spans multiple navigation feautres of dotPeek that are highlighted below.

h4. 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.

h3. 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|http://www.jetbrains.com/resharper/features/navigation_search.html] are available in dotPeek as well. Let's take a closer look at those:

h4. 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:

h5. 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:
!go_to_type.png|thumbnail,border=1!

h5. 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:
!go_to_symbol.png|thumbnail,border=1!

h5. 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.
!go_to_file_member.png|thumbnail,border=1!
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.

h5. 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.

h4. 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_):

h4. 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

dotPeek offers the same capabilities of searching for elements in decompiled code as ReSharper offers in code inside Visual Studio.

* _Usages of Symbol_ (Shift+Alt+F12): Select any symbol and right-click the mouse for the context menu or use the keyboard shortcut to find all usages of the current selected symbol, allowing quick navigation to the selected item.

!usagesofsymbol.png|border=1!


* _Find Usages_ (Shift+F12): In the Assembly Explorer, right click on any type or use keyboard shortcut to select Find Usages and get a tabbed tool window with the usages of the selected item. !findusages.png|border=1!


* _Find Usages Advanced_ (Ctrl+Shift+Alt+F12): Ability to fine tune the usages scenario by limiting scope and other characteristics.



h3. Other Features

h4. Type Hierarchy

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.
!type_hierarchy.png|thumbnail,border=1!

h4. Downloading Source Code from Source Servers

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|http://referencesource.microsoft.com/] and [SymbolSource.org|http://www.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_.

h4. 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_.

h4. 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:
!file_structure_filtered.png|thumbnail,border=1!