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 default(T) when there is no match. That pattern is equivalent to SingleOrDefault(...).

Example

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

Quick-fix

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

29 March 2026