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

[RCS1264] roslynator_use_var = when_type_is_obvious should recognize StringBuilder #1435

Open
RenderMichael opened this issue Apr 4, 2024 · 0 comments

Comments

@RenderMichael
Copy link

Product and Version Used:

NuGet package v. 4.10.0

Steps to Reproduce:

in .editorconfig:

roslynator_use_var = when_type_is_obvious

Code:

internal class Demo
{
    public static string StringBuilderDemo(List<int> entries)
    {
        var sb = new StringBuilder("Entries: ")
            .Append(entries.Count)
            .Append('.');

        return sb.ToString();
    }
}

Actual Behavior:

On the var keyword: RCS1264: Use 'var' or explicit type

Expected Behavior:

The StringBuilder is a well-known type, and this is not an uncommon pattern in my experience.

Much like Parse(string) methods, StringBuilder's Append methods should be recognized as "obviously" returning StringBuilder.

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

No branches or pull requests

1 participant