diff --git a/src/FSharp.Control.TaskSeq/Utils.fs b/src/FSharp.Control.TaskSeq/Utils.fs index 58956610..72deadb5 100644 --- a/src/FSharp.Control.TaskSeq/Utils.fs +++ b/src/FSharp.Control.TaskSeq/Utils.fs @@ -12,7 +12,9 @@ module ValueTaskExtensions = type ValueTask with /// (Extension member) Gets a task that has already completed successfully. - static member inline CompletedTask = Unchecked.defaultof + static member inline CompletedTask = + // This mimics how it is done in .NET itself + Unchecked.defaultof module ValueTask = @@ -26,10 +28,13 @@ module ValueTask = let inline FromResult (x: 'T) = ValueTask<'T> x /// Creates a ValueTask with an IValueTaskSource representing the operation - let inline ofIValueTaskSource taskSource version = ValueTask(taskSource, version) + let inline ofSource taskSource version = ValueTask(taskSource, version) + + [] + let inline ofIValueTaskSource taskSource version = ofSource taskSource version /// Creates a ValueTask form a Task<'T> - let inline ofTask (task: Task<'T>) = ValueTask<'T>(task) + let inline ofTask (task: Task<'T>) = ValueTask<'T> task /// Ignore a ValueTask<'T>, returns a non-generic ValueTask. let inline ignore (vtask: ValueTask<'T>) = @@ -86,7 +91,7 @@ module Task = } /// Create a task from a value - let inline fromResult (value: 'U) : Task<'U> = TaskBuilder.task { return value } + let inline fromResult (value: 'U) : Task<'U> = Task.FromResult value module Async = /// Convert an Task<'T> into an Async<'T> diff --git a/src/FSharp.Control.TaskSeq/Utils.fsi b/src/FSharp.Control.TaskSeq/Utils.fsi index 219d8e0a..65e119d0 100644 --- a/src/FSharp.Control.TaskSeq/Utils.fsi +++ b/src/FSharp.Control.TaskSeq/Utils.fsi @@ -1,6 +1,6 @@ namespace FSharp.Control -open System.Diagnostics +open System open System.Threading.Tasks open System.Threading.Tasks.Sources @@ -22,7 +22,17 @@ module ValueTask = /// Creates a ValueTask with the supplied result of the successful operation. val inline FromResult: x: 'T -> ValueTask<'T> - /// Creates a ValueTask with an IValueTaskSource representing the operation + /// + /// Initialized a new instance of with an representing + /// representing its operation. + /// + val inline ofSource: taskSource: IValueTaskSource -> version: int16 -> ValueTask + + /// + /// The function is deprecated since version 0.4.0, + /// please use in its stead. See . + /// + [] val inline ofIValueTaskSource: taskSource: IValueTaskSource -> version: int16 -> ValueTask /// Creates a ValueTask form a Task<'T>