Code inspection: Container nullability attribute usage with declaration of non-container type
This inspection reports container-item nullability annotations applied to a type that does not have nullable items.
Typical examples are [ItemNotNull] or [ItemCanBeNull] on value types or other non-container declarations. In those cases the annotation does not affect code analysis and only adds noise.
Example
In this example, the [ItemNotNull] annotation is applied to an int property. Since int is a value type and cannot be null, the annotation is redundant.
using JetBrains.Annotations;
public class Example
{
[ItemNotNull]
public int RetryCount => 3;
}
using JetBrains.Annotations;
public class Example
{
public int RetryCount => 3;
}
Quick-fix
The quick-fix removes the redundant container nullability annotation.
27 March 2026