Skip to content

Commit a5ca880

Browse files
authored
Merge pull request #2418 from sharwell/doc-sa1413
Update documentation for SA1413 to include rationale
2 parents 84e7e8b + ff4f970 commit a5ca880

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

documentation/SA1413.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@
1919

2020
## Cause
2121

22-
The last statement in a multi-line C# initializer is missing a trailing comma.
22+
The last statement in a multi-line C# initializer or list is missing a trailing comma.
23+
24+
### Rationale
25+
26+
This rule is specifically designed to work well with the most widely used source control systems as an aid to long-term
27+
code review. By placing a comma on the last line of a multi-line sequence, developers who append an item to the list or
28+
reorder the list at some point in the future will not need to modify any more lines than absolutely necessary for the
29+
change. As a result, the size of the subsequent code review is minimized and focused, and tools like **git blame**
30+
continue to show the original author and commit for the item that was previously last in the list.
2331

2432
## Rule description
2533

26-
A violation of this rule occurs when the last statement of a C# initializer is missing a trailing comma.
34+
A violation of this rule occurs when the last statement of a C# initializer or list is missing a trailing comma.
2735

2836
For example, the following code would generate one instance of this violation:
2937

@@ -47,6 +55,8 @@ var x = new Barnacle
4755
};
4856
```
4957

58+
This diagnostic is also reported for other forms of comma-separated list, such as enum members.
59+
5060
## How to fix violations
5161

5262
To fix a violation of this rule, add a trailing comma to the last statement in the initializer.

0 commit comments

Comments
 (0)