SyntaxEditor .NET Languages Add-on - C# Text Formatter

by Avatar Bill Henning (Actipro)
Wednesday, January 23, 2013 at 11:07am

BlogPostBanner

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:

CSharpFormatter1

When we format the document, the result is:

CSharpFormatter2

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.

TaskDownload TaskLiveDemo TaskBuyNow

Actipro's WPF Controls

Over 100 UI controls for building beautiful Windows Presentation Foundation desktop apps.

Learn More

Over 100 UI controls for building beautiful Windows Presentation Foundation desktop apps.

Includes editors, docking windows, MDI, property grids, charts, tree controls, ribbons, gauges, themes, and much more.

Learn More Download Free Trial

Add Comment

Please log in to a validated account to post comments.