Code inspection: Replace with FirstOrDefault($args$)
This inspection reports a conditional expression that checks Any(...) before calling First(...), and returns null when there is no match. That pattern is equivalent to FirstOrDefault(...).
Example
var result = items.Any(x => x.IsValid) ? items.First(x => x.IsValid) : null;
var result = items.FirstOrDefault(x => x.IsValid);
Quick-fix
Replace the Any(...) ? First(...) : null pattern with FirstOrDefault(...).
29 March 2026