Code inspection: Declaration nullability inferred (parameter is inferred to be not null)
This inspection reports a parameter that control-flow analysis infers is never expected to be null. Typical cases are parameters that are immediately dereferenced, validated with ArgumentNullException, or consistently used as non-null throughout the method body. Adding [NotNull] makes that contract explicit for callers and for static analysis.
Example
In this example, the text parameter is validated with ArgumentNullException. The quick-fix suggests adding the [NotNull] attribute.
using System;
public class Parser
{
public void Parse(string text)
{
if (text == null)
throw new ArgumentNullException(nameof(text));
Console.WriteLine(text.Length);
}
}
using System;
using JetBrains.Annotations;
public class Parser
{
public void Parse([NotNull] string text)
{
if (text == null)
throw new ArgumentNullException(nameof(text));
Console.WriteLine(text.Length);
}
}
Quick-fix
Annotate the parameter with the inferred nullability attribute, usually [NotNull]. For container-like parameters, the quick-fix can use [ItemNotNull] instead.
28 March 2026