ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Multiple nullable attributes usage

Last modified: 11 February 2024

NotNull and CanBeNull attributes can be used to indicate whether or not a parameter or a return value can be null. But consider the following code:

public void SetName([CanBeNull][NotNull]string name)
{
  myName = name;
}

This annotation does not make much sense since the two assertions contradict each other.