bug(RCS1077): does not fire when a List has been inherited
dylanvdmerwe opened this issue · 0 comments
dylanvdmerwe commented
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.
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