Skip to content

[RCS1264] roslynator_use_var = when_type_is_obvious should not report ReadOnlySpan<char> initialization from "" #1504

@sergey-rybalkin

Description

@sergey-rybalkin

Product and Version Used:

NuGet package v. 4.12.4

Steps to Reproduce:

in .editorconfig

roslynator_use_var = when_type_is_obvious

Code:

internal class Demo
{
    public static void ReadOnlyCharDemo()
    {
        ReadOnlySpan<char> span = "";
    }
}

Actual Behavior:

On the ReadOnlySpan<char> expression: RCS1264: Use 'var' or explicit type

Expected Behavior:
Applying suggested code fix to the code above generates var span = "" statement which changes span variable type to string. My guess is that variables declarations with assignment that have implicit type conversion should be ignored by this analyzer.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions