I am using the SyntaxWalker to go through a tree and in the function below I realize I need to insert a statement before the one I am working on.
Public Overrides Function VisitDeclarationExpression(ByVal Node As CSS.DeclarationExpressionSyntax) As VisualBasicSyntaxNode
Dim VariableDesignation As CSS.SingleVariableDesignationSyntax = CType(Node.Designation, CSS.SingleVariableDesignationSyntax)
Dim name As NameColonEqualsSyntax = Nothing
Dim value As ExpressionSyntax = CType(VariableDesignation.Accept(Me), ExpressionSyntax)
' Need to Insert Dim before the statement that contains this SimpleArgument
Return SyntaxFactory.SimpleArgument(name, value)
End Function
I need to declare "name = Nothing" so I can use name in a TryGetValue(name). In C# it would be easy using
return v.TryGetValue(out var name)
but in VB I need two statements
Dim name As Object = Nothing
Return v.TryGetValue(name)
How do I insert the Dim above the statement I am in the middle of walking?