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

Use Microsoft.Bcl.AsyncInterfaces in netstandard2.0 (Allows IAsyncDisposable and IAsyncEnumerable) #250

Merged
merged 3 commits into from
Jan 31, 2024
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: 3 additions & 4 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
source https://api.nuget.org/v3/index.json


storage: none
lowest_matching: true
strategy: min
nuget FSharp.Core >= 6.0.1
nuget Hopac >= 0.5.1
nuget FSharp.Control.AsyncSeq >= 3.2.1
nuget Fable.Core >= 4.2.0
nuget IcedTasks >= 0.10.2
nuget IcedTasks >= 0.11.0
nuget Microsoft.SourceLink.GitHub prerelease copy_local: true


nuget Microsoft.Bcl.AsyncInterfaces >= 6.0.0 framework:netstandard2.0

group Test
source https://api.nuget.org/v3/index.json
Expand All @@ -27,6 +25,7 @@ nuget Fable.Core
nuget Fable.Mocha
nuget Fable.Python
nuget Fable.Pyxpecto
nuget Microsoft.Bcl.AsyncInterfaces >= 6.0.0

group Benchmarks
source https://api.nuget.org/v3/index.json
Expand Down
17 changes: 11 additions & 6 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ NUGET
FSharp.Core (6.0.1)
Hopac (0.5.1)
FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0
IcedTasks (0.10.2)
IcedTasks (0.11)
FSharp.Core (>= 6.0.1) - restriction: >= netstandard2.0
Microsoft.Bcl.AsyncInterfaces (5.0) - restriction: >= netstandard2.0
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net461) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1))
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: && (>= netstandard2.0) (< netstandard2.1)
Microsoft.Bcl.AsyncInterfaces (6.0) - restriction: == netstandard2.0
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net461) (&& (>= netstandard2.0) (< netstandard2.1))
Microsoft.Build.Tasks.Git (8.0) - copy_local: true
Microsoft.SourceLink.Common (8.0) - copy_local: true
Microsoft.SourceLink.GitHub (8.0) - copy_local: true
Microsoft.Build.Tasks.Git (>= 8.0)
Microsoft.SourceLink.Common (>= 8.0)
System.Runtime.CompilerServices.Unsafe (4.5.3) - restriction: || (&& (< monoandroid) (< netstandard1.0) (>= netstandard2.0) (< win8)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netstandard2.0)) (&& (< netstandard1.0) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= wp8))
System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (>= net461) (>= netstandard2.0)) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1))
System.Runtime.CompilerServices.Unsafe (4.5.3) - restriction: == netstandard2.0
System.Threading.Tasks.Extensions (4.5.4) - restriction: == netstandard2.0
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< win8)) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= wp8)

GROUP Benchmarks
Expand Down Expand Up @@ -893,6 +894,8 @@ NUGET
FSharp.Core (7.0.402)
Hopac (0.5.1) - restriction: >= net6.0
FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0
Microsoft.Bcl.AsyncInterfaces (6.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net461) (&& (>= netstandard2.0) (< netstandard2.1))
Microsoft.CodeCoverage (17.8) - restriction: || (>= net462) (>= netcoreapp3.1)
Microsoft.NET.Test.Sdk (17.8)
Microsoft.CodeCoverage (>= 17.8) - restriction: || (>= net462) (>= netcoreapp3.1)
Expand All @@ -915,7 +918,9 @@ NUGET
System.Reflection.Metadata (8.0) - restriction: >= netcoreapp3.1
System.Collections.Immutable (>= 8.0) - restriction: || (>= net462) (>= netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0))
System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (>= monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (< netcoreapp2.1) (>= netcoreapp3.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard2.0)) (&& (>= monotouch) (>= netcoreapp3.1)) (&& (>= net45) (>= netcoreapp3.1) (< netstandard2.0)) (&& (>= net461) (>= netcoreapp3.1)) (&& (>= net462) (>= net6.0)) (&& (>= net462) (>= netcoreapp3.1)) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinios)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinmac)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarintvos)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinwatchos)) (&& (< netcoreapp2.0) (>= netcoreapp3.1)) (&& (>= netcoreapp3.1) (< netstandard1.1) (>= win8)) (&& (>= netcoreapp3.1) (< netstandard2.0) (>= wpa81)) (&& (>= netcoreapp3.1) (>= uap10.1))
System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (>= monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (< netcoreapp2.1) (>= netcoreapp3.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard2.0)) (&& (< monoandroid) (< netstandard1.0) (>= netstandard2.0) (< win8)) (&& (>= monotouch) (>= netcoreapp3.1)) (&& (>= net45) (>= netcoreapp3.1) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (>= net462) (>= net6.0)) (&& (>= net462) (>= netcoreapp3.1)) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinios)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinmac)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarintvos)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinwatchos)) (&& (< netcoreapp2.0) (>= netcoreapp3.1)) (&& (>= netcoreapp3.1) (< netstandard1.1) (>= win8)) (&& (>= netcoreapp3.1) (< netstandard2.0) (>= wpa81)) (&& (>= netcoreapp3.1) (>= uap10.1)) (&& (< netstandard1.0) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= wp8))
System.Threading.Tasks.Extensions (4.5.4) - restriction: || (>= net461) (&& (>= netstandard2.0) (< netstandard2.1))
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< win8)) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= wp8)
YoloDev.Expecto.TestSdk (0.14.3)
Expecto (>= 10.0 < 11.0) - restriction: >= net6.0
FSharp.Core (>= 7.0.200) - restriction: >= net6.0
Expand Down
1 change: 1 addition & 0 deletions src/FsToolkit.ErrorHandling.AsyncSeq/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Microsoft.SourceLink.GitHub
FSharp.Core
FSharp.Control.AsyncSeq
Microsoft.Bcl.AsyncInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ module CancellableTaskResultCE =
)
)

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
member inline internal this.TryFinallyAsync
(
body: CancellableTaskResultCode<'TOverall, 'Error, 'T>,
Expand Down Expand Up @@ -239,7 +238,7 @@ module CancellableTaskResultCE =
ValueTask()
)
)
#endif

