/// <summary> /// Checks that parenthesis are used correctly within an anonymous method. /// </summary> /// <param name="element">The parent element.</param> /// <param name="expression">The expression to check.</param> private void CheckAnonymousMethodParenthesis(Element element, AnonymousMethodExpression expression) { Param.AssertNotNull(element, "element"); Param.AssertNotNull(expression, "expression"); if (expression.ParameterList == null || expression.ParameterList.Count == 0) { // Check for parenthesis. for (Token token = expression.FindFirstChildToken(); token != null; token = token.FindNextSiblingToken()) { if (token.TokenType == TokenType.OpenCurlyBracket) { break; } else if (token.TokenType == TokenType.OpenParenthesis) { this.AddViolation(element, token.LineNumber, Rules.RemoveDelegateParenthesisWhenPossible); break; } } } }