ReSharper 6 Bundles Decompiler, Free Standalone Tool to Follow

What’s going on here?

We’ve recently hinted on a new kind of functionality that’s being developed within ReSharper 6 EAP. Those of you who saw that post got the message right: ReSharper 6 will feature a decompiler. More than that, it is already available in ReSharper 6 EAP builds that you can download and try.

As if it isn’t enough, we have more great news: make sure to read on to the end of this post.

How do I invoke the decompiler in ReSharper?

There are several ways you can navigate to decompiled code in ReSharper:

You can navigate to a decompiled library symbol right from its usage in the source code. This should be done via ReSharper’s Navigate To feature. To invoke Navigate To, press Alt+` and select Decompiled sources:

You can jump to the declaration of a specific library type from anywhere within Visual Studio using ReSharper’s Go to Type menu (Ctrl+T in Visual Studio layout). You can even go further by jumping to a specific library method or property using Go to Symbol (Shift+Alt+T).

If you prefer browsing library types using the Object Browser, you can invoke Navigate To Decompiled Sources right from there:

Will common ReSharper features be available with decompiled code?

Well naturally, you can’t refactor decompiled libraries, generate new code in them, or run code inspections (though it would be fun in some cases).

However, most navigation features that ReSharper normally provides in source code are equally available in decompiled code. For example, you can:

Navigate to declarations and implementations:

Search for usages, inheritors, and base symbols:

Explore a decompiled type with File Structure:

View type hierarchy or even see incoming calls to library symbols from your source code:

Highlight usages of symbols:

Where can I configure the behavior of ReSharper decompiler?

Decompiler is configured in the same group as other features from the External Sources feature group, namely ReSharper | Options | Tools | External Sources | Decompiled Sources.

If you’re trying to get ReSharper show decompiled code but it’s failing to do so, make sure that Decompiled sources is selected as an external sources data provider in ReSharper | Options | Tools | External Sources. By the way, if Decompiled sources is at the top of the list, you can navigate to decompiled code with Go to Declaration (F12 or Ctrl+click).

How sophisticated is ReSharper decompiler?

Let’s just say, ReSharper decompiler is sophisticated enough to correctly infer lambda expressions and yield returns. Some things are not yet supported, for instance auto-properties, but that’s only a question of time.

Why has ReSharper moved in this direction?

Source code management has been in focus of the developer community for ages. We have lots of source code storage systems with histories and branches, distributed and personal, tools ecosystem, and what not. However, many applications are quite large today, and handling them in source form tends to get more and more complicated. Setting up binary reusable libraries even inside a single business entity can be a very painful thing to perform.

ReSharper started assisting developers with this in version 5, by introducing navigation to and within external sources. The External Sources feature brings code available through information in PDB (Program DataBase) files straight into Visual Studio editor. For example, when Microsoft releases another library in Reference Source form, they publish PDB files having links to their Source Servers. ReSharper can parse this information, download source files and display them for a developer to explore.

That’s cool, but what about home-built libraries? What if your company doesn’t have Source Server infrastructure in place and doesn’t want to invest into getting one? How to get seamless integration with source code and binary libraries referenced in projects?

That’s exactly the task that the decompiler in ReSharper 6 is going to solve. Adding to the Source Server support, the new ReSharper reconstructs source code from compiled assemblies and enables all code reading features in such files.

Say, one department in your company builds a framework, and another department uses it to create an end-user application. You can reference assemblies for the framework and avoid bloating your workspace with files and projects that you don’t really need. However, when required, you can easily jump into decompiled sources and explore internals. Should you need further details — comments, real variable names, exact code — you can go and check out sources for that project, but in fact it is quite rarely needed.

Another point is the emerging market of packaging solutions: NuGet and OpenWrap to name a few. Packages (or wraps) contain binaries and tools, but not source code. However, many of them are open source and it is perfectly legal to look for sources, even reconstructed. We would like to talk to providers of packaging solutions and ask them to include information about source code locations into package descriptors, so that everybody can get the exact source code for a specific version of binaries.

Will the decompiler be only available as a part of ReSharper?

At this point you are probably asking yourself “Well, but what about a standalone solution? I don’t need ReSharper!”.

Bad news is you should only not need ReSharper if you’re not doing .NET development.

Good news is that we’re preparing a standalone binary-as-a-source application, i.e. a decompiler + assembly browser to explore whatever .NET compiled code is legal to explore. We don’t have any specific date for release, but it’s going to be released this year, and it’s going to be free of charge. And by saying “free”, we actually mean “free”.

“We would like to talk to providers of packaging solutions and ask them to include information about source code locations into package descriptors, so that everybody can get the exact source code for a specific version of binaries.”

Yes! This kind of metadata could be _extremely_ useful. And not only for navigation — just imagine finding a bug in github library and doing fork+submodule directly from VS to fix it.

As for the point about embedding the source location into packaging solution – that would be an absolute killer feature, totally the best! Only today I wanted to avoid having to use ILMerge in my build and went to download NLog’s source. I was going to use Stovell’s Tape to elegantly embed it into the code I was working on. Trouble was, I was not sure of how to get the source for the version I was using. Now, wouldn’t it be just great to be able to get that from the package?

“And by saying “free”, we actually mean “free”.”
Not that I don’t believe you, but wasn’t that the almost exact same statement issued by RedGate when they bought Reflector?
I don’t really care for a free tool, as I am a happy ReSharper user, but a lot of developers will. If parts of ReSharper is going to be available as a free tool, I guess I’m paying for the development of that free tool through my ReSharper license (which I happily will do).
RedGate should have chosen the same model for Reflector (may it rest in peace).

In the past, JetBrains offered another free tool, the ReSharper unit-test runner. That product was quietly killed off a few years ago. It had to integrate with Visual Studio, which was a moving target — a standalone decompiler likely won’t be as big a drain on your resources to maintain. Still, it’s something to think about.

As you get closer to releasing a free decompiler, it would be good to hear what level of commitment you’re able to put behind the free version. If you can’t promise much, that’s fine by me — but I want to know what to expect. RedGate never respected their users enough to communicate with them. I’ll be expecting more from you guys.

@Sergey – Done. When I looked closer when filing the bug report, it turns out that it could decompile one class, though it was gibberish, but couldn’t decompile another. Anyway, it’s all in the bug report.

@Joe
At this point, we’re not committing to anything except that the tool is going to come out, and it’s going to be free. Let’s see how it goes. However, since the core is shared with ReSharper, we’re not expecting the free tool to lag behind.

What a move! Love you guys. Of course, I love Red Gate’s tools too, but their recent move on Refactor, based on their earlier promise (or at least implied promise), really ticks me off. Nice job. This will likely lead to the death of a great, long used and perhaps the most widely used .NET tool, Refactor.

FYI – If you have Team Foundation Server 2010, you can get the proper Symbol Server & Source Server setup for internal use in your organization. This really helps with having shared libraries that are used internally by different teams.

The examples of looking for all classes derived from say, “Exception” bring up the need to have some checkbox or something to quickly enable/disbled decompiled sources (in case I just want my own exceptions, not every exception in the framework!). Will there be such a thing built into the usual Find Usages/Go to Implementors/etc etc.. interfaces?

@Omer
First of all, you don’t actually need a decompiler to find implementations of .NET Framework types: you could as well find them from metadata, for example.
We’re not planning a “hot switch” to turn decompiled sources on/off directly from the UI of Find Usages, Go to Implementation and other navigation features but what you can do in this case is when you search for implementations of System.Exception, you can drop search results into the Find Results window by pressing “+” or clicking the “Show in Find Results” button in the pop-up, and then group search results in a way that lets you easily distinguish between implementations in libraries and in source code. I’d say grouping by “Project and Type” is the best option for this task.

Too bad since Reflector Pro makes it possible to debug into decompiled code. However, as a software developer myself I understand you can’t implement everything all at once. Put it in 6.1 and I will be happy! 😉

This sounds like excellent news…the community really needs an alternative to Reflector. I have used Reflector for many, many years…almost since Lutz first released it, and I am very upset that RedGate reneged on their PROMISE to the .NET community to keep it free. I don’t see any reason why RedGate needs to charge for the tool, as they make plenty of money off the rest of their products, and Reflector doesn’t need much work (if anything outside of updates for new CLR/Framework versions).

I’ve downloaded the ReSharper 6 EAP and given it a try. While it is great to be able to see code when a .PDB is available, the results when a .PDB is NOT available are actually very disappointing. The “decompilation” does nothing more than what was already possible with Visual Studio…all you get is the interface of a class, NOT its implementation. This is in no way representative of Reflector’s functionality, which quite literally DECOMPILES code and presents you with full implementation (even if the variable names are not the same.) This is no better than browsing the class from the Object Browser. Here is an example of ‘decompiling’ the log4net LogManager class:

The implementation of LogManager is conspicuously absent…a very disappointing result. I SINCERELY hope that this new feature of ReSharper 6 does not stop at only providing the above class “interface”, and when finally release will actually DECOMPILE the full implementation. If the above is all we get without a .PDB file, then I find it a little shameful that you are hyping this new ReSharper 6 feature as an alternative to Reflector. While I truly, TRULY loath giving RedGate any money for a tool that has been free for the better part of a decade, and which they promised to keep free, ReSharper 6 is not actually an alternative to it if .PDB files are required for full implementation “decompilation”.

Don’t piss off your own community the same way RedGate pissed off the entire .NET community…be HONEST about your intentions, and don’t make people waste a lot of money getting a tool that won’t actually service their needs. Don’t debase the meaning of decompilation, as what you are currently providing is in no way, shape, or form actual “decompilation” of code…it is either simply the presentation of metadata (which is already available in other forms, such as via Object Browser), or the extraction of existing information from a .PDB (which is convenient, but not really solving the problem space that Reflector currently solves.)

That looks good! I can’t tell from the video if you had a .PDB or not. Was that code actually decompiled from an assembly without PDB info? If so, SUPERB, and I will truly be looking forward to ReSharper 6!

I am actually a bit confused. I have installed ReSharper 6.0.2102.59, as indicated below. I’ve tried to decompile numerous third-party libraries, but all I get is the interface. Implementations are not generated when I use the “Decompiled Sources” option. Am I running into a bug?

Turns out it was the way I was accessing the feature. Decompilation DOES work (woot!!), but you have to use the Alt-` hotkey to use the ReSharper 6 “Navigate” menu’s “Decompile Sources” command for it to fully decompile the implementation. Simply right-clicking a type, using the “Navigate To” sub menu, and clicking “Decompile Sources” only generates the interface. (Seems like a bug to me…perhaps the discrepancy is by design…)