member inline this.Source
(ctr: CancellableTaskResult<'T, 'Error>)
: CancellableTaskResult<'T, 'Error> =
Expand All @@ -258,10 +257,9 @@ module CancellableTaskResultCE =
|> Async.map Result.ofChoice
|> this.Source

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
member inline _.Source(t: ValueTask<Result<_, _>>) : CancellableTaskResult<'T, 'Error> =
cancellableTask { return! t }
#endif

member inline _.Source(result: Result<_, _>) : CancellableTaskResult<_, _> =
CancellableTask.singleton result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ module CancellableTaskValidationCE =
)
)
)
#if NETSTANDARD2_1 || NET6_0_OR_GREATER

member inline internal this.TryFinallyAsync
(
[<InlineIfLambda>] body: CancellableTaskValidationCode<'TOverall, 'Error, 'T>,
Expand Down Expand Up @@ -238,7 +238,6 @@ module CancellableTaskValidationCE =
ValueTask()
)
)
#endif

[<NoEagerConstraintApplication>]
static member inline BindDynamic
Expand Down
1 change: 1 addition & 0 deletions src/FsToolkit.ErrorHandling.IcedTasks/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Microsoft.SourceLink.GitHub
FSharp.Core
IcedTasks
Microsoft.Bcl.AsyncInterfaces
1 change: 1 addition & 0 deletions src/FsToolkit.ErrorHandling.JobResult/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Microsoft.SourceLink.GitHub
FSharp.Core
Hopac
Microsoft.Bcl.AsyncInterfaces
6 changes: 2 additions & 4 deletions src/FsToolkit.ErrorHandling.TaskResult/Task.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ module Task =
return! f x
}

#if NETSTANDARD2_1 || NET6_0_OR_GREATER

let inline bindV ([<InlineIfLambda>] f: 'a -> Task<'b>) (x: ValueTask<'a>) =
task {
let! x = x
return! f x
}
#endif

let inline apply f x =
bind (fun f' -> bind (fun x' -> singleton (f' x')) x) f

Expand All @@ -32,14 +32,12 @@ module Task =
>> singleton
)

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
let inline mapV ([<InlineIfLambda>] f) x =
x
|> bindV (
f
>> singleton
)
#endif

let inline map2 ([<InlineIfLambda>] f) x y = (apply (apply (singleton f) x) y)

Expand Down
10 changes: 1 addition & 9 deletions src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ open System
open System.Threading.Tasks



open System
open System.Runtime.CompilerServices
open System.Threading
Expand Down Expand Up @@ -153,7 +152,6 @@ type TaskOptionBuilderBase() =
)
)

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
member inline internal this.TryFinallyAsync
(
body: TaskOptionCode<'TOverall, 'T>,
Expand Down Expand Up @@ -213,20 +211,16 @@ type TaskOptionBuilderBase() =
ValueTask()
)
)
#endif

member inline this.Source(computation: Async<'T option>) : TaskOption<'T> =
computation
|> Async.StartImmediateAsTask

member inline this.Source(taskOption: TaskOption<'T>) : TaskOption<'T> = taskOption


#if NETSTANDARD2_1 || NET6_0_OR_GREATER

member inline this.Source(taskOption: ValueTask<'T option>) : TaskOption<'T> =
taskOption.AsTask()
#endif


type TaskOptionBuilder() =

Expand Down Expand Up @@ -607,7 +601,6 @@ module TaskOptionCEExtensionsMediumPriority =
return Some()
}

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
member inline this.Source(t: ValueTask<'T>) : TaskOption<'T> =
t
|> Task.mapV Some
Expand All @@ -617,7 +610,6 @@ module TaskOptionCEExtensionsMediumPriority =
do! t
return Some()
}
#endif

member inline this.Source(opt: Option<'T>) : TaskOption<'T> = Task.FromResult opt

Expand Down
7 changes: 2 additions & 5 deletions src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ open System
open System.Threading.Tasks



open System
open System.Runtime.CompilerServices
open System.Threading
Expand Down Expand Up @@ -153,7 +152,6 @@ type TaskResultBuilderBase() =
)
)

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
member inline internal this.TryFinallyAsync
(
body: TaskResultCode<'TOverall, 'Error, 'T>,
Expand Down Expand Up @@ -215,7 +213,7 @@ type TaskResultBuilderBase() =
ValueTask()
)
)
#endif


