ReSharper 2026.1 Help

Code inspection: Redundant nullable annotation on 'class?' constraint of type parameter constrained by non-nullable base type

This inspection reports a nullable annotation on a reference type constraint when another base-type constraint already guarantees that the type parameter is non-nullable. In that case, the ? on the class constraint is redundant or contradictory.

#nullable enable using System; class C { void M<T>() where T : class?, IDisposable { } }
#nullable enable using System; class C { void M<T>() where T : class, IDisposable { } }

Another quick-fix can instead annotate the constraining types as nullable when that better matches the intended generic contract.

13 April 2026