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: Redundant nullable warning suppression expression

Last modified: 27 May 2024

This inspection reports null-suppression operators ! on objects that are heuristically not nullable.

Although the redundant ! operator will not influence your code in any way, it may deteriorate readability as it makes non-nullable objects look as though they are nullable.

In the example below, the one parameter is nullable and we can use the ! operator on it, but the variable two initialized with the one! expression is not nullable and therefore using ! on it does not make any sense: