Code inspection: Declaration nullability inferred (type member is inferred to be nullable)
This inspection reports a method, property, indexer, or operator whose return value is inferred to be nullable. This usually means the member directly returns null on some paths, or yields nullable items in iterator or async-return scenarios. Adding [CanBeNull] makes that behavior explicit to callers and analysis tools.
Example
In this case, the method can return null. The quick-fix suggests annotating the method with the [CanBeNull] attribute.
public class Settings
{
public string FindName(bool exists)
{
return exists ? "Default" : null;
}
}
using JetBrains.Annotations;
public class Settings
{
[CanBeNull]
public string FindName(bool exists)
{
return exists ? "Default" : null;
}
}
Quick-fix
Annotate the member with the inferred nullability attribute, usually [CanBeNull]. For iterators and async methods returning container-like values, the quick-fix can use [ItemCanBeNull].
28 March 2026