public static bool HasParenthesesOnSameLine(this ForEachStatementSyntax forEachStatement) { if (forEachStatement == null) { throw new ArgumentNullException(nameof(forEachStatement)); } TextSpan textSpan = TextSpan.FromBounds( forEachStatement.OpenParenToken.Span.Start, forEachStatement.CloseParenToken.Span.End); return(!forEachStatement .DescendantTrivia(textSpan) .ContainsEndOfLine()); }