ReSharper 2026.1 Help

Code inspection: Use nullable annotation instead of an attribute

This inspection reports nullability attributes such as [NotNull] or [CanBeNull] when the same meaning can be expressed directly with nullable reference type syntax. Using ? and non-nullable type syntax is usually shorter and easier to read than keeping separate attributes for the same information.

Example

using System.Diagnostics.CodeAnalysis; class C { [return: NotNull] public string? M() => ""; }
class C { public string M() => ""; }

Quick-fix

Replace the nullability attribute with nullable reference type syntax.

01 April 2026