dotnet / dotnet/roslynator

Consider disabling `RCS0012` for fields

Open
#1,395 2 comments 2 reactions 1 assignee Claimed by @josefpihrt View on GitHub
Analyzer Options Area-Analyzers Feature Request
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

**Product and Version Used**:

4.10.0

**Steps to Reproduce**:

``` csharp
internal sealed class C
{
private readonly string? x; // RCS0012
private readonly string? y;

public C(string x, string y)
{
this.x = x;
this.y = y;
}

public void UseVariables()
{
// dismiss warnings about unused variable
_ = x;
_ = y;
}
}
```

**Actual Behavior**:
Warning `RCS0012`: Add blank lines between single-line declarations

**Expected Behavior**:
In contrast with properties and methods, fields are often written without a separate line between them. There is a case to be made that the analyzer should not warn in this case.

Perhaps it would at least be possible to make a different diagnostic for fields, so it can be separately suppressed.

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.