Child pages
  • Introducing JetBrains dotPeek

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Wiki Markup
{redirect:NETCOM:Introducing JetBrains dotPeek}

Table of Contents

What is dotPeek

dotPeek is a new free .NET decompiler and assembly browser 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 available to everyone in the .NET community, free of charge.

Image Added

dotPeek goes has gone public for the first time on Wednesday, May 11, in May 2011 as JetBrains open opened an Early Access Program (EAP) that implies implied regular publishing of pre-release builds. dotPeek web site with links to fresh EAP builds will be made 1.0 has been officially released on May 10, 2012. The latest official version of the decompiler and assembly browser is always available at http://www.jetbrains.com/decompiler

JetBrains are is also about to include providing 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., the renowned productivity tool for Visual Studio.

Anchor
distribution
distribution

Distribution Options

dotPeek is available for download in two distributions: an .msi installer and a .zip archive.

The installer-based distribution is a safe bet if you want to use dotPeek on a single PC and take advantage of automatic version management.

The .zip distribution is a better fit if you prefer to share dotPeek between multiple machines - for example, using a Dropbox folder.

Both distributions are functionally equivalent except for the way you configure Windows Explorer integration.

General Features

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 under Tools > Options > Environment > General.

All shortcuts defined in both Visual Studio and IntelliJ IDEA shortcut schemes are listed in a document called dotPeek Keyboard Shortcuts that is available from dotPeek via Help > Keyboard Shortcuts.

Opening and Browsing

...

Files

dotPeek decompiles any .NET assemblies and presents them as C# code. Both libraries

Supported file types include:

  • Libraries (.dll)

...

  • Executable files (.exe)
  • Windows 8 metadata files (.winmd)
  • Archives (.zip)
  • NuGet packages (.nupkg)
  • Microsoft Visual Studio Extensions packages (.vsix)

Files can be opened via in one of the following ways:

  • Using the File > Open

...

  • command.
  • Via drag-and-drop of a file (or a selection of files) to dotPeek window.
  • For .dll files: By double-clicking a file in Windows Explorer (provided that Windows Explorer integration is configured.)
  • For .dll and .exe files: By right-clicking a file in Windows Explorer and selecting Browse with JetBrains dotPeek.

You can also load entire folders in the Assembly Explorer by choosing File > Explore Folder. When you ask dotPeek to explore a folder, it processes all its subfolders in hunt for files that it is able to decompile, and displays the folder's hierarchy in the Assembly Explorer.

Image Added

Note

Since dotPeek processes a selected folder recursively, make sure to act wise selecting one. You wouldn't really want to explore the entire Program Files folder since it would take a really long time to load all assemblies that it contains in dotPeek.

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 an important 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.

In addition, the Assembly Explorer contains nodes representing base types and inheritors of the current type. This is a way to browse type inheritance trees that developers with Reflector background usually find appealing. However, dotPeek also provides a bunch of ReSharper-inspired navigation features that work not only from the Assembly Explorer but from other tool windows and from the source code view areas as well.

Note that the Assembly Explorer uses the same set of icons that are used in Visual Studio for member identification.

Clicking a reference

Pressing F4 on an entry in the Assembly Explorer brings up the Properties tool window that shows basic information about a selected assembly or reference, such as assembly location, full name, and platform version.

Image Added

Double-clicking a reference loads the referenced assembly, if immediately available. Clicking Double-clicking a type or type member displays decompiled code in the source code view area.

Double-clicking an entry under the Resources folder opens the source representation of the corresponding resource in the source code view area (this, for example, applies to .resources files that are converted back to human-readable .resx form, as well as .png and .bmp image formats), or passes it to an external application.

Assembly Lists and Folders

To apply order to the way you work with multiple assemblies, and also to support switching between different sets of assemblies, dotPeek provides assembly lists. You can now work with different assembly lists depending on your context. You can save and reopen assembly lists, or clear the current list if you no longer need it.

Image Added

Assembly lists are not limited to .dll and .exe files: they can contain all supported file types (including archives) and folders.

Anchor
windows_explorer
windows_explorer

Windows Explorer Integration

If you want to be able to open assemblies in dotPeek by double-clicking them or using the Windows Explorer context menu, you need to enable Windows Explorer integration.

This is accomplished in two different ways depending on the type of dotPeek distribution that you're using.

If you're deploying dotPeek using the installer, Windows Explorer integration is set using the installation wizard.

However, if you're using the zip distribution, you need to choose Tools > Options, and select Integrate with Windows Explorer under Environment > General to enable Windows Explorer integration.

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. To set outlining options, set of switch off word wrap and tweak other source code view area options to your liking, consider playing with menu items available through View > Outlining and View > Options. You might also want to glance through Tools > Options.

Code syntax is highlighted ReSharper-style, with distinctive colors for properties, types, accessors, and methods.

...

Similar to ReSharper, you can choose to highlight matching delimiters with a color or an outline. This and other ReSharper-style source code view area options can be set via File Tools > Options .

Note
titleKnown Issue

Highlighting matching delimiters with an outline doesn't work in early dotPeek builds.

> Environment Editor.

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.

...

  • Edit > Parameter Information (Ctrl+P) on a method call will display all available signatures of a given method.
  • Edit > Show Quick Documentation (Ctrl+Shift+F1) on a usage of a type, method, property, or another type member will display an overview of its documentation comments:

Using the Show compiler-generated code switch on the dotPeek toolbar, you can choose to turn off certain compiler transformations, thus making code structure that dotPeek displays very similar to what the compiler turns it to. This helps see how compiler deals with lambdas, closures, and auto-properties, among other things.

Image Added

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:

Anchor
context-insensitive_navigation
context-insensitive_navigation

Context-Insensitive Navigation in Decompiled Code

...

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 DatasetMethodGenerator to open this class - typing dmg is enough:

...

As soon as you've opened a specific type, use Navigate > Go to File Member (_Alt+_Backslash) 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.

...

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:

Anchor
context-sensitive_navigation
context-sensitive_navigation

Context-Sensitive Navigation Between Symbols in Decompiled Code

...

For more details on these and other special-purpose commands available through the Navigate To drop-down menu, see ReSharper web help.

Note
titleKnown Issue

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.

Searching in Decompiled Code

...

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.

Reference Hierarchy

A derivative of Type Hierarchy introduced above, the Reference Hierarchy tool window shows which references the current assembly has, allowing you to track down all assembly dependencies, and additionally showing recursive dependencies with a glyph to the right of a reference entry.

If you click Referencing projects in the tool window’s toolbar, you can see which of the assemblies in your current assembly list reference the current selected assembly.
Image Added

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 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 You can even go as far as make downloading symbol files the default action for Go to declaration - to do that go to Tools > Options > Decompiler and select Allow downloading from remote locations.

...

titleKnown Issue

...

Image Added

Use the navigation mode drop-down in the menu bar to choose whether you only want dotPeek to decompile assemblies, or try find source code if possible.

Keyboard-Driven Navigation Between 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 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:

What's Next

The feature scope of As dotPeek 1.0 has been more or less defined, and before we release it later that year, we're looking for user feedback from EAP users - hopefully tons of feedback that would allow us to make the new decompiler bug-free and comfortable in daily use by .NET developers.successfully released in May 2012, we're now looking to come up with a bug fix release in coming months, and then proceed to implementing your feature requests.

Thanks for reading up until this point. ! We hope you've had much fun playing with dotPeek.

In case you were just looking around trying to find out if the tool was worth it, now it's probably the right time to download the latest and greatest dotPeek and see with your own eyes.