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

bug(RCS1077): does not fire when a List has been inherited #1427

Closed
dylanvdmerwe opened this issue Mar 22, 2024 · 0 comments · Fixed by #1428
Closed

bug(RCS1077): does not fire when a List has been inherited #1427

dylanvdmerwe opened this issue Mar 22, 2024 · 0 comments · Fixed by #1428
Assignees

Comments

@dylanvdmerwe
Copy link

Product and Version Used:

  <ItemGroup>
    <PackageReference Include="roslynator.analyzers" Version="4.12.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="roslynator.formatting.analyzers" Version="4.12.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

Steps to Reproduce:

Correct when using a list directly.
image

However create a class that inherits from List, and the optimizer does not fire.

            TestCollection s  = ["one", "two", "three", "four", "five"];
            s.FirstOrDefault(x => x == "two"); // does not recommend to use Find here

    public class TestCollection : List<string>
    {

    }

Often clients in enterprise environments inherit from List, IList to create their own collections with helper methods in.

The expectation is that inheritance should be checked as well for Lists. Maybe this applies to other analyzers, not sure, but def in RCS1077

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