BRO1109: Opening parenthesis or bracket should be on the declaration line¶
The opening parenthesis of a parameter or argument list goes on the line of the name it belongs to, not on the next line. Replaces StyleCop SA1110.
Example¶
Before¶
public class Report
{
public string Title
(int year, int month)
{
return Format
(year, month);
}
private static string Format(int year, int month) => year + "-" + month;
}
After¶
public class Report
{
public string Title(
int year, int month)
{
return Format(
year, month);
}
private static string Format(int year, int month) => year + "-" + month;
}
Why¶
A name followed by ( on the next line looks like a statement that ended, and the list like something unrelated.
Keeping ( with the name makes the call or declaration read as one unit.
How the fix works¶
The ( or [ moves to the end of the name's line, and what followed it stays where it was, now as the list's first
line. An empty list is simply joined: new Report().
Checked: parameter lists of methods, constructors, delegates, local functions and indexers, and argument lists of
calls, new, element access, attributes and constructor initializers. A lambda's parameter list has no name before
it and isn't checked.
Not reported¶
- A comment or directive between the name and the parenthesis.