First(), Last() or ElementAt() is called on a list or array, where indexing says the same

tx0/csharp:linq-on-indexablestrictwarningperformance/algorithmicdepth fastperformance

What it finds

On a variable declared as a list or array, items[0], items[^1] and items[i] reach the element directly, while the LINQ methods go through an interface check first. The variants that take a condition or a default are left alone.

From the rule's source, linq_on_indexable.rs.

Example from the rule's tests
using System.Collections.Generic;using System.Linq; class Queue{    int Head(List<int> items) => items.First();tx0 reports: First on a List<int>, which an index reaches directly     int Head(IEnumerable<int> items) => items.First();}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:linq-on-indexable" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:linq-on-indexable] reason="..."

tx0 explain tx0/csharp:linq-on-indexable shows the same in the terminal. Found a false positive? Report it.