Today I'd like to show off a new feature coming to the WPF and Silverlight .NET Languages Add-on: C# text formatting!
Text formatters beautify code, making it more readable by adjusting whitespace.
C# Text Formatting Example
Let's see an example. Here is some messy C# code loaded up in SyntaxEditor:
When we format the document, the result is:
That's a lot more readable! The text formatter also has an option for whether open curly braces appear on the same or next line.
Intelligent Modifications
The best part about this feature is that SyntaxEditor only adjusts ranges it needs to. It doesn't do a mass replace of the whole document. For instance on line 7, it does a tweak of the leading whitespace on the line but doesn't touch the rest of the line.
All of the various text change operations involved in the formatting are merged into a single atomic text change that is added as a single undo stack item. This makes it easy for the end user to quickly undo any formatting changes that were made.
Summary
These features will be in the 2013.1 versions of the WPF and Silverlight SyntaxEditor .NET Languages Add-on.