Make Comparing Build Process Templates Easier With XamlClean 1.0

Comparing XML is troublesome at the best of times but comparing Workflow Foundation XAML files is even harder because they contain both logic and designer markup. The designer markup stores information such as the expanded/collapsed state of each workflow activity, its size, and physical location on disk and has no effect on the resulting workflow but adds significant noise when comparing.

In this comparison you can see from the bar on the left that there are a significant number of changes between these two files but if you look at the circled lines on the right you’ll see that the only difference in these lines is the hint size:

image

If we remove all of the designer markup you’ll see that we get a much cleaner comparison that only shows the meaningful differences between the files:

image

So what can safely be removed? From my experimentation it appears that attributes and elements in the following namespaces can safely be removed from a Workflow Foundation XAML file:

Obviously doing this manually is time consuming and error prone so I’ve written a console application called XamlClean which can take a Workflow Foundation XAML file, remove the designer markup from it, and write it out to a new file. The usage is as follows:

XamlClean originalFile cleanFile

For example:

XamlClean DefaultTemplate.xaml DefaultTemplateClean.xaml

NOTE: XamlClean is provided “AS IS” with no warranties, and confer no rights. Backup your XAML files before overwriting them with the outputs from XamlClean to avoid data loss.