Skip to content

Commit cd4b7ab

Browse files
committed
Deprecate utils ValueTask.ofIValueTaskSource in favor of ValueTask.ofSource
1 parent 6cee5f4 commit cd4b7ab

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/FSharp.Control.TaskSeq/Utils.fs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ module ValueTaskExtensions =
1212
type ValueTask with
1313

1414
/// (Extension member) Gets a task that has already completed successfully.
15-
static member inline CompletedTask = Unchecked.defaultof<ValueTask>
15+
static member inline CompletedTask =
16+
// This mimics how it is done in .NET itself
17+
Unchecked.defaultof<ValueTask>
1618

1719

1820
module ValueTask =
@@ -26,10 +28,13 @@ module ValueTask =
2628
let inline FromResult (x: 'T) = ValueTask<'T> x
2729

2830
/// Creates a ValueTask with an IValueTaskSource representing the operation
29-
let inline ofIValueTaskSource taskSource version = ValueTask<bool>(taskSource, version)
31+
let inline ofSource taskSource version = ValueTask<bool>(taskSource, version)
32+
33+
[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
34+
let inline ofIValueTaskSource taskSource version = ofSource taskSource version
3035

3136
/// Creates a ValueTask form a Task<'T>
32-
let inline ofTask (task: Task<'T>) = ValueTask<'T>(task)
37+
let inline ofTask (task: Task<'T>) = ValueTask<'T> task
3338

3439
/// Ignore a ValueTask<'T>, returns a non-generic ValueTask.
3540
let inline ignore (vtask: ValueTask<'T>) =
@@ -86,7 +91,7 @@ module Task =
8691
}
8792

8893
/// Create a task from a value
89-
let inline fromResult (value: 'U) : Task<'U> = TaskBuilder.task { return value }
94+
let inline fromResult (value: 'U) : Task<'U> = Task.FromResult value
9095

9196
module Async =
9297
/// Convert an Task<'T> into an Async<'T>

src/FSharp.Control.TaskSeq/Utils.fsi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace FSharp.Control
22

3-
open System.Diagnostics
3+
open System
44
open System.Threading.Tasks
55
open System.Threading.Tasks.Sources
66

@@ -22,7 +22,17 @@ module ValueTask =
2222
/// Creates a ValueTask with the supplied result of the successful operation.
2323
val inline FromResult: x: 'T -> ValueTask<'T>
2424

25-
/// Creates a ValueTask with an IValueTaskSource representing the operation
25+
/// <summary>
26+
/// Initialized a new instance of <see cref="ValueTask" /> with an <see cref="IValueTaskSource" /> representing
27+
/// representing its operation.
28+
/// </summary>
29+
val inline ofSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>
30+
31+
/// <summary>
32+
/// The function <paramref name="ofIValueTaskSource" /> is deprecated since version 0.4.0,
33+
/// please use <paramref name="ofSource" /> in its stead. See <see cref="T:FSharp.Control.ValueTask.ofSource" />.
34+
/// </summary>
35+
[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
2636
val inline ofIValueTaskSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>
2737

2838
/// Creates a ValueTask form a Task<'T>

0 commit comments

Comments
 (0)