Look inside code for free with dotPeek

When the source code is unavailable, give dotPeek a try. One developer explains the numerous things he likes about the tool and the one aspect he doesn't like.

Source code is great -- when you have it. But in this not-so-perfect world, organizations often lose or forget about source code once an application is rolled out (which is another reason for version control). It only becomes an issue when problems arise or changes are requested. I was presented with such a situation on a recent project.

The client had DLLs along with some configuration files. I calmed their fears and reached for my favorite compiler -- RedGate's .NET Reflector -- only to realize it is no longer free. I don't fault RedGate for wanting to make a profit, and I'm kind of happy the company went that route because it forced me to look elsewhere and discover dotPeek. I was soon wading through the code behind the code. (Note: You're viewing reverse engineered source code and not the true or original source code when working with a tool like dotPeek.)

More than a peek

The folks at JetBrains make dotPeek available as a free download. The current version of dotPeek is 1.1, and it is installed via an msi installer. Figure A shows the initial installation screen.

Figure A


The initial screen presented when installing dotPeek. (See an enlarged view of this image.)

Decompiling code via dotPeek is easy. You load the questionable file(s) -- it supports DLLs, EXEs, Windows 8 metadata files, and more -- and take a look at the decompiled source code. Figure B shows dotPeek opened the first time after installation. Figure C shows the options for opening and viewing files and directories. You can open a file from file system or the GAC as well as browse a directory.  

Figure B


The dotPeek tool opened the first time post installation. (See an enlarged view of this image.)

Figure C


Files are easily opened via the File menu.

With dotPeek installed and loaded, you can easily load compiled files for a closer look inside. Figure D shows the log4net.dll file loaded. The dotPeek interface lists the DLL name with references, resources, and namespaces listed underneath -- each is expandable. The namespace is expanded to reveal a list of its classes; double-click on the class name to look at its source code.

Figure E shows the context menu (right-click on name) available for classes. The Find Usages option in Figure E is useful because it allows you to explore when and where it is used within the decompiled source code. Another interesting feature just added to the current release is the Export To Project option (Figure C), which allows you to export generated source code to a Visual Studio project -- kind of completing or reversing the circle of life with a development project -- starting at decompilation and ending at an actual project. In addition, you can load symbols from a source server when available (for example, download from Microsoft).

Figure D


Working with a DLL in dotPeek. (See an enlarged view of the image.)

Figure E


There are a number of options for working with decompiled source. (See an enlarged view of the image.)

My impressions of dotPeek

Overall, I like the whole user experience of dotPeek. It has the look and feel of a development IDE, and those who are fans of ReSharper will love it. It loads quickly, and installation is a breeze (without any add-on hassles like Google toolbar). It offers simple navigation, and searching is only a click away. Find Usages is a great option to get a feel for how something may be used. The Go to options, Go to Declaration and Go to Implementation, are valuable when navigating unknown code.

On the downside, dotPeek only offers C# code. No matter what you decompile, it generates C#. While I am a C# developer who only occasionally dabbles in VB.NET, it seems like the VB.NET options could be useful (especially for VB.NET developers).

I am still in the honeymoon phase with dotPeek, so we'll see if my impression of the tool changes over time.

Rearranging the toolbox

While I have my top three development tools, there are a number of other items needed for the not-so-common tasks (like dealing with situations where the source code is unavailable), with dotPeek replacing .NET Reflector in my toolbox. I have used dotPeek on a couple projects, and it is easy to use and delivers everything I need. With a company like JetBrains behind it, I hope dotPeek continues to improve and maintains that attractive price tag.

If you're a fan of dotPeek or an alternative like .NET Reflector or even JustDecompile, let us know in the discussion.