From 0cf71bade0ae10728512e9a37c2d8f1c0ce0b28c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 00:45:41 +0000 Subject: [PATCH 1/7] Initial plan From ae2e8adb5117b9b7daa2205223848ce81782890b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 00:51:11 +0000 Subject: [PATCH 2/7] Add documentation for IDE0360, IDE0370, and IDE0380 Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com> --- .../code-analysis/style-rules/ide0360.md | 85 +++++++++++++++ .../code-analysis/style-rules/ide0370.md | 90 ++++++++++++++++ .../code-analysis/style-rules/ide0380.md | 102 ++++++++++++++++++ .../code-analysis/style-rules/index.md | 3 + 4 files changed, 280 insertions(+) create mode 100644 docs/fundamentals/code-analysis/style-rules/ide0360.md create mode 100644 docs/fundamentals/code-analysis/style-rules/ide0370.md create mode 100644 docs/fundamentals/code-analysis/style-rules/ide0380.md diff --git a/docs/fundamentals/code-analysis/style-rules/ide0360.md b/docs/fundamentals/code-analysis/style-rules/ide0360.md new file mode 100644 index 0000000000000..a8e7c7937eee2 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide0360.md @@ -0,0 +1,85 @@ +--- +title: "IDE0360: Simplify property accessor" +description: "Learn about code analysis rule IDE0360: Simplify property accessor" +ms.date: 11/08/2025 +f1_keywords: +- IDE0360 +helpviewer_keywords: +- IDE0360 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Simplify property accessor (IDE0360) + +| Property | Value | +|--------------------------|-----------------------------------------------| +| **Rule ID** | IDE0360 | +| **Title** | Simplify property accessor | +| **Category** | Style | +| **Subcategory** | Language rules (expression-level preferences) | +| **Applicable languages** | C# 13+ | +| **Options** | `csharp_style_prefer_simple_property_accessors` | + +## Overview + +This rule flags places where a property accessor can be simplified by using field-backed properties (C# 13+). A property accessor that only gets or sets a backing field can be replaced with a simpler field-backed property accessor. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### csharp_style_prefer_simple_property_accessors + +| Property | Value | Description | +|--------------------------|-----------------------------------------------|---------------------------------------------| +| **Option name** | csharp_style_prefer_simple_property_accessors | | +| **Option values** | `true` | Prefer simplified property accessors | +| | `false` | Disables the rule | +| **Default option value** | `true` | | + +## Example + +```csharp +// Code with violations. +private string _name; +public string Name +{ + get { return _name; } + set { _name = value; } +} + +// Fixed code. +private string _name; +public string Name +{ + get => field; + set => field = value; +} +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE0360 +// The code that's violating the rule is on this line. +#pragma warning restore IDE0360 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE0360.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-Style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). diff --git a/docs/fundamentals/code-analysis/style-rules/ide0370.md b/docs/fundamentals/code-analysis/style-rules/ide0370.md new file mode 100644 index 0000000000000..b1087b162f2b7 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide0370.md @@ -0,0 +1,90 @@ +--- +title: "IDE0370: Remove unnecessary suppression" +description: "Learn about code analysis rule IDE0370: Remove unnecessary suppression" +ms.date: 11/08/2025 +f1_keywords: +- IDE0370 +helpviewer_keywords: +- IDE0370 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Remove unnecessary suppression (IDE0370) + +| Property | Value | +|--------------------------|-------------------------------------------| +| **Rule ID** | IDE0370 | +| **Title** | Remove unnecessary suppression | +| **Category** | Style | +| **Subcategory** | Unnecessary code rules | +| **Applicable languages** | C# | +| **Options** | None | + +## Overview + +This rule identifies unnecessary nullable warning suppressions using the null-forgiving operator (`!`). The null-forgiving operator tells the compiler that the value is not null, suppressing nullable reference type warnings. However, when the compiler can already determine that a value is not null, the null-forgiving operator is unnecessary and can be removed. + +## Example + +```csharp +// Code with violations. +string GetMessage() +{ + string message = "Hello"; + return message!; // Unnecessary, compiler knows message is not null +} + +void ProcessValue(string value) +{ + if (value != null) + { + var length = value!.Length; // Unnecessary, we just checked for null + } +} + +// Fixed code. +string GetMessage() +{ + string message = "Hello"; + return message; // No suppression needed +} + +void ProcessValue(string value) +{ + if (value != null) + { + var length = value.Length; // No suppression needed + } +} +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE0370 +// The code that's violating the rule is on this line. +#pragma warning restore IDE0370 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE0370.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-Style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [Nullable reference types](../../../csharp/nullable-references.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0380.md b/docs/fundamentals/code-analysis/style-rules/ide0380.md new file mode 100644 index 0000000000000..a5bb62ebad38b --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide0380.md @@ -0,0 +1,102 @@ +--- +title: "IDE0380: Remove unnecessary 'unsafe' modifier" +description: "Learn about code analysis rule IDE0380: Remove unnecessary 'unsafe' modifier" +ms.date: 11/08/2025 +f1_keywords: +- IDE0380 +helpviewer_keywords: +- IDE0380 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Remove unnecessary 'unsafe' modifier (IDE0380) + +| Property | Value | +|--------------------------|-------------------------------------------| +| **Rule ID** | IDE0380 | +| **Title** | Remove unnecessary 'unsafe' modifier | +| **Category** | Style | +| **Subcategory** | Unnecessary code rules | +| **Applicable languages** | C# | +| **Options** | None | + +## Overview + +This rule identifies code blocks, methods, types, or other declarations marked with the `unsafe` modifier that don't actually contain any unsafe operations. The `unsafe` modifier allows the use of pointers and other unsafe code features, but when those features aren't being used, the modifier is unnecessary and should be removed for code clarity. + +## Example + +```csharp +// Code with violations. +unsafe class MyClass // Unnecessary, no unsafe operations in the class +{ + public void Method() + { + var x = 5; + } +} + +unsafe void ProcessData(int value) // Unnecessary, no unsafe operations +{ + Console.WriteLine(value); +} + +void Example() +{ + unsafe // Unnecessary, no unsafe operations in this block + { + var result = 10 + 20; + } +} + +// Fixed code. +class MyClass // No unsafe modifier needed +{ + public void Method() + { + var x = 5; + } +} + +void ProcessData(int value) // No unsafe modifier needed +{ + Console.WriteLine(value); +} + +void Example() +{ + // No unsafe modifier needed + var result = 10 + 20; +} +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE0380 +// The code that's violating the rule is on this line. +#pragma warning restore IDE0380 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE0380.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-Style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [Unsafe code, pointer types, and function pointers](../../../csharp/language-reference/unsafe-code.md) diff --git a/docs/fundamentals/code-analysis/style-rules/index.md b/docs/fundamentals/code-analysis/style-rules/index.md index fec923289f122..7060e750e061e 100644 --- a/docs/fundamentals/code-analysis/style-rules/index.md +++ b/docs/fundamentals/code-analysis/style-rules/index.md @@ -146,6 +146,9 @@ The following table list all the code-style rules by ID and [options](../code-st > | [IDE0330](ide0330.md) | Prefer 'System.Threading.Lock' | [csharp_prefer_system_threading_lock](ide0330.md#csharp_prefer_system_threading_lock) | > | [IDE0340](ide0340.md) | Use unbound generic type | [csharp_style_prefer_unbound_generic_type_in_nameof](ide0340.md#csharp_style_prefer_unbound_generic_type_in_nameof) | > | [IDE0350](ide0350.md) | Use implicitly typed lambda | [csharp_style_prefer_implicitly_typed_lambda_expression](ide0350.md#csharp_style_prefer_implicitly_typed_lambda_expression) | +> | [IDE0360](ide0360.md) | Simplify property accessor | [csharp_style_prefer_simple_property_accessors](ide0360.md#csharp_style_prefer_simple_property_accessors) | +> | [IDE0370](ide0370.md) | Remove unnecessary suppression | | +> | [IDE0380](ide0380.md) | Remove unnecessary 'unsafe' modifier | | > | [IDE1005](ide1005.md) | Use conditional delegate call | [csharp_style_conditional_delegate_call](ide1005.md#csharp_style_conditional_delegate_call) | > | [IDE1006](naming-rules.md) | Naming styles | | > | [IDE2000](ide2000.md) | Avoid multiple blank lines | [dotnet_style_allow_multiple_blank_lines_experimental](ide2000.md#dotnet_style_allow_multiple_blank_lines_experimental)† | From 0db9648e1ddc605946e52497eff647b1b3344d68 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 00:53:27 +0000 Subject: [PATCH 3/7] Update examples for IDE0360, IDE0370, and IDE0380 based on Roslyn tests Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com> --- .../code-analysis/style-rules/ide0360.md | 16 +++++------- .../code-analysis/style-rules/ide0370.md | 26 +++++-------------- .../code-analysis/style-rules/ide0380.md | 14 +++------- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0360.md b/docs/fundamentals/code-analysis/style-rules/ide0360.md index a8e7c7937eee2..95368fbb2efab 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0360.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0360.md @@ -23,7 +23,7 @@ ai-usage: ai-assisted ## Overview -This rule flags places where a property accessor can be simplified by using field-backed properties (C# 13+). A property accessor that only gets or sets a backing field can be replaced with a simpler field-backed property accessor. +This rule flags places where a property accessor that directly accesses the `field` keyword (C# 13+) can be simplified. When a property accessor only returns `field` or assigns a value to `field`, it can be simplified to a simple auto-accessor. ## Options @@ -42,19 +42,17 @@ Options specify the behavior that you want the rule to enforce. For information ```csharp // Code with violations. -private string _name; -public string Name +public int Prop { - get { return _name; } - set { _name = value; } + get { return field; } + set { field = value; } } // Fixed code. -private string _name; -public string Name +public int Prop { - get => field; - set => field = value; + get; + set; } ``` diff --git a/docs/fundamentals/code-analysis/style-rules/ide0370.md b/docs/fundamentals/code-analysis/style-rules/ide0370.md index b1087b162f2b7..ac9dce00ee383 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0370.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0370.md @@ -29,33 +29,19 @@ This rule identifies unnecessary nullable warning suppressions using the null-fo ```csharp // Code with violations. -string GetMessage() -{ - string message = "Hello"; - return message!; // Unnecessary, compiler knows message is not null -} +#nullable enable -void ProcessValue(string value) +void ProcessValue() { - if (value != null) - { - var length = value!.Length; // Unnecessary, we just checked for null - } + object o = ""; // Unnecessary, compiler knows "" is not null } // Fixed code. -string GetMessage() -{ - string message = "Hello"; - return message; // No suppression needed -} +#nullable enable -void ProcessValue(string value) +void ProcessValue() { - if (value != null) - { - var length = value.Length; // No suppression needed - } + object o = ""; // No suppression needed } ``` diff --git a/docs/fundamentals/code-analysis/style-rules/ide0380.md b/docs/fundamentals/code-analysis/style-rules/ide0380.md index a5bb62ebad38b..763a60719e87d 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0380.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0380.md @@ -42,14 +42,6 @@ unsafe void ProcessData(int value) // Unnecessary, no unsafe operations Console.WriteLine(value); } -void Example() -{ - unsafe // Unnecessary, no unsafe operations in this block - { - var result = 10 + 20; - } -} - // Fixed code. class MyClass // No unsafe modifier needed { @@ -64,10 +56,10 @@ void ProcessData(int value) // No unsafe modifier needed Console.WriteLine(value); } -void Example() +// Example where unsafe is needed. +unsafe class ValidUsage { - // No unsafe modifier needed - var result = 10 + 20; + int* pointer; // Pointer type requires unsafe } ``` From 12586f8c76a19b3b4fd3af62dfdb713dd63d9c02 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 00:55:08 +0000 Subject: [PATCH 4/7] Fix IDE0370 example to show the null-forgiving operator Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com> --- docs/fundamentals/code-analysis/style-rules/ide0370.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0370.md b/docs/fundamentals/code-analysis/style-rules/ide0370.md index ac9dce00ee383..92b804977f8c2 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0370.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0370.md @@ -33,7 +33,7 @@ This rule identifies unnecessary nullable warning suppressions using the null-fo void ProcessValue() { - object o = ""; // Unnecessary, compiler knows "" is not null + object o = ""!; // Unnecessary, compiler knows "" is not null } // Fixed code. From f924a8eed14a2734a021806457365f0f7734bc7b Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:18:05 -0800 Subject: [PATCH 5/7] add to toc and other index --- .../code-analysis/style-rules/ide0360.md | 18 ++++++--------- .../code-analysis/style-rules/ide0370.md | 22 +++++++++---------- .../code-analysis/style-rules/ide0380.md | 19 +++++++++------- .../style-rules/language-rules.md | 8 ++++++- docs/navigate/tools-diagnostics/toc.yml | 6 +++++ 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0360.md b/docs/fundamentals/code-analysis/style-rules/ide0360.md index 95368fbb2efab..bf240867b475c 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0360.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0360.md @@ -31,12 +31,12 @@ Options specify the behavior that you want the rule to enforce. For information ### csharp_style_prefer_simple_property_accessors -| Property | Value | Description | -|--------------------------|-----------------------------------------------|---------------------------------------------| -| **Option name** | csharp_style_prefer_simple_property_accessors | | -| **Option values** | `true` | Prefer simplified property accessors | -| | `false` | Disables the rule | -| **Default option value** | `true` | | +| Property | Value | Description | +|-------------------|-----------------------------------------------|-------------------| +| **Option name** | `csharp_style_prefer_simple_property_accessors` | | +| **Option values** | `true` | Prefer simplified property accessors | +| | `false` | Disables the rule | +| **Default option value** | `true` | | ## Example @@ -49,11 +49,7 @@ public int Prop } // Fixed code. -public int Prop -{ - get; - set; -} +public int Prop { get; set; } ``` ## Suppress a warning diff --git a/docs/fundamentals/code-analysis/style-rules/ide0370.md b/docs/fundamentals/code-analysis/style-rules/ide0370.md index 92b804977f8c2..020138eba0531 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0370.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0370.md @@ -12,18 +12,18 @@ ai-usage: ai-assisted --- # Remove unnecessary suppression (IDE0370) -| Property | Value | -|--------------------------|-------------------------------------------| -| **Rule ID** | IDE0370 | -| **Title** | Remove unnecessary suppression | -| **Category** | Style | -| **Subcategory** | Unnecessary code rules | -| **Applicable languages** | C# | -| **Options** | None | +| Property | Value | +|--------------------------|--------------------------------------------------| +| **Rule ID** | IDE0370 | +| **Title** | Remove unnecessary suppression | +| **Category** | Style | +| **Subcategory** | Unnecessary code rules (suppression preferences) | +| **Applicable languages** | C# | +| **Options** | None | ## Overview -This rule identifies unnecessary nullable warning suppressions using the null-forgiving operator (`!`). The null-forgiving operator tells the compiler that the value is not null, suppressing nullable reference type warnings. However, when the compiler can already determine that a value is not null, the null-forgiving operator is unnecessary and can be removed. +This rule identifies unnecessary nullable warning suppressions using the [null-forgiving operator](../../../csharp/language-reference/operators/null-forgiving.md) (`!`). The null-forgiving operator tells the compiler that the value is not null, which suppresses warnings for nullable reference types. However, when the compiler can already determine that a value is not null, the null-forgiving operator is unnecessary and can be removed. ## Example @@ -33,7 +33,7 @@ This rule identifies unnecessary nullable warning suppressions using the null-fo void ProcessValue() { - object o = ""!; // Unnecessary, compiler knows "" is not null + List names = new()!; } // Fixed code. @@ -41,7 +41,7 @@ void ProcessValue() void ProcessValue() { - object o = ""; // No suppression needed + List names = new(); // No suppression needed. } ``` diff --git a/docs/fundamentals/code-analysis/style-rules/ide0380.md b/docs/fundamentals/code-analysis/style-rules/ide0380.md index 763a60719e87d..448ebba8afbc4 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0380.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0380.md @@ -10,12 +10,12 @@ dev_langs: - CSharp ai-usage: ai-assisted --- -# Remove unnecessary 'unsafe' modifier (IDE0380) +# Remove unnecessary `unsafe` modifier (IDE0380) | Property | Value | |--------------------------|-------------------------------------------| | **Rule ID** | IDE0380 | -| **Title** | Remove unnecessary 'unsafe' modifier | +| **Title** | Remove unnecessary `unsafe` modifier | | **Category** | Style | | **Subcategory** | Unnecessary code rules | | **Applicable languages** | C# | @@ -29,7 +29,9 @@ This rule identifies code blocks, methods, types, or other declarations marked w ```csharp // Code with violations. -unsafe class MyClass // Unnecessary, no unsafe operations in the class + +// Unnecessary, no unsafe operations. +unsafe class MyClass { public void Method() { @@ -37,13 +39,14 @@ unsafe class MyClass // Unnecessary, no unsafe operations in the class } } -unsafe void ProcessData(int value) // Unnecessary, no unsafe operations +// Unnecessary, no unsafe operations. +unsafe void ProcessData(int value) { Console.WriteLine(value); } // Fixed code. -class MyClass // No unsafe modifier needed +class MyClass { public void Method() { @@ -51,15 +54,15 @@ class MyClass // No unsafe modifier needed } } -void ProcessData(int value) // No unsafe modifier needed +void ProcessData(int value) { Console.WriteLine(value); } -// Example where unsafe is needed. +// Example where 'unsafe' is needed. unsafe class ValidUsage { - int* pointer; // Pointer type requires unsafe + int* pointer; // Pointer type requires 'unsafe'. } ``` diff --git a/docs/fundamentals/code-analysis/style-rules/language-rules.md b/docs/fundamentals/code-analysis/style-rules/language-rules.md index bd86cd6744ebd..bd2e2520186f9 100644 --- a/docs/fundamentals/code-analysis/style-rules/language-rules.md +++ b/docs/fundamentals/code-analysis/style-rules/language-rules.md @@ -1,7 +1,7 @@ --- title: Code-style language and unnecessary code rules description: Learn about the different code-style rules for using C# and Visual Basic language constructs and for finding unnecessary code. -ms.date: 03/25/2025 +ms.date: 11/07/2025 helpviewer_keywords: - language code style rules [EditorConfig] - language rules @@ -172,6 +172,7 @@ C# style rules: - [Use collection expression for new (IDE0306)](ide0306.md) - [Use unbound generic type (IDE0340)](ide0340.md) - [Use implicitly typed lambda (IDE0350)](ide0350.md) +- [Simplify property accessor (IDE0360)](ide0360.md) Visual Basic style rules: @@ -205,6 +206,7 @@ C# style rules: - [Struct can be made 'readonly' (IDE0250)](ide0250.md) - [Member can be made 'readonly' (IDE0251)](ide0251.md) - [Make anonymous function static (IDE0320)](ide0320.md) +- [Remove unnecessary `unsafe` modifier (IDE0380)](ide0380.md) ### New-line preferences @@ -259,6 +261,10 @@ C# style rules: - [Remove unnecessary suppression (IDE0079)](ide0079.md) +C# style rules: + +- [Remove unnecessary suppression (IDE0370)](ide0370.md) + ### `This.` and `me.` preferences .NET style rules (C# and Visual Basic): diff --git a/docs/navigate/tools-diagnostics/toc.yml b/docs/navigate/tools-diagnostics/toc.yml index 3bfea72f9aa3b..ef7767c738afb 100644 --- a/docs/navigate/tools-diagnostics/toc.yml +++ b/docs/navigate/tools-diagnostics/toc.yml @@ -3874,6 +3874,12 @@ items: href: ../../fundamentals/code-analysis/style-rules/ide0340.md - name: IDE0350 href: ../../fundamentals/code-analysis/style-rules/ide0350.md + - name: IDE0360 + href: ../../fundamentals/code-analysis/style-rules/ide0360.md + - name: IDE0370 + href: ../../fundamentals/code-analysis/style-rules/ide0370.md + - name: IDE0380 + href: ../../fundamentals/code-analysis/style-rules/ide0380.md - name: IDE1005 href: ../../fundamentals/code-analysis/style-rules/ide1005.md - name: IDE2000 From 1806686bb2c9ec55d80ba890aa1f29c79b4e20e5 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:24:04 -0800 Subject: [PATCH 6/7] update category --- .../code-analysis/style-rules/ide0380.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0380.md b/docs/fundamentals/code-analysis/style-rules/ide0380.md index 448ebba8afbc4..a42dc99114354 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0380.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0380.md @@ -12,14 +12,14 @@ ai-usage: ai-assisted --- # Remove unnecessary `unsafe` modifier (IDE0380) -| Property | Value | -|--------------------------|-------------------------------------------| -| **Rule ID** | IDE0380 | -| **Title** | Remove unnecessary `unsafe` modifier | -| **Category** | Style | -| **Subcategory** | Unnecessary code rules | -| **Applicable languages** | C# | -| **Options** | None | +| Property | Value | +|--------------------------|-----------------------------------------------| +| **Rule ID** | IDE0380 | +| **Title** | Remove unnecessary `unsafe` modifier | +| **Category** | Style | +| **Subcategory** | Unnecessary code rules (modifier preferences) | +| **Applicable languages** | C# | +| **Options** | None | ## Overview From 3402b37113ba027c48d4c8696742ebcfc4939ac8 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 10 Nov 2025 08:42:59 -0800 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Bill Wagner Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/fundamentals/code-analysis/style-rules/ide0360.md | 2 +- docs/fundamentals/code-analysis/style-rules/language-rules.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0360.md b/docs/fundamentals/code-analysis/style-rules/ide0360.md index bf240867b475c..8e28ae61771be 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0360.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0360.md @@ -45,7 +45,7 @@ Options specify the behavior that you want the rule to enforce. For information public int Prop { get { return field; } - set { field = value; } + set { field = (value > 0) ? value : throw new ArgumentException(); } } // Fixed code. diff --git a/docs/fundamentals/code-analysis/style-rules/language-rules.md b/docs/fundamentals/code-analysis/style-rules/language-rules.md index bd2e2520186f9..6ca1f966d419c 100644 --- a/docs/fundamentals/code-analysis/style-rules/language-rules.md +++ b/docs/fundamentals/code-analysis/style-rules/language-rules.md @@ -263,7 +263,7 @@ C# style rules: C# style rules: -- [Remove unnecessary suppression (IDE0370)](ide0370.md) +- [Remove unnecessary suppression (null-forgiving operator) (IDE0370)](ide0370.md) ### `This.` and `me.` preferences