Code inspection: Declaration nullability inferred (parameter is inferred to be nullable)
This inspection reports a parameter that control-flow analysis infers may legitimately be null. This usually happens when the method checks the parameter for null, uses conditional access, or otherwise handles the null case explicitly. Adding [CanBeNull] documents that callers are allowed to pass null.
Example
In this example, the builder parameter is used with conditional access (?.). The quick-fix suggests adding the [CanBeNull] attribute.
using System.Text;
public class Formatter
{
public void WriteLine(StringBuilder builder)
{
builder?.AppendLine();
}
}
using System.Text;
using JetBrains.Annotations;
public class Formatter
{
public void WriteLine([CanBeNull] StringBuilder builder)
{
builder?.AppendLine();
}
}
Quick-fix
Annotate the parameter with the inferred nullability attribute, usually [CanBeNull]. For container-like parameters, the quick-fix can use [ItemCanBeNull] instead.
28 March 2026