Collection expressions are not considered "obvious" typing
RenderMichael opened this issue · comments
Michael Render commented
Product and Version Used:
4.10.0
Steps to Reproduce:
roslynator_object_creation_type_style = implicit_when_type_is_obvious
roslynator_array_creation_type_style = implicit_when_type_is_obvious
List<string> strings = [
"1", "2", "3"
]; // RCS1250
var x = new HasArray
{
Strings = [], // RCS1250 *and* RCS1014
};
internal class HasArray
{
public required string[] Strings { get; set; }
}
Actual Behavior:
RCS1250
: Use explicit object creation
RCS1014
: Use explicitly typed array
Expected Behavior:
As of C#12, there is no natural type for collection expressions, it's always target-type, and as such the type is always "obvious"