Code inspection: Annotation duplicate in hierarchy
This inspection reports a nullability annotation that repeats the same contract already inherited from a base member or implemented member.
This usually happens when an override or implementation adds [NotNull], [CanBeNull], or a similar annotation even though the base declaration already defines that nullability. The extra attribute does not add new information and can make the hierarchy noisier.
Example
using JetBrains.Annotations;
public class Base
{
[NotNull]
public virtual object CreateValue() => new object();
}
public class Derived : Base
{
[NotNull]
public override object CreateValue() => new object();
}
using JetBrains.Annotations;
public class Base
{
[NotNull]
public virtual object CreateValue() => new object();
}
public class Derived : Base
{
public override object CreateValue() => new object();
}
Quick-fix
A quick-fix helps you remove the redundant attribute from the derived declaration.
27 March 2026