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

RCS1250 not detecting an obvious type situation #1202

Closed
eduardomezencio opened this issue Sep 12, 2023 · 0 comments · Fixed by #1205
Closed

RCS1250 not detecting an obvious type situation #1202

eduardomezencio opened this issue Sep 12, 2023 · 0 comments · Fixed by #1205
Assignees

Comments

@eduardomezencio
Copy link

eduardomezencio commented Sep 12, 2023

Product and Version Used: Roslynator.Analyzers 4.5.0, dotnet 7

Steps to Reproduce:
Consider that configuration is roslynator_object_creation_type_style = implicit_when_type_is_obvious.
In the following code:

// SomeType can be simply `public record SomeType;`
public record MyRecord(SomeType? Whatever = null)
{
    public SomeType Whatever { get; init; } = Whatever ?? new();
}

The new() gives RCS1250: Use explicit object creation. The example below behaves as expected, wihout raising the problem:

public record MyRecord
{
    public SomeType Whatever { get; init; } = new();
}

Actual Behavior: It raises the error in a situation where the type is obvious (considering that in my second example the new is considered obvious, the first is basically the same situation)

Expected Behavior: Not raising RCS1250 in my first example

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

Successfully merging a pull request may close this issue.

2 participants