OrderBy follows OrderBy, which discards the first ordering
What it finds
items.OrderBy(a => a.Name).OrderBy(a => a.Age) sorts by age only: the second sort replaces the first. ThenBy sorts by age within equal names.
From the rule's source, repeated_order_by.rs.
using System.Collections.Generic;using System.Linq; class People{ List<string> Sort(List<string> names) { var a = names.OrderBy(n => n.Length).OrderBy(n => n);tx0 reports: OrderBy after an ordering discards it var b = names.OrderBy(n => n.Length).ThenBy(n => n); return a.Concat(b).ToList(); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/csharp:repeated-order-by" = "off"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:repeated-order-by] reason="..."tx0 explain tx0/csharp:repeated-order-by shows the same in the terminal. Found a false positive? Report it.