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

Collection expressions are not considered "obvious" typing #1397

Open
RenderMichael opened this issue Feb 16, 2024 · 0 comments
Open

Collection expressions are not considered "obvious" typing #1397

RenderMichael opened this issue Feb 16, 2024 · 0 comments

Comments

@RenderMichael
Copy link

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"

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