Add performance refactoring for IList Last, First or ElementAt
Nixxen opened this issue · comments
Odd Mathisen commented
Product and Version Used:
Visual Studio Professional 2022, 17.8.3
.Net 6.0
Rosslynator extension, 4.11.0
Index access versus list methods context: https://rules.sonarsource.com/csharp/RSPEC-6608/
Steps to Reproduce:
- Populate a list,
someList
. - Access the first element through
someList.First()
. - Access the third element through
someList.ElementAt(2)
. - Access the first element through
someList.Last()
.
Actual Behavior:
No suggestions.
Expected Behavior:
Suggestions:
someList[0];
someList[2];
someList[^1];
Josef Pihrt commented
First
and ElementAt
is already implemented as a part of RCS1246.
But Last
is not implemented yet, so that's good idea.