`[RCS1264]` `roslynator_use_var = when_type_is_obvious` should recognize `StringBuilder`
RenderMichael opened this issue · comments
Michael Render commented
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
.