The popular Snoop tool from Peter Blois has been out for a long time, and I use it almost every day in my WPF development. However, there has always been something missing: a native 64-bit version.
My coworker Joe and I finally decided that it was worth looking into building one. There were a few tweaks to the code itself to compile in 64-bit, and then some project build directory settings changes … but for the most part, it was pretty straight forward to make.
So with permission from Peter Blois, I have created and posted a true 64-bit version of Snoop. Mind you, this is version 1 of Snoop – haven’t yet tried to tackle version 2. I tend to use v1 in my everyday WPF dev – not having property editing in v2 is a showstopper for me.
Snoop works its magic by injecting a DLL into the process space of the app you are snooping. The problem with snooping a 64-bit app with the original snoop is that the injector DLL was always 32-bit, and when Snoop tries to load a 32-bit DLL into the 64-bit target application, you get the invalid image exception.
To allow snooping either a native 32 or 64-bit target app, I have built both a 32 and 64-bit version of Snoop and its supporting ManagedInjector DLL. So unfortunately, the only downside of this approach is that you have to keep both versions around, and use the one that’s right for the bit-level of the target app. (There has already been a request for ONE version of Snoop that will load the appropriate version of the injector DLL, so maybe someday I’ll dig deeper into that.)
While I was in there building Snoop, I decided to throw in a couple other tidbits – either changes to small things that have always bugged me, or small features that I wish the original had.
- “ShowAllProperites” ToggleButton is off by default. I find that more times than not, the properties I want to look at are in the “defaults” set, so this keeps the properties list much shorter.
- Use a 2nd monitor if present. My everyday use of Snoop is that I choose the app to snoop, the SnoopUI comes up and I move it over to my 2nd monitor. I added some code to do this automatically if there’s a 2nd monitor present.
- Scroll to Selection – when you snoop on an element in your app with CTRL+SHIFT pressed and the element is found in the tree, the selected item is automatically scrolled into view.
- Custom property filter ComboBox. In addition to filtering the properties list by text, there is now a ComboBox next it that allows to filter the properties by functionality. For example, if you choose “Layout”, you see only properties like Width, Height, Margin, etc. that have to do with layout. Choose ItemsControl for things like ItemsSource, SelectedItem, etc. This screenshot shows snooping on a ListBox with the custom property filter set to ItemsControl to quickly see everything related to ItemsControls and Selectors.
- Indexer delve. This is the small TextBox to the right of the Custom Property ComboBox. If the current property type (that you’ve delved into) is an ICollection, you can type an index value in the TextBox and delve into that item in the collection. The indexer delve plays along with all the other delves, so you can pop context to get back to where you came from.
Here is the properties window after delving into a collection data type (ListBox.ItemsSource which is ObservableCollection<Person> in this case).
After entering a “1” in the Indexer Delve field (updates on text change), you see the Person object at index 1 in the above list.
There you have it. I hope these enhancements, along with a native 64-bit version are helpful in your WPF development!