Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; var code = "int x = 1 + 2;"; var tree = CSharpSyntaxTree.ParseText(code); var root = tree.GetRoot(); // ASTのルートノードをたどる foreach (var node in root.DescendantNodes()) { Console.WriteLine($"{node.Kind()}: {node}"); }