From af15571af0a0a58adce9f7562d18519543975d2f Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 15 Jun 2017 20:43:44 -0500 Subject: [PATCH 1/2] Update documentation for SA1413 to include rationale Closes #2416 --- documentation/SA1413.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/documentation/SA1413.md b/documentation/SA1413.md index 50b52dab9..f5788ca25 100644 --- a/documentation/SA1413.md +++ b/documentation/SA1413.md @@ -21,6 +21,14 @@ The last statement in a multi-line C# initializer is missing a trailing comma. +### Rationale + +This rule is specifically designed to work well with the most widely used source control systems as an aid to long-term +code review. By placing a comma on the last line of a multi-line sequence, developers who append an item to the list or +reorder the list at some point in the future will not need to modify any more lines than absolutely necessary for the +change. As a result, the size of the subsequent code review is minimized and focused, and tools like **git blame** +continue to show the original author and commit for the item that was previously last in the list. + ## Rule description A violation of this rule occurs when the last statement of a C# initializer is missing a trailing comma. From ff4f9709192981f42958af9b2af78dedd0c0e78e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 15 Jun 2017 20:48:13 -0500 Subject: [PATCH 2/2] Clarify that SA1413 is also reported for enum members --- documentation/SA1413.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/documentation/SA1413.md b/documentation/SA1413.md index f5788ca25..c9c0692f3 100644 --- a/documentation/SA1413.md +++ b/documentation/SA1413.md @@ -19,7 +19,7 @@ ## Cause -The last statement in a multi-line C# initializer is missing a trailing comma. +The last statement in a multi-line C# initializer or list is missing a trailing comma. ### Rationale @@ -31,7 +31,7 @@ continue to show the original author and commit for the item that was previously ## Rule description -A violation of this rule occurs when the last statement of a C# initializer is missing a trailing comma. +A violation of this rule occurs when the last statement of a C# initializer or list is missing a trailing comma. For example, the following code would generate one instance of this violation: @@ -55,6 +55,8 @@ var x = new Barnacle }; ``` +This diagnostic is also reported for other forms of comma-separated list, such as enum members. + ## How to fix violations To fix a violation of this rule, add a trailing comma to the last statement in the initializer.