svick
svick

Reputation: 244837

Extensible formatting in Roslyn?

I have found the code formatting present in the Roslyn CTP quite lacking. But Dustin Campbell mentioned in his talk (around 42:00 mark) that:

The actual formatting engine is also extensible. There's a rules engine there so you can add formatting rules and do custom stuff if you want to, as well.

But when looking at the actual code, I have found only the Format(SyntaxNode) extension method that internally uses an internal class SyntaxFormatter.

My question is: where is the extensibility? Is it present in the Roslyn CTP?

Upvotes: 7

Views: 753

Answers (1)

Kevin Pilch
Kevin Pilch

Reputation: 11615

With the release of the Roslyn June 2012 CTP, this extensibility is now available. To invoke formatting, look at the Format extension method that is in Roslyn.Services.dll (don't forget to add a using Roslyn.Services;.

To expose your own formatting rules, try implementing the Roslyn.Services.Formatting.IFormattingRule interface. Unfortunately, we don't have a sample of this yet, but feel free to ask questions for any issues you run into.

Upvotes: 4

Related Questions