roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

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

Open sergey-rybalkin opened this issue 1 year ago • 0 comments
trafficstars

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.

sergey-rybalkin avatar Aug 19 '24 18:08 sergey-rybalkin