From 67e9dad828687bb9e32e0f571d167a90a76991a2 Mon Sep 17 00:00:00 2001 From: Abel Braaksma Date: Sun, 5 Nov 2023 16:19:01 +0100 Subject: [PATCH 1/3] Deprecate utils `ValueTask.ofIValueTaskSource` in favor of `ValueTask.ofSource` --- src/FSharp.Control.TaskSeq/Utils.fs | 13 +++++++++---- src/FSharp.Control.TaskSeq/Utils.fsi | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) 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> From 3ab3bab880e208e762cb2afe058aa836c8d11bf5 Mon Sep 17 00:00:00 2001 From: Abel Braaksma Date: Sun, 5 Nov 2023 16:23:45 +0100 Subject: [PATCH 2/3] Deprecate `ValueTask.FromResult` in favor of `ValueTask.fromResult` --- src/FSharp.Control.TaskSeq/Utils.fs | 3 +++ src/FSharp.Control.TaskSeq/Utils.fsi | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/FSharp.Control.TaskSeq/Utils.fs b/src/FSharp.Control.TaskSeq/Utils.fs index 72deadb5..986880ec 100644 --- a/src/FSharp.Control.TaskSeq/Utils.fs +++ b/src/FSharp.Control.TaskSeq/Utils.fs @@ -25,6 +25,9 @@ module ValueTask = let True = ValueTask true /// Creates a ValueTask with the supplied result of the successful operation. + let inline fromResult (x: 'T) = ValueTask<'T> x + + [] let inline FromResult (x: 'T) = ValueTask<'T> x /// Creates a ValueTask with an IValueTaskSource representing the operation diff --git a/src/FSharp.Control.TaskSeq/Utils.fsi b/src/FSharp.Control.TaskSeq/Utils.fsi index 65e119d0..4aee1bca 100644 --- a/src/FSharp.Control.TaskSeq/Utils.fsi +++ b/src/FSharp.Control.TaskSeq/Utils.fsi @@ -20,6 +20,13 @@ module ValueTask = val True: ValueTask /// Creates a ValueTask with the supplied result of the successful operation. + val inline fromResult: x: 'T -> ValueTask<'T> + + /// + /// The function is deprecated since version 0.4.0, + /// please use in its stead. See . + /// + [] val inline FromResult: x: 'T -> ValueTask<'T> /// From 35735a26f01bcef22bce27dacec154190a57aea9 Mon Sep 17 00:00:00 2001 From: Abel Braaksma Date: Sun, 5 Nov 2023 16:37:23 +0100 Subject: [PATCH 3/3] Update `release-notes.txt` with these minor deprecations --- release-notes.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/release-notes.txt b/release-notes.txt index e901fc4b..8d13122e 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -2,9 +2,12 @@ Release notes: 0.4.x (unreleased) - overhaul all doc comments, add exceptions, improve editor experience, #136 - - DEPRECATED: 'taskSeq<_>' renamed to 'TaskSeq<_>', 'taskSeq' warns with FS0044, #187 - - BINARY INCOMPATIBILITY: 'TaskSeq' module is now static members on 'TaskSeq<_>', fixes #184 - Performance: less thread hops with 'StartImmediateAsTask' instead of 'StartAsTask', fixes #135 + - BINARY INCOMPATIBILITY: 'TaskSeq' module is now static members on 'TaskSeq<_>', fixes #184 + - DEPRECATIONS (these raise warning FS0044): + - type 'taskSeq<_>' is renamed to 'TaskSeq<_>', fixes #193 + - function 'ValueTask.ofIValueTaskSource` renamed to `ValueTask.ofSource`, fixes #193 + - function `ValueTask.FromResult` is renamed to `ValueTask.fromResult`, fixes #193 0.4.0-alpha.1 - fixes not calling Dispose for 'use!', 'use', or `finally` blocks #157 (by @bartelink)