Esempio n. 1
0
        private static string GetTranslation(string source)
        {
            // Getting the AST node
            CSharpSyntaxTree tree = ASTExtractor.Extract(source);

            SyntaxNode             node = new NodeLocator(tree).LocateLast(typeof(ClassDeclarationSyntax));
            ClassDeclarationSyntax classDeclarationNode = node as ClassDeclarationSyntax;

            // Creating the walker
            var astWalker = ClassASTWalker.Create(classDeclarationNode);

            // Getting the translation unit
            ITranslationUnit translationUnit = astWalker.Walk();

            return(translationUnit.Translate());
        }
Esempio n. 2
0
        public string RenderSimpleEmptyClass()
        {
            var    sourceInfo = SourceGenerator.Generate(SourceOptions.None);
            string source     = sourceInfo.Key;

            // Getting the AST node
            CSharpSyntaxTree       tree = ASTExtractor.Extract(source);
            SyntaxNode             node = new NodeLocator(tree).LocateLast(typeof(ClassDeclarationSyntax));
            ClassDeclarationSyntax classDeclarationNode = node as ClassDeclarationSyntax;

            // Creating the walker
            var astWalker = ClassASTWalker.Create(classDeclarationNode);

            // Getting the translation unit
            ITranslationUnit translationUnit = astWalker.Walk();

            return(translationUnit.Translate());
        }
Esempio n. 3
0
 public static MockedClassASTWalker Create(CSharpSyntaxNode node)
 {
     return(new MockedClassASTWalker(ClassASTWalker.Create(node)));
 }