Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 297
svick Avatar asked Apr 23 '12 23:04

svick


1 Answers

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.

like image 60
Kevin Pilch Avatar answered Nov 03 '22 12:11

Kevin Pilch