XAML Spy 3 Preview 1

Thursday, November 26, 2015

First Floor Software is excited to announce the immediate availability of the first public preview of XAML Spy 3. XAML Spy 3 is a major new release, with lots of new features and changes. Among others version 3 adds support for Android and iOS apps build with Xamarin technology. The new XAML Spy API enables you to automate your apps, and works great with REPLs, such as the ones that come with Roslyn and scriptcs.

Note: XAML Spy 3 Preview 1 is a pre-release version, the product is not finished, and you might run into an issue or two. There are a number of known bugs that are scheduled to be addressed in upcoming releases. Have an issue, comment or question? Please do share, your feedback is greatly appreciated.

Continue reading if you want to know all the details. In a hurry? Go see the quick start.

XAML Spy desktop app

Xamarin Android and iOS

One of the great new features of XAML Spy 3 is support for Android and iOS apps created with Xamarin technology. Both Android and iOS are first class citizens in the XAML Spy world, features previously available to XAML apps on windows only, are now available to Android and iOS as well. And as an added bonus, XAML Spy 3 provides a way to inspect the hierarchical structure of your Xamarin Forms objects at runtime.

Although iOS is fully supported, XAML Spy does require a Windows machine to run in. The remote debugging feature is used to enable inspection of an iOS app running in an emulator on a Mac, or on an actual iOS device.

XAML Spy API

XAML Spy 3 introduces an extensible API for automating and querying apps. The API consists of a set of .NET assemblies, providing direct access to runtime objects of any supported app. Want to export the visual tree of your app to a custom format? No problem. Need to backup the files in app local storage? XAML Spy has you covered. Do you need to query the UI automation tree and invoke automation patterns from within your own application? XAML Spy supports it all.

The XAML Spy API exposes various hierarchical object structures. These tree structures include the visual tree, local file storage, UI automation trees, and more. In order to locate particular objects in hierarchical structures, XAML Spy provides extensive search options, including regular expressions and xpath.

The following code snippet writes the entire contents of the visual tree to the output;

async void WriteVisualTreeAsync(RemoteApp app)
{
  // get visual tree
  var visualTree = app.GetVisualTree();

  // retrieve all visuals
  var visuals = await visualTree.GetDescendantsAsync();

  // print (properly indented)
  for(var i = 0; i < visuals.Count; i++) {
    var v = visuals[i];
    Console.WriteLine("{0:000} {1}{2}", i + 1, new string(' ', v.Depth), v);
  }
}

Please note, that the XAML Spy API is subject to change in the pre-release versions of XAML Spy 3. Documentation on the XAML Spy API is limited, there’s a blogpost coming soon with some additional details to get you started.

XAML Spy visualizer

Another new feature is the XAML Spy visualizer. The visualizer grabs image snapshots of selected visuals, and renders them in a isometric projection. More features will be added to the visualizer, which will enable you to create stunning artwork right from your running app. The visualizer works great on all platforms supported by XAML Spy.

XAML Spy 2 users

If you are a XAML Spy 2 user, you will notice that a number of features are missing. File system access to package contents and app storage is currently not available. This will be added in the near future. Exploring installed apps, and attaching to any running WPF app has been removed entirely. XAML Spy 3 is aiming at providing a great runtime inspection service for your own apps. Adding support for inspecting any app is considered for a future release.

Also, fairly late in the development process it was decided to replace the good old WinForms property grid with a true WPF alternative that scales well on high-DPI screens. The property grid is used in the Properties window for viewing and editing the properties of the selected object in the XAML Spy Explorer. Although the basic functionality works fine, there are some features missing, and the overall robustness can, and will be improved.

XAML Spy 2 and 3 cannot be installed side-by-side. When you install XAML Spy 3, any XAML Spy 2 installation will be removed from your system.

Getting started

The post introduces XAML Spy 3, which includes an exciting set of new features and extends support to new platforms. This is a pre-release, new features and fixes are scheduled to be released soon. Go download XAML Spy 3 and visit the quick start. Make sure to let us know what you think.