Esempio n. 1
0
        public void Convert(string file)
        {
            var text       = File.ReadAllText(file);
            var syntaxTree = CSharpSyntaxTree.ParseText(text);
            var root       = syntaxTree.GetRoot();

            if (!_syntaxRewriter.IsValidFile(root as CompilationUnitSyntax))
            {
                return;
            }

            Logger.Log($"Starting Convertion of file {Path.GetFileNameWithoutExtension(file)}", ConsoleColor.Red);
            try
            {
                root = _syntaxRewriter.Visit(root);
            }
            catch (Exception exception)
            {
                Logger.Log($"Failed Convertion of file {Path.GetFileNameWithoutExtension(file)}",
                           ConsoleColor.Yellow);
            }

            var code = Prettify(root);

            File.WriteAllText(file, code);
        }
Esempio n. 2
0
        public void TestAssertStatements()
        {
            var text       = File.ReadAllText("From_Assert.txt");
            var syntaxTree = CSharpSyntaxTree.ParseText(text);
            var root       = syntaxTree.GetRoot();
            var rewriter   = new Rewritter();

            root = rewriter.Visit(root);
            Assert.Equal(File.ReadAllText("To_Assert.txt"), FileConverter.Prettify(root));
        }