Skip to content

Commit 0a5fbf0

Browse files
committed
205 overload resolution (#252)
* Missed this in net8 additions * Fix overload resolution issues in Core * Fix overload resolution issues in Tasks/Hopac * Fix overload resolution issues in CancellableTaskResult * WIP: TaskValidtionCE * Wip merge sources * Fix MergeSources for CTValidation * cleanup * Ensure IAsyncDisposable tests * ignore nuget stuff
1 parent 0523aea commit 0a5fbf0

39 files changed

+3356
-1739
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
pull_request:
99
branches:
1010
- master
11+
workflow_dispatch:
1112

1213
jobs:
1314

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<DisableCheckingDuplicateNuGetItems>true</DisableCheckingDuplicateNuGetItems>
4-
<NoWarn>$(NoWarn);FS2003; NU1903</NoWarn>
4+
<NoWarn>$(NoWarn);FS2003; NU1903; NU1904</NoWarn>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66
<WarningsAsErrors />
77
</PropertyGroup>

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultBuilderBase.fs

Lines changed: 1365 additions & 0 deletions
Large diffs are not rendered by default.

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs

Lines changed: 260 additions & 646 deletions
Large diffs are not rendered by default.

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskValidationCE.fs

Lines changed: 909 additions & 865 deletions
Large diffs are not rendered by default.

src/FsToolkit.ErrorHandling.IcedTasks/FsToolkit.ErrorHandling.IcedTasks.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5+
<TargetFrameworks>net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
66
<LangVersion>preview</LangVersion>
77
<DebugType>portable</DebugType>
88
<NoWarn>FS3511;FS3513</NoWarn>
99
</PropertyGroup>
1010
<ItemGroup>
11+
<Compile Include="CancellableTaskResultBuilderBase.fs" />
1112
<Compile Include="CancellableTaskResultCE.fs" />
1213
<None Include="paket.references" />
1314
<Compile Include="CancellableTaskValidationCE.fs" />
1415
<Compile Include="CancellableTaskValidationOp.fs" />
15-
<Watch Include="@(None)" />
1616
</ItemGroup>
1717
<ItemGroup>
1818
<ProjectReference

src/FsToolkit.ErrorHandling.JobResult/JobOptionCE.fs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,6 @@ module JobOptionCE =
118118
/// </summary>
119119
member inline _.Source(job: Job<_ option>) : Job<_ option> = job
120120

121-
/// <summary>
122-
/// Method lets us transform data types into our internal representation.
123-
/// </summary>
124-
member inline _.Source(async: Async<_ option>) : Job<_ option> =
125-
async
126-
|> Job.fromAsync
127-
128-
/// <summary>
129-
/// Method lets us transform data types into our internal representation.
130-
/// </summary>
131-
member inline _.Source(task: Task<_ option>) : Job<_ option> =
132-
task
133-
|> Job.awaitTask
134121

135122
let jobOption = JobOptionBuilder()
136123

@@ -173,3 +160,24 @@ module JobOptionCEExtensions =
173160
a
174161
|> Job.awaitTask
175162
|> Job.map Some
163+
164+
[<AutoOpen>]
165+
// Having members as extensions gives them lower priority in
166+
// overload resolution and allows skipping more type annotations.
167+
module JobOptionCEExtensions2 =
168+
169+
type JobOptionBuilder with
170+
171+
/// <summary>
172+
/// Method lets us transform data types into our internal representation.
173+
/// </summary>
174+
member inline _.Source(async: Async<_ option>) : Job<_ option> =
175+
async
176+
|> Job.fromAsync
177+
178+
/// <summary>
179+
/// Method lets us transform data types into our internal representation.
180+
/// </summary>
181+
member inline _.Source(task: Task<_ option>) : Job<_ option> =
182+
task
183+
|> Job.awaitTask

src/FsToolkit.ErrorHandling.JobResult/JobResultCE.fs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,6 @@ module JobResultCE =
123123
/// </summary>
124124
member inline _.Source(job': Job<Result<_, _>>) : Job<Result<_, _>> = job'
125125

126-
/// <summary>
127-
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
128-
/// </summary>
129-
member inline _.Source(task: Task<Result<_, _>>) : Job<Result<_, _>> =
130-
task
131-
|> Job.awaitTask
132-
133-
/// <summary>
134-
/// Method lets us transform data types into our internal representation.
135-
/// </summary>
136-
member inline _.Source(result: Async<Result<_, _>>) : Job<Result<_, _>> =
137-
result
138-
|> Job.fromAsync
139-
140126
let jobResult = JobResultBuilder()
141127

142128
[<AutoOpen>]
@@ -194,3 +180,22 @@ module JobResultCEExtensions =
194180
t
195181
|> Job.awaitUnitTask
196182
|> Job.map Ok
183+
184+
185+
[<AutoOpen>]
186+
module JobResultCEExtensions2 =
187+
type JobResultBuilder with
188+
189+
/// <summary>
190+
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
191+
/// </summary>
192+
member inline _.Source(task: Task<Result<_, _>>) : Job<Result<_, _>> =
193+
task
194+
|> Job.awaitTask
195+
196+
/// <summary>
197+
/// Method lets us transform data types into our internal representation.
198+
/// </summary>
199+
member inline _.Source(result: Async<Result<_, _>>) : Job<Result<_, _>> =
200+
result
201+
|> Job.fromAsync

src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,8 @@ type TaskOptionBuilderBase() =
212212
)
213213
)
214214

