Ejemplo n.º 1
0
        static void Transform(string filePath, CSharpSyntaxRewriter[] rewriters)
        {
            Console.Write($"  {filePath}");

            SourceText            text    = SourceText.From(File.ReadAllText(filePath));
            SyntaxTree            tree    = CSharpSyntaxTree.ParseText(text);
            CompilationUnitSyntax root    = tree.GetCompilationUnitRoot();
            CompilationUnitSyntax current = root;

            foreach (CSharpSyntaxRewriter rewriter in rewriters)
            {
                current = (CompilationUnitSyntax)current.Accept(rewriter);
            }

            if (!current.Equals(root))
            {
                Console.WriteLine("*");
                File.WriteAllText(filePath, current.ToFullString());
            }
            else
            {
                Console.WriteLine();
            }
        }