bling.github.io

This blog has relocated to bling.github.io.

Friday, May 20, 2011

Taking a Quick Look at .NET Decompilers

Decompilers in the .NET space has changed a lot since the announcement from Red Gate that they were going to start charging for Reflector, which was the defacto most important/useful tool in any developer’s tool belt.

This blog post will be a quick overview to take a look at all the new contenders that have cropped up in the .NET space to see if any of them can dethrone Reflector as the decompiler of choice.  This is only taking a look at the tools as a stand alone product and excludes any IDE integration.

To start, let’s take a look at Reflector.

Red Gate Reflector (7.1.0.143)

Having been around for years, Reflector is a rock solid product that sets the standard for everything else.  It has a simple straight forward interface and has a large following with many 3rd party addins.  It has a search which lets you find types, and an analyzer which shows you incoming and outgoing calls for any method.  It also has the most options for decompiling, giving choices from C# to VB and even Delphi.

Another useful feature is being able change the framework from .NET to WPF to Silverlight.

As of this version it looks like they added tabs, but it for me it only used one at a time…perhaps a limitation of the trial version.

ILSpy (1.0.0.822)

This open source offering at this point looks the same as Reflector did just before Red Gate took over.  It has all the necessities, including search and analyze.  It can only view one thing at a time, and doesn’t have support for addins yet.  However, progress on this project is blazing fast and it’s only a matter of time before it reaches feature parity with the rest.

JustDecompile Beta (2011.1.516.2)

First impression was, damn, this is a nice pretty WPF app.  Onwards, it has a predefined assembly list of .NET2, 4, and Silverlight, which is nice.  What’s nicer is that you can save a predefined list for use later, a feature that’s absent from the others.  It has search by type, and search by symbol, however, the search is noticeably slower than everything else I tried.  Also, the actual decompiling is much slower than the rest as well.  Like ILSpy, it can only view one thing at a time.

Decompiling to C# and VB are supported, but no IL yet.

dotPeek EAP (1.0.0.1219)

I tried an EAP build and I was blown away.  I may be biased because I’m a Resharper user, but having almost all of the keyboard shortcuts I have in my muscle memory work in dotPeek was a welcome surprise.  The keyboard navigation makes dotPeek by far the best tool for navigating.  While the others have searches, they only do so at the type level.  With dotPeek (just like Resharper), you can search by type, current type, and even private members.  Inheritance searching like finding implementations, etc., all of that works.  Simply amazing.  Oh, and it also has full tab support.

It was also fast as well, which was a surprise considering it’s searching through the entire framework.  Searching all symbols for “m_” brought a list up in 2 seconds, and subsequent keystrokes narrowing it down occurred within half a second.

The downside?  No support for decompiling to IL, and lambdas aren’t fully supported yet.  I’m sure these will be done by the time it’s released.

Conclusion

I guess the most important thing I should be looking at is the actual decompiler, rather than the bells and whistles. If that’s what I looked at, this would be a pretty boring post because only Reflector is able to decompile everything out there.

JustDecompile failed to decompile some of the assemblies I threw it at it.  dotPeek at this stage doesn’t have good lambda support (if at all).  ILSpy decompiles very well at this point and I’d have to go out of my way to find an example where Reflector does it better than ILSpy.

In conclusion, I love dotPeek just because of the awesomeness that is Resharper keyboard shortcuts.  For everything else, ILSpy does the job.

I’m actually pretty thankful that Red Gate decided to charge money for Reflector, because that inspired so much competition and we already have 3 viable replacements, all of which are free -- something that wouldn’t have happened if Reflector remained free.

Sunday, May 8, 2011

Simple App to Preview Fonts

I spent a good few hours yesterday trying out a new programming font.  It’s a personal thing.  I like switch fonts every couple weeks, and while Consolas is an excellent font and I have nothing against it, to me, it’s….too simple.  For most people, the defaults are just fine, and they can’t be bothered to try another font.  But for me, I want my font to speak to me a little.  But enough of that voodoo magic stuff.

The problem with sites that survey fonts is that it’s hard to compare quickly one with the next.  For example, this excellent article comparing 42 fonts on CodeProject is one of the most comprehensive surveys, but even with that I can’t really tell if I prefer one font over another.  So, since I’m going to be doing this from time to time, I wrote a quick WPF app.

The XAML is simple, only this:

<StackPanel Orientation="Horizontal">
  <ListBox IsSynchronizedWithCurrentItem="True" 
           SelectedItem="{Binding CurrentFont}"
           ItemsSource="{Binding Fonts}" />
  <TextBlock FontFamily='{Binding CurrentFont}' FontSize="14" Text="{Binding Code}" />
</StackPanel>

And the code is just as simple, only this:

public class ViewModel
{
  public static readonly DependencyProperty CurrentFontProperty = DependencyProperty.Register("CurrentFont", typeof(FontFamily), typeof(ViewModel));
  public FontFamily CurrentFont
  {
    get { return (FontFamily)GetValue(CurrentFontProperty); }
    set { SetValue(CurrentFontProperty, value); }
  }
  public List<FontFamily> Fonts { get; private set; }
  public string Code { get { return "insert what you want to see"; } }
  public ViewModel()
  {
    Fonts = new List<FontFamily>();
    Fonts.AddRange(System.Windows.Media.Fonts.SystemFontFamilies);
  }
}

And with this, you get something like this.  The coding sample is taken from Coding Horror.

image

Yep, my current chosen font is BPMono.

For the lazy, here’s the project on GitHub.