From 233bbc8f241e7885e86b268db6bdb74da89ab75e Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:40:36 -0800 Subject: [PATCH 1/2] format tables and clarify false value --- .../style-rules/csharp-formatting-options.md | 395 +++++++++--------- 1 file changed, 198 insertions(+), 197 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md b/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md index 711f99ff24edb..7a6bd597d4238 100644 --- a/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md +++ b/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md @@ -39,15 +39,15 @@ csharp_new_line_between_query_expression_clauses = true This option concerns whether an open brace `{` should be placed on the same line as the preceding code, or on a new line. For this rule, you specify **all**, **none**, or one or more code elements such as **methods** or **properties**, to define when this rule should be applied. To specify multiple code elements, separate them with a comma (,). -| Property | Value | Description | -|--------------------------|-----------------------------------|--------------------------------------------------------------------------| -| **Option name** | csharp_new_line_before_open_brace | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | +| Property | Value | Description | +|--------------------------|-----------------------------------|-------------| +| **Option name** | csharp_new_line_before_open_brace | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | | **Option values** | `all` | Require braces to be on a new line for all expressions ("Allman" style). | -| | `none` | Require braces to be on the same line for all expressions ("K&R"). | +| | `none` | Require braces to be on the same line for all expressions ("K&R"). | | | `accessors`, `anonymous_methods`, `anonymous_types`, `control_blocks`, `events`, `indexers`,
`lambdas`, `local_functions`, `methods`, `object_collection_array_initializers`, `properties`, `types` | Require braces to be on a new line for the specified code element ("Allman" style). | -| **Default option value** | `all` | | +| **Default option value** | `all` | | Code examples: @@ -101,14 +101,14 @@ if (...) { ### csharp_new_line_before_catch -| Property | Value | Description | -| ------------------------ | ------------------------------- | ------------------------------------------ | -| **Option name** | csharp_new_line_before_catch | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | -| **Option values** | `true` | Place `catch` statements on a new line. | -| | `false` | Place `catch` statements on the same line. | -| **Default option value** | `true` | | +| Property | Value | Description | +|--------------------------|------------------------------|--------------------------------------------| +| **Option name** | csharp_new_line_before_catch | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | +| **Option values** | `true` | Place `catch` statements on a new line. | +| | `false` | Place `catch` statements on the same line. | +| **Default option value** | `true` | | Code examples: @@ -131,14 +131,14 @@ try { ### csharp_new_line_before_finally -| Property | Value | Description | -| ------------------------ | ------------------------------- | ------------------------------------------------------------------------- | -| **Option name** | csharp_new_line_before_finally | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | -| **Option values** | `true` | Require `finally` statements to be on a new line after the closing brace. | -| | `false` | Require `finally` statements to be on the same line as the closing brace. | -| **Default option value** | `true` | | +| Property | Value | Description | +|--------------------------|--------------------------------|-------------| +| **Option name** | csharp_new_line_before_finally | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | +| **Option values** | `true` | Require `finally` statements to be on a new line after the closing brace. | +| | `false` | Require `finally` statements to be on the same line as the closing brace. | +| **Default option value** | `true` | | Code examples: @@ -166,14 +166,14 @@ try { ### csharp_new_line_before_members_in_object_initializers -| Property | Value | Description | -| ------------------------ | ----------------------------------------------------- | -------------------------------------------------------------- | -| **Option name** | csharp_new_line_before_members_in_object_initializers | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | +| Property | Value | Description | +|--------------------------|-------------------------------------------------------|-------------| +| **Option name** | csharp_new_line_before_members_in_object_initializers | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | | **Option values** | `true` | Require members of object initializers to be on separate lines | -| | `false` | Require members of object initializers to be on the same line | -| **Default option value** | `true` | | +| | `false` | Require members of object initializers to be on the same line | +| **Default option value** | `true` | | Code examples: @@ -194,14 +194,14 @@ var z = new B() ### csharp_new_line_before_members_in_anonymous_types -| Property | Value | Description | -| ------------------------ | ------------------------------------------------- | ---------------------------------------------------------- | -| **Option name** | csharp_new_line_before_members_in_anonymous_types | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | +| Property | Value | Description | +|--------------------------|---------------------------------------------------|-------------| +| **Option name** | csharp_new_line_before_members_in_anonymous_types | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | | **Option values** | `true` | Require members of anonymous types to be on separate lines | | | `false` | Require members of anonymous types to be on the same line | -| **Default option value** | `true` | | +| **Default option value** | `true` | | Code examples: @@ -222,14 +222,14 @@ var z = new ### csharp_new_line_between_query_expression_clauses -| Property | Value | Description | -| ------------------------ | ------------------------------------------------ | -------------------------------------------------------------------- | -| **Option name** | csharp_new_line_between_query_expression_clauses | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | +| Property | Value | Description | +|--------------------------|--------------------------------------------------|-------------| +| **Option name** | csharp_new_line_between_query_expression_clauses | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | | **Option values** | `true` | Require elements of query expression clauses to be on separate lines | | | `false` | Require elements of query expression clauses to be on the same line | -| **Default option value** | `true` | | +| **Default option value** | `true` | | Code examples: @@ -270,14 +270,14 @@ csharp_indent_case_contents_when_block = true ### csharp_indent_case_contents -| Property | Value | Description | -| ------------------------ | ------------------------------- | ------------------------------------ | -| **Option name** | csharp_indent_case_contents | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | -| **Option values** | `true` | Indent `switch` case contents | -| | `false` | Do not indent `switch` case contents | -| **Default option value** | `true` | | +| Property | Value | Description | +|--------------------------|-----------------------------|-------------| +| **Option name** | csharp_indent_case_contents | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | +| **Option values** | `true` | Indent `switch` case contents | +| | `false` | Do not indent `switch` case contents | +| **Default option value** | `true` | | Code examples: @@ -352,15 +352,15 @@ default: ### csharp_indent_labels -| Property | Value | Description | -| ------------------------ | ------------------------------- | ----------------------------------------------------------- | -| **Option name** | csharp_indent_labels | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | -| **Option values** | `flush_left` | Labels are placed at the leftmost column | -| | `one_less_than_current` | Labels are placed at one less indent to the current context | -| | `no_change` | Labels are placed at the same indent as the current context | -| **Default option value** | `one_less_than_current` | | +| Property | Value | Description | +|--------------------------|----------------------|-------------| +| **Option name** | csharp_indent_labels | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | +| **Option values** | `flush_left` | Labels are placed at the leftmost column | +| | `one_less_than_current` | Labels are placed at one less indent to the current context | +| | `no_change` | Labels are placed at the same indent as the current context | +| **Default option value** | `one_less_than_current` | | Code examples: @@ -459,13 +459,13 @@ static void Hello() ### csharp_indent_case_contents_when_block -| Property | Value | Description | -| ------------------------ | -------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| **Option name** | csharp_indent_case_contents_when_block | | -| **Applicable languages** | C# | | -| **Option values** | `true` | When it's a block, indent the statement list and curly braces for a case in a switch statement. | +| Property | Value | Description | +|--------------------------|----------------------------------------|-------------| +| **Option name** | csharp_indent_case_contents_when_block | | +| **Applicable languages** | C# | | +| **Option values** | `true` | When it's a block, indent the statement list and curly braces for a case in a switch statement. | | | `false` | When it's a block, don't indent the statement list and curly braces for a case in a switch statement. | -| **Default option value** | `true` | | +| **Default option value** | `true` | | Code examples: @@ -543,14 +543,14 @@ csharp_space_between_square_brackets = false ### csharp_space_after_cast -| Property | Value | Description | -| ------------------------ | ------------------------------- | ---------------------------------------------------- | -| **Option name** | csharp_space_after_cast | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | -| **Option values** | `true` | Place a space character between a cast and the value | -| | `false` | Remove space between the cast and the value | -| **Default option value** | `false` | | +| Property | Value | Description | +|--------------------------|-------------------------|-------------| +| **Option name** | csharp_space_after_cast | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | +| **Option values** | `true` | Place a space character between a cast and the value | +| | `false` | Remove space between the cast and the value | +| **Default option value** | `false` | | Code examples: @@ -564,14 +564,14 @@ int y = (int)x; ### csharp_space_after_keywords_in_control_flow_statements -| Property | Value | Description | -| ------------------------ | ------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -| **Option name** | csharp_space_after_keywords_in_control_flow_statements | | -| **Applicable languages** | C# | | -| **Introduced version** | Visual Studio 2017 | | +| Property | Value | Description | +|--------------------------|--------------------|-------------| +| **Option name** | csharp_space_after_keywords_in_control_flow_statements | | +| **Applicable languages** | C# | | +| **Introduced version** | Visual Studio 2017 | | | **Option values** | `true` | Place a space character after a keyword in a control flow statement such as a `for` loop | -| | `false` | Remove space after a keyword in a control flow statement such as a `for` loop | -| **Default option value** | `true` | | +| | `false` | Remove space after a keyword in a control flow statement such as a `for` loop | +| **Default option value** | `true` | | Code examples: @@ -585,17 +585,18 @@ for(int i;i Date: Thu, 30 Jan 2025 10:13:05 -0800 Subject: [PATCH 2/2] update csharp_space_between_parentheses with default value --- .../style-rules/csharp-formatting-options.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md b/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md index 7a6bd597d4238..0b6da2fa54169 100644 --- a/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md +++ b/docs/fundamentals/code-analysis/style-rules/csharp-formatting-options.md @@ -1,7 +1,7 @@ --- title: C# formatting options description: Learn about the code style options for formatting C# code files. -ms.date: 12/13/2022 +ms.date: 01/30/2025 dev_langs: - CSharp --- @@ -593,10 +593,10 @@ for(int i;i