"Function never returns" doesn't differentiate async methods from regular methods

Consider the following method:

public static async void Foo()
{
    while (true)
    {
        await Task.Delay(100);
        Console.WriteLine("Hello");
    }
}

Resharper will complain about "Function never returns" where in fact it does return (with a Task, as soon as the first await is hit).
Yes, the task will never end, but that may be desirable for certain background tasks.

I think async methods require different handling, perhaps a different issue whose severity is lower by default (suggestion / hint).

Thanks!

2 comments
Comment actions Permalink

Hello Yosi,

  Thanks for the report. I filed a new ticket to YouTrack https://youtrack.jetbrains.com/issue/RSRP-425337.

Thanks!

0
Comment actions Permalink

Glad to be of assistance!

0

Please sign in to leave a comment.