You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/SA1118.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,15 @@ A parameter to a C# method or indexer, other than the first parameter, spans acr
21
21
22
22
## Rule description
23
23
24
-
To prevent method calls from becoming excessively complicated and unreadable, only the first parameter to a method or indexer call is allowed to span across multiple lines. The exception is an anonymous method passed as a parameter, which is always allowed to span multiple lines. A violation of this rule occurs whenever a parameter other than the first parameter spans across multiple lines, and the parameter does not contain an anonymous method.
24
+
To prevent method calls from becoming excessively complicated and unreadable, individual parameters and arguments should
25
+
be placed on a single line. When parameters other than the first parameter span across multiple lines, it can be
26
+
difficult to tell how many parameters are passed to the method. In general, the code becomes difficult to read. A
27
+
violation of this rule is reported when a parameter or argument spans multiple lines, except in the following specific
28
+
cases:
29
+
30
+
* The first parameter may span multiple lines
31
+
* Anonymous methods (including lambda expressions) may span multiple lines
32
+
* Invocation expressions may span multiple lines
25
33
26
34
For example, the following code would violate this rule, since the second parameter spans across multiple lines:
27
35
@@ -32,9 +40,9 @@ return JoinStrings(
32
40
" Doe");
33
41
```
34
42
35
-
When parameters other than the first parameter span across multiple lines, it can be difficult to tell how many parameters are passed to the method. In general, the code becomes difficult to read.
36
-
37
-
To fix the example above, ensure that the parameters after the first parameter do not span across multiple lines. If this will cause a parameter to be excessively long, store the value of the parameter within a temporary variable. For example:
43
+
To fix the example above, ensure that the parameters after the first parameter do not span across multiple lines. If
44
+
this will cause a parameter to be excessively long, store the value of the parameter within a temporary variable. For
To fix a violation of this rule, ensure that the parameters after the first parameter do not span multiple lines, unless the parameter contains an anonymous method.
64
+
To fix a violation of this rule, ensure that the parameters and arguments do not span multiple lines, except in the
0 commit comments