Gofer.NET icon indicating copy to clipboard operation
Gofer.NET copied to clipboard

Add TaskQueue.Enqueue(Expression<Func<T>>) to suppress warning CS4014

Open ArcticLampyrid opened this issue 4 years ago • 2 comments

https://github.com/brthor/Gofer.NET/blob/08a8bbd21f72776a5bd170aa0cd78340e2b8b3a5/Gofer.NET.Utils/ActionExtensionMethods.cs#L31 Since ToTaskInfo(this Expression<Func<T>>) is available, why not add TaskQueue.Enqueue(Expression<Func<T>>)? It's helpful to suppress warning CS4014 with async function.

CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the await operator to the result of the call.

At least TaskQueue.Enqueue(Expression<Func<Task>>) should be added.

ArcticLampyrid avatar Mar 03 '21 16:03 ArcticLampyrid

The intention is to eventually allow job return values to be fetched which is likely why TaskQueue.Enqueue(Expression<Func<T>>) was placed there.

(https://github.com/brthor/Gofer.NET/commit/16f8708e2a76ef402da6a27b7227e7aa6e9612ee)

As for the Compiler Warnings, there is a special extension method you can use to bypass them: https://github.com/brthor/Gofer.NET/blob/master/Gofer.NET.Utils/TaskExtensions.cs#L12

An example of this here: https://github.com/brthor/Gofer.NET/blob/master/Gofer.NET.Tests/GivenARedisTaskQueue.cs#L99

EDIT: For reference, the requested functionality was removed here: https://github.com/brthor/Gofer.NET/commit/510cf3ae117e9d4e1e6e65557e55ecc1d8333ed0#diff-2afb79e64d5ed88321d16c16d382ced69fbad41f713483e48b3a80cbadd1b881

brthor avatar Mar 04 '21 17:03 brthor

Though Expression<Func<T>> can be confusing and may be mistaken for the support for result-fetchable job, Expression<Func<Task>> can still be a acceptable choice.

ArcticLampyrid avatar Mar 06 '21 09:03 ArcticLampyrid