private static bool IsAnyVariableAssigned(SeparatedSyntaxList <VariableDeclaratorSyntax> variables, SyntaxList <StatementSyntax> statements, int startIndex) { for (int i = startIndex; i < statements.Count; i++) { MarkLocalVariableAsConstWalker walker = MarkLocalVariableAsConstWalkerCache.Acquire(); walker.Visit(statements[i]); HashSet <string> assigned = MarkLocalVariableAsConstWalkerCache.GetAssignedAndRelease(walker); if (assigned != null) { foreach (VariableDeclaratorSyntax variable in variables) { if (assigned.Contains(variable.Identifier.ValueText)) { return(true); } } walker.Clear(); } } return(false); }
public static MarkLocalVariableAsConstWalker Acquire() { MarkLocalVariableAsConstWalker walker = _cachedInstance; if (walker != null) { _cachedInstance = null; walker.Clear(); return(walker); } return(new MarkLocalVariableAsConstWalker()); }