Skip to content

[automated] Merge branch 'main' => 'release/dev18.0' #18481

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

Merged
merged 5 commits into from
Apr 24, 2025
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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Core/9.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### Added
* Added nullability annotations to `.Using` builder method for `async` and `task` builders ([PR #18292](https://github.com/dotnet/fsharp/pull/18292))
* Support for `and!` in `TaskBuilder` ([LanguageSuggestion #1363](https://github.com/fsharp/fslang-suggestions/issues/1363), [PR #18451](https://github.com/dotnet/fsharp/pull/18451))

### Changed

Expand Down
9 changes: 9 additions & 0 deletions eng/Publishing.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<!-- Update Artifacts with Kind=Package to have additional metadata item Category="ToolingPackage".
Depending on channel configuration, this means that these assets could be pushed to a different feed. -->
<ItemGroup>
<Artifact Update="@(Artifact->WithMetadataValue('Kind', 'Package'))" Category="ToolingPackage" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Dependencies>
<Source Uri="https://github.com/dotnet/dotnet" Mapping="fsharp" Sha="721dc7a2a59416b21fc49447d264009d708d6000" BarId="265489" />
<ProductDependencies>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25209.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25223.3">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>7dbf5deea5bdccf513df73cba179c4c0ad106010</Sha>
<Sha>19eb5ea4e5f9c4e5256843a92805c8c9e942207d</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
Expand Down
407 changes: 81 additions & 326 deletions src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/FSharp.Core/fslib-extra-pervasives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ module ExtraTopLevelOperators =
[<assembly: AutoOpen("Microsoft.FSharp.Collections")>]
[<assembly: AutoOpen("Microsoft.FSharp.Control")>]
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.LowPriority")>]
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.LowPlusPriority")>]
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.MediumPriority")>]
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.HighPriority")>]
[<assembly: AutoOpen("Microsoft.FSharp.Linq.QueryRunExtensions.LowPriority")>]
Expand Down
280 changes: 280 additions & 0 deletions src/FSharp.Core/tasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,48 @@ module LowPriority =
=
ResumableCode.Using(resource, body)

type TaskBuilder with
member inline this.MergeSources< ^TaskLike1, ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter1, ^Awaiter2
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
and ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
and ^Awaiter1 :> ICriticalNotifyCompletion
and ^Awaiter2 :> ICriticalNotifyCompletion
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
and ^Awaiter1: (member GetResult: unit -> ^TResult1)
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
and ^Awaiter2: (member GetResult: unit -> ^TResult2)>
(task1: ^TaskLike1, task2: ^TaskLike2)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

type BackgroundTaskBuilder with
member inline this.MergeSources< ^TaskLike1, ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter1, ^Awaiter2
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
and ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
and ^Awaiter1 :> ICriticalNotifyCompletion
and ^Awaiter2 :> ICriticalNotifyCompletion
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
and ^Awaiter1: (member GetResult: unit -> ^TResult1)
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
and ^Awaiter2: (member GetResult: unit -> ^TResult2)>
(task1: ^TaskLike1, task2: ^TaskLike2)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

module HighPriority =

// High priority extensions
type TaskBuilderBase with

Expand Down Expand Up @@ -424,7 +465,36 @@ module HighPriority =
member inline this.ReturnFrom(task: Task<'T>) : TaskCode<'T, 'T> =
this.Bind(task, this.Return)

type TaskBuilder with

// This overload is required for type inference in tasks cases
member inline this.MergeSources
(task1: Task< ^TResult1 >, task2: Task< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

type BackgroundTaskBuilder with

// This overload is required for type inference in tasks cases
member inline this.MergeSources
(task1: Task< ^TResult1 >, task2: Task< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

module MediumPriority =
open LowPriority
open HighPriority

// Medium priority extensions
Expand All @@ -437,3 +507,213 @@ module MediumPriority =

member inline this.ReturnFrom(computation: Async<'T>) : TaskCode<'T, 'T> =
this.ReturnFrom(Async.StartImmediateAsTask computation)

type TaskBuilder with

// This overload is required for type inference in tasks cases
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
and ^Awaiter2 :> ICriticalNotifyCompletion
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
(task1: Task< ^TResult1 >, task2: ^TaskLike2)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in tasks cases
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
and ^Awaiter1 :> ICriticalNotifyCompletion
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
(task1: ^TaskLike1, task2: Task< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in async cases
member inline this.MergeSources
(computation1: Async< ^TResult1 >, computation2: Async< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
computation1,
fun (result1: ^TResult1) ->
this.Bind(computation2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in task + async cases
member inline this.MergeSources
(task: Task< ^TResult1 >, computation: Async< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task,
fun (result1: ^TResult1) ->
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in async + task case
member inline this.MergeSources
(computation: Async< ^TResult1 >, task: Task< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
computation,
fun (result1: ^TResult1) ->
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

type BackgroundTaskBuilder with

// This overload is required for type inference in tasks cases
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
and ^Awaiter2 :> ICriticalNotifyCompletion
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
(task1: Task< ^TResult1 >, task2: ^TaskLike2)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in tasks cases
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
and ^Awaiter1 :> ICriticalNotifyCompletion
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
(task1: ^TaskLike1, task2: Task< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task1,
fun (result1: ^TResult1) ->
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in async cases
member inline this.MergeSources
(computation1: Async< ^TResult1 >, computation2: Async< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
computation1,
fun (result1: ^TResult1) ->
this.Bind(computation2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in task + async cases
member inline this.MergeSources
(task: Task< ^TResult1 >, computation: Async< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task,
fun (result1: ^TResult1) ->
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in async + task case
member inline this.MergeSources
(computation: Async< ^TResult1 >, task: Task< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
computation,
fun (result1: ^TResult1) ->
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

module LowPlusPriority =
open LowPriority
open MediumPriority

type TaskBuilder with
// This overload is required for type inference in async cases
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
and ^Awaiter2 :> ICriticalNotifyCompletion
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
(computation: Async< ^TResult1 >, task: ^TaskLike2)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
computation,
fun (result1: ^TResult1) ->
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in async cases
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
and ^Awaiter1 :> ICriticalNotifyCompletion
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
(task: ^TaskLike1, computation: Async< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task,
fun (result1: ^TResult1) ->
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

type BackgroundTaskBuilder with
// This overload is required for type inference in async cases
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
and ^Awaiter2 :> ICriticalNotifyCompletion
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
(computation: Async< ^TResult1 >, task: ^TaskLike2)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
computation,
fun (result1: ^TResult1) ->
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)

// This overload is required for type inference in async cases
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
and ^Awaiter1 :> ICriticalNotifyCompletion
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
(task: ^TaskLike1, computation: Async< ^TResult2 >)
: Task<struct (^TResult1 * ^TResult2)> =
this.Run(
this.Bind(
task,
fun (result1: ^TResult1) ->
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
)
)
Loading
Loading