File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change 1- using System . Globalization ;
2-
31using Microsoft . CodeAnalysis ;
42using Microsoft . CodeAnalysis . CSharp ;
5- using Microsoft . CodeAnalysis . Formatting ;
63
74namespace Generators ;
85
96internal static class Formatting
107{
11- private static readonly AdhocWorkspace AdhocWorkspace = new ( ) ;
12-
13- internal static string FormatCode ( string code ) =>
14- Formatter . Format ( Parse ( code ) . NormalizeWhitespace ( ) , AdhocWorkspace )
15- . ToFullString ( ) + Environment . NewLine ;
8+ internal static string FormatCode ( string code ) =>
9+ Parse ( code ) . NormalizeWhitespace ( ) . AddTrailingNewLine ( ) . ToFullString ( ) ;
1610
1711 private static SyntaxNode Parse ( string code ) =>
1812 CSharpSyntaxTree . ParseText ( code ) . GetRoot ( ) ;
1913
20- internal static string FormatLiteral ( object obj ) =>
21- SymbolDisplay . FormatLiteral ( Convert . ToString ( obj , CultureInfo . InvariantCulture ) ! , obj is string ) ;
14+ private static SyntaxNode AddTrailingNewLine ( this SyntaxNode node ) =>
15+ node . WithTrailingTrivia ( SyntaxFactory . ElasticEndOfLine ( Environment . NewLine ) ) ;
2216}
You can’t perform that action at this time.
0 commit comments