public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) { var awaitExpr = null as ExpressionSyntax; var extraStatement = null as StatementSyntax; if (node.Declaration.Variables.Count == 1) { var variable = node .Declaration .Variables[0]; var value = variable ?.Initializer ?.Value; if (node.Declaration.Type.ToString() == "await") { //case: await signal; awaitExpr = CSharp.IdentifierName(variable.Identifier); } else if (value != null && value is AwaitExpressionSyntax) { //case: var a = await b(); extraStatement = CSharp .LocalDeclarationStatement(CSharp.VariableDeclaration( node.Declaration.Type, CSharp.SeparatedList(new[] { CSharp.VariableDeclarator(variable.Identifier) }))); awaitExpr = CSharp.AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, CSharp.IdentifierName(variable.Identifier), (value as AwaitExpressionSyntax) .Expression); } } if (awaitExpr != null) { var result = VisitExpressionStatement(Templates .AwaitExpr .Get <ExpressionStatementSyntax>(awaitExpr)) as StatementSyntax; if (extraStatement != null) { var block = Roslyn.TrackNode(CSharp.Block( extraStatement, result)); var document = _scope.GetDocument(); document.change(node.Parent, Roslyn.ExplodeBlock(block)); return(block); } return(result); } return(base.VisitLocalDeclarationStatement(node)); }