THANK YOU, JetBrains! Can’t THANK YOU enough for providing a high quality alternative to Reflector! RedGate can eat their betrayal and reap the justified wrath of a now-still-satisfied .NET community. 😉

R#6 is freezes Visual Studio 2010 VERY often.. Hope you understand that we dont need that javascript support if IDE will freeze..It just slows me down, so that the main slogan of this PRODUCTIVITY plugin is becoming just strange. Hope you will work on performance before even first beta release.
Still thank you for a great tool.

@Dima
We’re definitely working on performance, and the closer a release the more we do that.
Please let me know if you’re willing to profile VS with ReSharper to find out the source of the freeze problem.

@lacithetemplar
I’m using VS2010 Professional. Will investigate if that’s the problem but I guess rather it’s some unexpected change in the set of items in the “Navigate to” menu.
Does it work if you navigate to a library symbol using “Go to declaration” or, say, “Go to type”?

I don’t know, when I use “Go to declaration” or “Go to type”, it starts to download symbol pdb file. But in one case, when I used “Go to declaration”, it show me warning that I’m going to use decompilation.

@lacithetemplar
That’s ok. ReSharper uses symbol files as a priority way of rendering unavailable sources.
If you deselect “Use debug information for navigation” in ReSharper > Options > Tools > External sources, ReSharper should choose to decompile when there’s a choice between decompiling and downloading symbol files.
However, we definitely need to take a second look at UI options in both “Navigate to” and Options. Thanks for your feedback!

Hi:
We are evaluating the nightly builds for EAP 6. However, people who have VS 2010 (and CLR4) can run/install the nightly builds fine into VS2010. However, folks with VS2008 receive various errors when trying to launch. Will EAP 6 be available in VS 2008? Are these errors just a product of being nightly builds?
Thanx

@DanF
ReSharper 6 should work smoothly both in VS2008 and VS2010.
We’d love to know more details about the errors that your colleagues are facing.
Our QA will contact you for additional info that we need to reproduce these errors.
Thanks for reporting this!

dotPeek early builds are horrendously slow and clunky. I recently found the open source ILSpy tool and it is way superior feature and speed wise, including great OOB XAML support. Keep up the good work though, i really have high hopes for debugging externally libraries, etc right from with R#

Decompilation without being able to debug into the decompiled sources is not enough for my work. Sure I can see the code with the issue(s) but if I cannot debug then I cannot isolate *where* those issue(s) are. I really hope Jetbrains gets this feature into R#.