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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With