The dotPeek decompiler tool was initially introduced by Microsoft. It is a free-of-charge, standalone tool and decompiler for .NET assemblies. It converts .NET assemblies into equivalent C# code and optionally shows the underlying IL code. A dotPeek application can decompile different kinds of assembly files, such as Libraries (.dll), Executable files (.exe), Windows 8 metadata files (.winmd), Archives (.zip), NuGet packages (.nupkg), and Microsoft Visual Studio Extensions packages (.vsix).
Developers can use dotPeek to decompile .NET assemblies based on .NET Framework into the equivalent C# code.
Read: Best IDEs for .NET Developers
What are the Features of .NET Decompiler?
The following is a list of features developers can explore for the dotPeek .NET decompiler tool from JetBrains.
View Source Code if Available
DotPeek can generate PDB files. Decompiled .NET code generated by dotPeek can be used to match an assembly to its source code. This tool allows developers to download code from a remote server location, as shown in Figure 1.
Figure 1: Navigation and decompiler options
Show or Hide Compiler-generated .NET Code
As a developer, we may want to show or hide the compiler-generated code created by this .NET decompiler. We may choose to show certain compiler transformations, thus making a code structure that dotPeek displays. This feature helps to see how the compiler deals with lambdas, closures, and auto-properties, among other things.
Explore Running Processes
The Process Explorer window of the code decompiler tool shows the list of all currently running processes. A developer can explore these modules and decompile all the .NET assemblies. A developer can choose to show or hide native processes and modules, or turn on the process hierarchy view. You also can filter the list to find a module or process that you are looking for (see Figure 2).
Figure 2: Process Explorer
Read: Debugging Tools for C#
View IL Code in a Separate View
A developer can navigate to IL code from any point of decompiled C# code. That feature is required to dive deeper inside the source code. The dotPeek tool provides an easy way to show IL code in a separate tool window that is synchronized with the main code viewer.
View IL Code as Comments to Decompiled C#
A developer also can opt to show IL code as comments to decompiled C# code. DotPeek can display IL code both for decompiled code and for source code reproduced from symbol files.
Preferred Color Theme
DotPeek supports a number of color themes, such as the Visual Studio editor. Developers can select a Blue or Dark theme, or choose to synchronize your color scheme preference with Visual Studio settings.
How to Use Symbols in dotPeek
From dotPeek, you can find all usages of a symbol (such as a method or property) across all loaded assemblies. The usages will be displayed in the Find Results tool window where you can group them, navigate between them, and open them in the code view area.
There’s also Find Usages Advanced, which is a more detailed version of Find Usages that helps you fine-tune search criteria by limiting the scope of the search and other details.
Highlight Usages in a Code Viewer
DotPeek automatically highlights all visible usages of the symbol under a caret, very similar to how recent versions of Visual Studio do it. This helps improve the readability of decompiled code.
Jump to Any Code
DotPeek provides two features to quickly jump to specific code:
- Go to Symbol: Helps navigate to a specific symbol declaration, which could be a type, method, field, or property.
- Go to Everything: Allows searching for an assembly, namespace, type, member, or a recently opened file.
Bookmarking in DotPeek
To go back to specific lines of decompiled code later, feel free to set bookmarks.
You can create up to 10 numbered bookmarks and unlimited unnumbered bookmarks. The full list of bookmarked locations is displayed in a single pop-up window.
Navigate in the Code Decompiler
DotPeek supports Navigate contextually and by class hierarchies. Go to Declaration takes you from a usage of any symbol to its declaration. Go to Implementation helps navigate to end implementations of types and type members, bypassing intermediate inheritance steps in the inheritance chain.
Explore Inheritance Chains
DotPeek will show you all types that are inherited from the selected type, as well as types that it inherits itself.
Manage Assembly Lists in .NET
A developer can work with different assembly lists, depending on context. You can save and re-open assembly lists, and clear the current list if you no longer need it.
Explore Assembly Contents
The Assembly Explorer shows what kind of references, resources, and code a particular assembly has, all the way from namespaces to type members.
Explore Assembly Metadata
DotPeek helps you explore assembly metadata and dig through all items (tables, blobs, strings, and so forth) inside it. Under the Metadata node, you can explore values of blob items, PE file headers, and usages of metadata table items.
Conclusion to DotPeek .NET Code Decompiler Tutorial
I hope this article about dotPeek has given you a basic understanding of how to use the .NET decompiler tool.