Frage

Is it possible to set up formatting options for C# code generation without spaces and line breaks?

I mean the transformation of the following code:

using System;
class Test
{
    public void Main(string[] args)
    {
         Console.WriteLine("Hello, World");
    }
}

to this code:

using System;class Test{public void Main(string[] args){Console.WriteLine("Hello, World");}}

I am trying to do it with empty options, but it is does not work.

SyntaxTree syntaxTree;
CSharpFormattingOptions emptyOptions = FormattingOptionsFactory.CreateEmpty();
sting CSharpCode = syntaxTree.GetText(emptyOptions);
War es hilfreich?

Lösung

I created project for C# code minification based on NRefactory: CSharpMinifier

Code for whitespace removing located in this file: Minifier.cs

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top