Title | Query clause should begin on new line when previous clause spans multiple lines |
TypeName | SA110xQueryClauses |
CheckId | SA1104 |
Category | Readability Rules |
A clause within a C# query expression begins on the same line as the previous clause, when the previous clause spans across multiple lines.
A violation of this rule occurs when a query clause spans across multiple lines, and the next clause begins on the same line as the end of the previous clause. For example:
var elementNames =
from element in GetElements
(
12,
45
) select element.Name;
The query clauses can correctly be written as:
var elementNames =
from element in GetElements
(
12,
45
)
select element.Name;
To fix a violation of this rule, move the clause down to start on the next line.
#pragma warning disable SA1104 // Query clause should begin on new line when previous clause spans multiple lines
var elementNames =
from element in GetElements
(
12,
45
) select element.Name;
#pragma warning restore SA1104 // Query clause should begin on new line when previous clause spans multiple lines