Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate minor utility functions #194

Merged
merged 3 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions src/FSharp.Control.TaskSeq/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValueTask>
static member inline CompletedTask =
// This mimics how it is done in .NET itself
Unchecked.defaultof<ValueTask>


module ValueTask =
Expand All @@ -23,13 +25,19 @@ module ValueTask =
let True = ValueTask<bool> true

/// Creates a ValueTask with the supplied result of the successful operation.
let inline fromResult (x: 'T) = ValueTask<'T> x

[<Obsolete "From version 0.4.0 onward, 'ValueTask.FromResult' is deprecated in favor of 'ValueTask.fromResult'. It will be removed in an upcoming release.">]
let inline FromResult (x: 'T) = ValueTask<'T> x

/// Creates a ValueTask with an IValueTaskSource representing the operation
let inline ofIValueTaskSource taskSource version = ValueTask<bool>(taskSource, version)
let inline ofSource taskSource version = ValueTask<bool>(taskSource, version)

[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
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>) =
Expand Down Expand Up @@ -86,7 +94,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>
Expand Down
21 changes: 19 additions & 2 deletions src/FSharp.Control.TaskSeq/Utils.fsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace FSharp.Control

open System.Diagnostics
open System
open System.Threading.Tasks
open System.Threading.Tasks.Sources

Expand All @@ -20,9 +20,26 @@ module ValueTask =
val True: ValueTask<bool>

/// Creates a ValueTask with the supplied result of the successful operation.
val inline fromResult: x: 'T -> ValueTask<'T>

/// <summary>
/// The function <paramref name="FromResult" /> is deprecated since version 0.4.0,
/// please use <paramref name="fromSource" /> in its stead. See <see cref="T:FSharp.Control.ValueTask.fromResult" />.
/// </summary>
[<Obsolete "From version 0.4.0 onward, 'ValueTask.FromResult' is deprecated in favor of 'ValueTask.fromResult'. It will be removed in an upcoming release.">]
val inline FromResult: x: 'T -> ValueTask<'T>

/// Creates a ValueTask with an IValueTaskSource representing the operation
/// <summary>
/// Initialized a new instance of <see cref="ValueTask" /> with an <see cref="IValueTaskSource" /> representing
/// representing its operation.
/// </summary>
val inline ofSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>

/// <summary>
/// The function <paramref name="ofIValueTaskSource" /> is deprecated since version 0.4.0,
/// please use <paramref name="ofSource" /> in its stead. See <see cref="T:FSharp.Control.ValueTask.ofSource" />.
/// </summary>
[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
val inline ofIValueTaskSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>

/// Creates a ValueTask form a Task<'T>
Expand Down
Loading