Code inspection: [NotNull] or [CanBeNull] attribute is applied to a type that already has the same annotation from nullable reference types
This inspection reports nullability attributes such as [NotNull], [CanBeNull], [ItemNotNull], [ItemCanBeNull] when nullable reference type syntax already expresses the same information. Keeping both usually adds noise without improving the contract.
#nullable enable
using JetBrains.Annotations;
class C
{
[NotNull]
public string GetName() => "";
}
#nullable enable
class C
{
public string GetName() => "";
}
The same applies to collection element annotations when ? on the element type already describes the nullability.
13 April 2026