bkoelman / ResharperCodeContractNullability

Reports diagnostics, helping you to annotate your source tree with (Item)NotNull / (Item)CanBeNull attributes.
https://www.jetbrains.com/resharper/help/Code_Analysis__Code_Annotations.html
Apache License 2.0
26 stars 4 forks source link

Warning where nullability annotation would be redundant (async Task) #20

Closed starkcolin closed 8 years ago

starkcolin commented 8 years ago

A nullability warning (RNUL) on a method with a signature async Task is redundant, as the Task object returned from this method can never be null.

When the method return type is Task (where T is a reference type), the annotation ItemNotNull/ItemCanBeNull makes sense, but the NotNull/CanBeNull annotation adds no value in this case. When the return type is simply Task, neither of those annotations make sense.

bkoelman commented 8 years ago

Nice catch!

I agree that RNUL should be removed from async methods.

For non-async methods the existing rules should still apply, I believe. Since returning a null task is allowed, so annotating them makes resharper report potential warnings:

image

starkcolin commented 8 years ago

Agreed that the warning should still be displayed for non-async methods.

bkoelman commented 8 years ago

This fix is included in https://github.com/bkoelman/ResharperCodeContractNullability/releases/tag/v1.0.5.