JetBrains Rider 2026.1 Help

Code inspection: Replace with SingleOrDefault($args$)

This inspection reports a conditional expression that checks Any(...) before calling Single(...), and returns null when there is no match. That pattern is equivalent to SingleOrDefault(...).

Example

var item = items.Any(x => x.IsActive) ? items.Single(x => x.IsActive) : null;
var item = items.SingleOrDefault(x => x.IsActive);

Quick-fix

Replace the Any(...) ? Single(...) : null pattern with SingleOrDefault(...).

29 March 2026