ReSharper 2024.1 Help

Code Inspection: Nullable attribute usage with declaration having value or void type

Category

Common Practices and Code Improvements

ID

AnnotationRedundancyAtValueType

EditorConfig

resharper_annotation_redundancy_at_value_type_highlighting

Default severity

Warning

Language

C#, VB.NET

Requires SWA

No

In the code snippet below, the NotNull annotation is meaningless.

public void SetAge([NotNull] int age) { myAge = age; }
Public Sub SetAge(<NotNull> age As Integer) myAge = age End Sub

The reason is that int cannot possibly be null, so any sort of indication that it is or is not null is redundant and can be removed. The same applies to methods that have a void return type.

Last modified: 15 April 2024