Skip to content

Instantly share code, notes, and snippets.

@rogeralsing
Created July 9, 2015 08:50
Show Gist options
  • Save rogeralsing/2744ce7b83a822080a3a to your computer and use it in GitHub Desktop.
Save rogeralsing/2744ce7b83a822080a3a to your computer and use it in GitHub Desktop.
update all nodes with roslyn?
//other junk
....
....
Dictionary<StatementSyntax,StatementSyntax> lookup = new Dictionary<StatementSyntax,StatementSyntax>();
if (returnActions.Count > 0)
{
foreach(var ifStatement in returnActions)
{
var mainCall = ifStatement.GetPrevious() as ExpressionStatementSyntax;
var newIfStatement = ifStatement.WithCondition(mainCall.Expression.WithoutTrivia());
lookup[mainCall] = null;
lookup[ifStatement] = newIfStatement;
}
root = root.ReplaceNodes(lookup.Keys, (s, d) => lookup[s]);
}
}
return root.ToFullString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment