ReSharper 2024.1 Help

Code Inspection: Multiple nullable attributes usage

Category

Common Practices and Code Improvements

ID

MultipleNullableAttributesUsage

EditorConfig

resharper_multiple_nullable_attributes_usage_highlighting

Default severity

Warning

Language

C#, VB.NET

Requires SWA

No

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; }
Public Sub SetName(<CanBeNull> <NotNull> name As String) myName = name End Sub

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

Last modified: 15 April 2024