dotnet / dotnet/roslyn

Unable to disable analyzer UseExpressionBodyDiagnosticAnalyzer with .editorconfig/globalconfig

Open
#78,096 1 comment 1 reaction 0 assignees View on GitHub
Area-Analyzers
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

**Version Used**:

.NET 8.0.407

**Steps to Reproduce**:

1. Enable analyzers
2. Disable IDE0021, IDE0022, IDE0023, IDE0024, IDE0025, IDE0026, IDE0027, IDE0061 (`dotnet_diagnostic.IDE0021.severity = None`)
3. Run solution build

**Diagnostic Id**:

IDE0021, IDE0022, IDE0023, IDE0024, IDE0025, IDE0026, IDE0027, IDE0061

**Expected Behavior**:

Analyzer UseExpressionBodyDiagnosticAnalyzer is disabled and didn't affect build.

**Actual Behavior**:

Binlog report that analyzer still in use:

```
Microsoft.CodeAnalysis.CSharp.UseExpressionBody.UseExpressionBodyDiagnosticAnalyzer (IDE0021, IDE0022, IDE0023, IDE0024, IDE0025, IDE0026, IDE0027, IDE0061) = 42.434 s
```

---

I faced same problem with IDE0005 but after adding 3 more rules I finally disabled it:

```
# Performance issues
# IDE0005 rule and associated
# Source: https://github.com/dotnet/roslyn/blob/main/src/Analyzers/Core/Analyzers/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs#L56
dotnet_diagnostic.IDE0005.severity = None
dotnet_diagnostic.IDE0005_gen.severity = None
dotnet_diagnostic.RemoveUnnecessaryImportsFixable.severity = None
dotnet_diagnostic.EnableGenerateDocumentationFile.severity = None
```

But now I tried all what I know:

1. Used both .globalconfig and .editorconfig
2. Check source code of analyzers, found group `DiagnosticSet(CSharpFeaturesResources.Apply_expression_block_body_preferences` and disabled all of analyzers
3. Added `dotnet_analyzer_diagnostic.category-Style.severity = none`
4. Tried both `csharp_style_expression_bodied_accessors = true` and `csharp_style_expression_bodied_accessors = true:none`. Tried to remove associated options from config.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.