Skip to content

Latest commit

 

History

History
64 lines (54 loc) · 1.44 KB

SA1104.md

File metadata and controls

64 lines (54 loc) · 1.44 KB

SA1104

Title Query clause should begin on new line when previous clause spans multiple lines
TypeName SA110xQueryClauses
CheckId SA1104
Category Readability Rules

Cause

A clause within a C# query expression begins on the same line as the previous clause, when the previous clause spans across multiple lines.

Rule description

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;

How to fix violations

To fix a violation of this rule, move the clause down to start on the next line.

How to suppress violations

#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