215-
member inline this.Source(computation: Async<'T option>) : TaskOption<'T> =
216-
computation
217-
|> Async.StartImmediateAsTask
218-
219215
member inline this.Source(taskOption: TaskOption<'T>) : TaskOption<'T> = taskOption
220216

221-
member inline this.Source(taskOption: ValueTask<'T option>) : TaskOption<'T> =
222-
taskOption.AsTask()
223-
224-
225217
type TaskOptionBuilder() =
226218

227219
inherit TaskOptionBuilderBase()
@@ -617,3 +609,17 @@ module TaskOptionCEExtensionsMediumPriority =
617609
computation
618610
|> Async.map Some
619611
|> Async.StartImmediateAsTask
612+
613+
614+
[<AutoOpen>]
615+
module TaskOptionCEExtensionsHighPriority2 =
616+
617+
// Medium priority extensions
618+
type TaskOptionBuilderBase with
619+
620+
member inline this.Source(computation: Async<'T option>) : TaskOption<'T> =
621+
computation
622+
|> Async.StartImmediateAsTask
623+
624+
member inline this.Source(taskOption: ValueTask<'T option>) : TaskOption<'T> =
625+
taskOption.AsTask()

src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,6 @@ type TaskResultBuilderBase() =
218218
member inline this.Source(taskResult: TaskResult<'T, 'Error>) : TaskResult<'T, 'Error> =
219219
taskResult
220220

221-
member inline _.Source(result: Async<Result<_, _>>) : Task<Result<_, _>> =
222-
result
223-
|> Async.StartImmediateAsTask
224-
225-
member inline _.Source(t: ValueTask<Result<_, _>>) : Task<Result<_, _>> = task { return! t }
226-
227-
member inline _.Source(result: Result<_, _>) : Task<Result<_, _>> = Task.singleton result
228-
229-
member inline _.Source(result: Choice<_, _>) : Task<Result<_, _>> =
230-
result
231-
|> Result.ofChoice
232-
|> Task.singleton
233-
234221

235222
type TaskResultBuilder() =
236223

@@ -591,3 +578,23 @@ module TaskResultCEExtensionsMediumPriority =
591578
computation
592579
|> Async.map Ok
593580
|> Async.StartImmediateAsTask
581+
582+
[<AutoOpen>]
583+
module TaskResultCEExtensionsHighPriority2 =
584+
585+
// Medium priority extensions
586+
type TaskResultBuilderBase with
587+
588+
589+
member inline _.Source(result: Async<Result<_, _>>) : Task<Result<_, _>> =
590+
result
591+
|> Async.StartImmediateAsTask
592+
593+
member inline _.Source(t: ValueTask<Result<_, _>>) : Task<Result<_, _>> = task { return! t }
594+
595+
member inline _.Source(result: Result<_, _>) : Task<Result<_, _>> = Task.singleton result
596+
597+
member inline _.Source(result: Choice<_, _>) : Task<Result<_, _>> =
598+
result
599+
|> Result.ofChoice
600+
|> Task.singleton

0 commit comments

Comments
 (0)