BUG: Incorrect "return value never used" warning (R# 2019.1 EAP 4)

A non-async method which returns a Task (rather than a Task<T>) which is awaited displays an incorrect "return value is never used" error.


Eg:


static async Task Main() => await TestMe();
static Task TestMe() => Task.CompletedTask;


If the method is declared async, the warning goes away:


static async Task Main() => await TestMe();
static async Task TestMe() { await Task.CompletedTask; }


If the method returns a Task<T>, and the returned T is used, the warning goes away:


static async Task Main() { int x = await TestMe(); }
static Task<int> TestMe() => Task.FromResult(42);


This behaviour was not present in R# 2018.3.


NB: The warning appears in both VS2019 and VS2017, so it's not coming from Visual Studio.

1 comment
Official comment

Hello Richard!

 

Thank you for the feedback.

I've filed corresponding issue - https://youtrack.jetbrains.com/issue/RSRP-474168.

You are welcome to comment or vote for it.

Thank you.

 

Please sign in to leave a comment.