public void TraverseAllExpressionsInASyntaxTreeUsingAWalker()
{
var tree = SyntaxTree.ParseText(@"
using System;
class Program
{
static void Main()
{
var i = 0.0;
i += 1 + 2L;
}
}");
var compilation = Compilation.Create("MyCompilation")
.AddReferences(MetadataReference.CreateAssemblyReference("mscorlib"))
.AddSyntaxTrees(tree);
var model = compilation.GetSemanticModel(tree);
var walker = new ExpressionWalker() { SemanticModel = model };
walker.Visit(tree.GetRoot());
Assert.AreEqual(@"
PredefinedTypeSyntax void has type void
IdentifierNameSyntax var has type double
LiteralExpressionSyntax 0.0 has type double
BinaryExpressionSyntax i += 1 + 2L has type double
IdentifierNameSyntax i has type double
BinaryExpressionSyntax 1 + 2L has type long
LiteralExpressionSyntax 1 has type int
LiteralExpressionSyntax 2L has type long", walker.Results.ToString());
}