[AllowNull] attribute ignored by Resharper Follow
Resharper version = 2020.2.1
Consider the following code from a .Net Core 3.1 console application:
static void Main()
Test test = new Test
SomeProperty = null // R# warning: Possible null assignment.
public sealed class Test
public string SomeProperty
get => _someProperty;
value != null // R# warning: Expression is always true.
string _someProperty = "";
The [AllowNull] attribute tells the compiler that although the SomeProperty getter cannot return null,
the setter can accept null.
The C# compiler is happy with this, and does not issue any warnings or errors.
However, Resharper gives two incorrect warnings, as commented in the code above
("// R# warning: ...").
Is this a problem with Resharper, or have I configured Resharper incorrectly?
Please sign in to leave a comment.
Thanks for the report. It is a bug in the code analysis. However, it has already been fixed in 2020.3 branch, and the fix will be available in the first EAP build of ReSharper 2020.3 release cycle.
Great, thanks for the swift response!