member inline this.Source(taskResult: TaskResult<'T, 'Error>) : TaskResult<'T, 'Error> =
taskResult
Expand All @@ -224,9 +222,8 @@ type TaskResultBuilderBase() =
result
|> Async.StartImmediateAsTask

#if NETSTANDARD2_1 || NET6_0_OR_GREATER
member inline _.Source(t: ValueTask<Result<_, _>>) : Task<Result<_, _>> = task { return! t }
#endif

member inline _.Source(result: Result<_, _>) : Task<Result<_, _>> = Task.singleton result

member inline _.Source(result: Choice<_, _>) : Task<Result<_, _>> =
Expand Down
1 change: 1 addition & 0 deletions src/FsToolkit.ErrorHandling.TaskResult/paket.references
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FSharp.Core
Microsoft.SourceLink.GitHub
Microsoft.Bcl.AsyncInterfaces
5 changes: 1 addition & 4 deletions src/FsToolkit.ErrorHandling/AsyncOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ module AsyncOptionCE =
[<InlineIfLambda>] compensation: unit -> unit
) : Async<'value option> =
async.TryFinally(computation, compensation)


#if NETSTANDARD2_1

#if !FABLE_COMPILER
member inline _.TryFinallyAsync
(
computation: Async<'value option>,
Expand Down
6 changes: 1 addition & 5 deletions src/FsToolkit.ErrorHandling/AsyncResultCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ module AsyncResultCE =
[<InlineIfLambda>] compensation: unit -> unit
) : Async<Result<'ok, 'error>> =
async.TryFinally(computation, compensation)

#if NETSTANDARD2_1

#if !FABLE_COMPILER
member inline _.TryFinallyAsync
(
computation: Async<Result<'ok, 'error>>,
Expand Down Expand Up @@ -91,8 +89,6 @@ module AsyncResultCE =
)
)
#endif


member inline this.While
(
[<InlineIfLambda>] guard: unit -> bool,
Expand Down
7 changes: 1 addition & 6 deletions src/FsToolkit.ErrorHandling/AsyncResultOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ module AsyncResultOptionCE =
[<InlineIfLambda>] compensation: unit -> unit
) : AsyncResultOption<'ok, 'error> =
async.TryFinally(computation, compensation)


#if NETSTANDARD2_1

#if !FABLE_COMPILER
member inline _.TryFinallyAsync
(
computation: AsyncResultOption<'ok, 'error>,
Expand All @@ -66,7 +63,6 @@ module AsyncResultOptionCE =

Async.TryFinallyAsync(computation, compensation)


member inline this.Using
(
resource: 'ok :> IAsyncDisposable,
Expand All @@ -83,7 +79,6 @@ module AsyncResultOptionCE =
)
#endif


member inline this.While
(
[<InlineIfLambda>] guard: unit -> bool,
Expand Down
1 change: 1 addition & 0 deletions src/FsToolkit.ErrorHandling/paket.references
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FSharp.Core
Microsoft.SourceLink.GitHub
Microsoft.Bcl.AsyncInterfaces
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<ProjectReference Include="../../src/FsToolkit.ErrorHandling/FsToolkit.ErrorHandling.fsproj">
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
<ProjectReference Include="../../src/FsToolkit.ErrorHandling.AsyncSeq/FsToolkit.ErrorHandling.AsyncSeq.fsproj">
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0'">
<ProjectReference Include="../../src/FsToolkit.ErrorHandling.AsyncSeq/FsToolkit.ErrorHandling.AsyncSeq.fsproj">
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AsyncSeq.fs" />
<Compile Include="Main.fs" />
<None Include="paket.references" />
<Watch Include="@(None)" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference
Include="../../src/FsToolkit.ErrorHandling.AsyncSeq/FsToolkit.ErrorHandling.AsyncSeq.fsproj">
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AsyncSeq.fs" />
<Compile Include="Main.fs" />
<None Include="paket.references" />
<Watch Include="@(None)" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ group Test
YoloDev.Expecto.TestSdk
Fable.Mocha
Fable.Pyxpecto
Microsoft.Bcl.AsyncInterfaces
4 changes: 0 additions & 4 deletions tests/FsToolkit.ErrorHandling.IcedTasks.Tests/Expect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ module Expect =

#endif

#if NETSTANDARD2_0 || NET6_0
open FSharp.Control.Tasks
#endif


#if FABLE_COMPILER
let isOk x message =
Expand Down
Loading