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 { } }
Hi,
I’m having a problem with:
CustomWorkspace cw = new CustomWorkspace();
It doesn’t find it.
Thanks
It’s been a while (the post is 7 years old), but I think they renamed the workspace. Some googling suggests it might be MSBuildWorkspace or maybe AdHocWorkspace.