File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
2836For 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
5262To fix a violation of this rule, add a trailing comma to the last statement in the initializer.
You can’t perform that action at this time.
0 commit comments