There’s already been a change to Roslyn that made my last bit of code obsolete. CustomWorkspace no longer requires a string in the constructor and is just:
new CustomWorkspace()
I found out how to change the formatting on the output. We can do this:
CustomWorkspace cw = new CustomWorkspace(); OptionSet options = cw.GetOptions(); options = options.WithChangedOption( CSharpFormattingOptions.OpenBracesInNewLineForMethods, false ); options = options.WithChangedOption( CSharpFormattingOptions.OpenBracesInNewLineForTypes, false ); SyntaxNode formattedNode = Formatter.Format( cu, cw, options );
With this change, our output code is now:
using System; using System.Generic; namespace MyNamespace { private partial class MyClass { } }