Code inspection: Use type annotation syntax
This inspection reports JetBrains nullability attributes such as [CanBeNull] and [NotNull] when the same nullability can be expressed directly with nullable reference type syntax. When nullable reference types are enabled, the type declaration itself is usually the clearest place to express nullability.
Example
using JetBrains.Annotations;
class C
{
[CanBeNull]
public string M() => null;
}
class C
{
public string? M() => null;
}
Quick-fix
Type-based nullability syntax is more idiomatic in modern C# and keeps the nullability information directly next to the type.
30 March 2026