From b88153a26cb81f4ba97cdeb659e1004b801dcaee Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Sat, 6 Apr 2024 20:53:50 +0100 Subject: [PATCH] Cleanup CompletedTask --- src/FSharp.Control.TaskSeq/Utils.fs | 10 ++-------- src/FSharp.Control.TaskSeq/Utils.fsi | 4 +++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/FSharp.Control.TaskSeq/Utils.fs b/src/FSharp.Control.TaskSeq/Utils.fs index 63e0798..ec076f2 100644 --- a/src/FSharp.Control.TaskSeq/Utils.fs +++ b/src/FSharp.Control.TaskSeq/Utils.fs @@ -1,20 +1,15 @@ namespace FSharp.Control -open System.Threading.Tasks open System +open System.Threading.Tasks [] module ValueTaskExtensions = - /// Extensions for ValueTask that are not available in NetStandard 2.1, but are - /// available in .NET 5+. We put them in Extension space to mimic the behavior of NetStandard 2.1 type ValueTask with - - /// (Extension member) Gets a task that has already completed successfully. static member inline CompletedTask = - // This mimics how it is done in .NET itself + // This mimics how it is done in net5.0 and later internally Unchecked.defaultof - module ValueTask = let False = ValueTask() let True = ValueTask true @@ -38,7 +33,6 @@ module ValueTask = [] let inline ofIValueTaskSource taskSource version = ofSource taskSource version - module Task = let inline fromResult (value: 'U) : Task<'U> = Task.FromResult value let inline ofAsync (async: Async<'T>) = task { return! async } diff --git a/src/FSharp.Control.TaskSeq/Utils.fsi b/src/FSharp.Control.TaskSeq/Utils.fsi index aecada8..86d9dd4 100644 --- a/src/FSharp.Control.TaskSeq/Utils.fsi +++ b/src/FSharp.Control.TaskSeq/Utils.fsi @@ -6,9 +6,11 @@ open System.Threading.Tasks.Sources [] module ValueTaskExtensions = + + /// Shims back-filling .NET 5+ functionality for use on netstandard2.1 type ValueTask with - /// (Extension member) Gets a task that has already completed successfully. + /// (Extension member) Gets a ValueTask that has already completed successfully. static member inline CompletedTask: ValueTask module ValueTask =