Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider disabling RCS0012 for fields #1395

Open
RenderMichael opened this issue Feb 15, 2024 · 1 comment
Open

Consider disabling RCS0012 for fields #1395

RenderMichael opened this issue Feb 15, 2024 · 1 comment

Comments

@RenderMichael
Copy link

Product and Version Used:

4.10.0

Steps to Reproduce:

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.

@josefpihrt
Copy link
Collaborator

josefpihrt commented Feb 15, 2024

Maybe the desired behavior could be achieved by adding editorconfig option, something like:

roslynator_blank_line_between_singleline_declarations.field = false
roslynator_blank_line_between_single_line_declarations.fields = false
roslynator_blank_line_between_single_line_declarations.field_declarations = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants