Skip to content

Commit ae62432

Browse files
authored
random code fix updates (#43826)
1 parent 09e749d commit ae62432

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

docs/fundamentals/code-analysis/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If rule violations are found by an analyzer, they're reported as a suggestion, w
2525
*Code quality analysis* ("CAxxxx") rules inspect your C# or Visual Basic code for security, performance, design and other issues. Analysis is enabled, by default, for projects that target .NET 5 or later. You can enable code analysis on projects that target earlier .NET versions by setting the [EnableNETAnalyzers](../../core/project-sdk/msbuild-props.md#enablenetanalyzers) property to `true`. You can also disable code analysis for your project by setting `EnableNETAnalyzers` to `false`.
2626

2727
> [!TIP]
28-
> If you're using Visual Studio, many analyzer rules have associated *code fixes* that you can apply to correct the problem. Code fixes are shown in the light bulb icon menu.
28+
> If you're using Visual Studio, many analyzer rules have associated *code fixes* that you can apply to automatically correct the problem. Code fixes are shown in the light bulb icon menu.
2929
3030
### Enabled rules
3131

docs/fundamentals/code-analysis/quality-rules/ca1865-ca1867.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ The target methods on `string` for these rules:
3939

4040
The following table summarizes the conditions for each of the related rule IDs.
4141

42-
| Diagnostic ID | Description | Code fix available |
43-
| - | - | - |
44-
| CA1865 | Applies when a safe transformation can be performed automatically with a code fix. | Yes |
45-
| CA1866 | Applies when there's no specified comparison. | No |
46-
| CA1867 | Applies for any other string comparison not covered by the other two rules. | No |
42+
| Diagnostic ID | Description | Code fix available? |
43+
|---------------|------------------------------------------------------------------------------------|---------------------|
44+
| CA1865 | Applies when a safe transformation can be performed automatically with a code fix. | Yes |
45+
| CA1866 | Applies when there's no specified comparison. | No |
46+
| CA1867 | Applies for any other string comparison not covered by the other two rules. | No |
4747

4848
CA1867 is disabled by default.
4949

docs/fundamentals/code-analysis/quality-rules/ca1870.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Using a cached <xref:System.Buffers.SearchValues%601> instance is more efficient
3737

3838
Create and cache a <xref:System.Buffers.SearchValues%601> instance in a `static readonly` field, then pass that instance to the `IndexOfAny` or `ContainsAny` call instead.
3939

40-
A code fixer that performs this transformation is available.
40+
A *code fix* that automatically performs this transformation is available.
4141

4242
## Example
4343

docs/fundamentals/code-analysis/style-rules/ide0028.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ dev_langs:
2828

2929
This style rule concerns the use of [collection initializers](../../../csharp/programming-guide/classes-and-structs/object-and-collection-initializers.md) and, if you're using C# 12 or later, [collection expressions](../../../csharp/language-reference/operators/collection-expressions.md) for collection initialization.
3030

31-
In .NET 8 (C# 12) and later versions, if you have the `dotnet_style_prefer_collection_expression` option set to `true`, the code fixer in Visual Studio converts your collection initialization code to use a collection expression (`List<int> list = [1, 2, 3];`). In Visual Basic and in .NET 7 (C# 11) and earlier versions, the code fixer converts your code to use a collection initializer (`List<int> list = new List<int> { 1, 2, 3 };`).
31+
In .NET 8 (C# 12) and later versions, if you have the `dotnet_style_prefer_collection_expression` option set to `true`, the *code fix* in Visual Studio converts your collection initialization code to use a collection expression (`List<int> list = [1, 2, 3];`). In Visual Basic and in .NET 7 (C# 11) and earlier versions, the *code fix* converts your code to use a collection initializer (`List<int> list = new List<int> { 1, 2, 3 };`).
3232

3333
> [!NOTE]
34-
> If you use the code fixer in Visual Studio, the change it offers might have different semantics in some cases. For example, `int[] x = new int[] { }` is replaced with `int[] x = [];`, which has slightly different semantics&mdash;the compiler uses a singleton for `x` instead of creating a new instance.
34+
> If you use the *code fix* in Visual Studio, the change it offers might have different semantics in some cases. For example, `int[] x = new int[] { }` is replaced with `int[] x = [];`, which has slightly different semantics&mdash;the compiler uses a singleton for `x` instead of creating a new instance.
3535
3636
## Options
3737

docs/fundamentals/code-analysis/style-rules/ide0058.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ For information about configuring options, see [Option format](language-rules.md
6262

6363
### csharp_style_unused_value_expression_statement_preference
6464

65-
| Property | Value | Description |
66-
| ------------------------ | --------------------------------------------------------- | --------------------------------------------------------------------------- |
67-
| **Option name** | csharp_style_unused_value_expression_statement_preference | |
68-
| **Applicable languages** | C# | |
69-
| **Option values** | `discard_variable` | Prefer to assign an unused expression to a discard |
65+
| Property | Value | Description |
66+
|--------------------------|-----------------------------------------------------------|-------------|
67+
| **Option name** | csharp_style_unused_value_expression_statement_preference | |
68+
| **Applicable languages** | C# | |
69+
| **Option values** | `discard_variable` | Prefer to assign an unused expression to a discard |
7070
| | `unused_local_variable` | Prefer to assign an unused expression to a local variable that's never used |
71-
| **Default option value** | `discard_variable` | |
71+
| **Default option value** | `discard_variable` | |
7272

7373
```csharp
7474
// Original code:
@@ -85,12 +85,12 @@ var unused = Convert.ToInt32("35");
8585

8686
### visual_basic_style_unused_value_expression_statement_preference
8787

88-
| Property | Value | Description |
89-
| ------------------------ | --------------------------------------------------------------- | --------------------------------------------------------------------------- |
90-
| **Option name** | visual_basic_style_unused_value_expression_statement_preference | |
91-
| **Applicable languages** | Visual Basic | |
88+
| Property | Value | Description |
89+
|--------------------------|-----------------------------------------------------------------|-------------|
90+
| **Option name** | visual_basic_style_unused_value_expression_statement_preference | |
91+
| **Applicable languages** | Visual Basic | |
9292
| **Option values** | `unused_local_variable` | Prefer to assign an unused expression to a local variable that's never used |
93-
| **Default option value** | `unused_local_variable` | |
93+
| **Default option value** | `unused_local_variable` | |
9494

9595
```vb
9696
' visual_basic_style_unused_value_expression_statement_preference = unused_local_variable

0 commit comments

Comments
 (0)