JetBrains Rider 2024.1 Help

Code inspection: Redundant nullable warning suppression expression

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:

#nullable enable class Sample { void Test(string? one) { var two = one!; var three = two!; } }
Last modified: 27 May 2024