Skip to content

Commit 733445a

Browse files
committed
Refactor namespaces and enhance module organization for IcedTasks components
1 parent 084f55c commit 733445a

17 files changed

+96
-30
lines changed

src/IcedTasks/AsyncEx.fs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
namespace IcedTasks
1+
namespace IcedTasks.AsyncEx
22

33
open System
44
open System.Threading
55
open System.Threading.Tasks
66
open System.Runtime.ExceptionServices
77
open System.Collections.Generic
8-
9-
type private Async =
8+
open IcedTasks.Nullness
9+
open IcedTasks.TaskLike
10+
type internal Async =
1011
static member inline map f x =
1112
async.Bind(x, (fun v -> async.Return(f v)))
1213

@@ -343,6 +344,7 @@ namespace IcedTasks.Polyfill.Async
343344
[<AutoOpen>]
344345
module PolyfillBuilders =
345346
open IcedTasks
347+
open IcedTasks.AsyncEx
346348

347349
/// <summary>
348350
/// Builds an asynchronous workflow using computation expression syntax.

src/IcedTasks/AutoOpens.fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace IcedTasks
2+
3+
/// Module exists to AutoOpen all relevant IcedTasks modules for ease of use when opening the main IcedTasks namespace.
4+
[<AutoOpen>]
5+
module AutoOpens =
6+
7+
[<assembly: AutoOpen("IcedTasks")>]
8+
[<assembly: AutoOpen("IcedTasks.TaskLike")>]
9+
[<assembly: AutoOpen("IcedTasks.TasksUnit")>]
10+
[<assembly: AutoOpen("IcedTasks.AsyncEx")>]
11+
[<assembly: AutoOpen("IcedTasks.ParallelAsync")>]
12+
[<assembly: AutoOpen("IcedTasks.TaskBase")>]
13+
[<assembly: AutoOpen("IcedTasks.ValueTasks")>]
14+
[<assembly: AutoOpen("IcedTasks.PoolingValueTasks")>]
15+
[<assembly: AutoOpen("IcedTasks.ValueTasksUnit")>]
16+
[<assembly: AutoOpen("IcedTasks.ColdTasks")>]
17+
[<assembly: AutoOpen("IcedTasks.CancellableTaskBase")>]
18+
[<assembly: AutoOpen("IcedTasks.CancellableValueTasks")>]
19+
[<assembly: AutoOpen("IcedTasks.CancellablePoolingValueTasks")>]
20+
[<assembly: AutoOpen("IcedTasks.CancellableTasks")>]
21+
do ()

src/IcedTasks/CancellablePoolingValueTask.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights
1010
// to this software to the public domain worldwide. This software is distributed without any warranty.
1111

12-
namespace IcedTasks
12+
namespace IcedTasks.CancellablePoolingValueTasks
13+
1314
#if NET6_0_OR_GREATER
1415

16+
open IcedTasks
17+
open IcedTasks.TaskLike
18+
open IcedTasks.CancellableTaskBase
19+
open IcedTasks.ValueTasks
20+
1521
/// Contains methods to build CancellableTasks using the F# computation expression syntax
1622
[<AutoOpen>]
1723
module CancellablePoolingValueTasks =
@@ -260,6 +266,8 @@ module CancellablePoolingValueTasks =
260266
/// <exclude />
261267
[<AutoOpen>]
262268
module HighPriority =
269+
270+
open IcedTasks.AsyncEx
263271

264272
type AsyncEx with
265273

@@ -330,6 +338,7 @@ module CancellablePoolingValueTasks =
330338
/// </summary>
331339
[<AutoOpen>]
332340
module AsyncExtensions =
341+
open IcedTasks.AsyncEx
333342
type AsyncExBuilder with
334343

335344
member inline this.Source([<InlineIfLambda>] t: CancellableValueTask<'T>) : Async<'T> =

src/IcedTasks/CancellableTask.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights
1010
// to this software to the public domain worldwide. This software is distributed without any warranty.
1111

12-
namespace IcedTasks
12+
namespace IcedTasks.CancellableTasks
1313

14+
open IcedTasks.TaskLike
15+
open IcedTasks.CancellableTaskBase
1416

1517
/// Contains methods to build CancellableTasks using the F# computation expression syntax
1618
[<AutoOpen>]
@@ -25,6 +27,7 @@ module CancellableTasks =
2527
open Microsoft.FSharp.Core.CompilerServices.StateMachineHelpers
2628
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
2729
open Microsoft.FSharp.Collections
30+
open IcedTasks
2831

2932
/// CancellationToken -> Task<'T>
3033
type CancellableTask<'T> = CancellationToken -> Task<'T>
@@ -333,6 +336,7 @@ module CancellableTasks =
333336
/// </summary>
334337
[<AutoOpen>]
335338
module AsyncExtensions =
339+
open IcedTasks.AsyncEx
336340

337341
type AsyncExBuilder with
338342

src/IcedTasks/CancellableTaskBuilderBase.fs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
namespace IcedTasks
1+
namespace IcedTasks.CancellableTaskBase
22

3+
open IcedTasks
4+
open IcedTasks.Nullness
5+
open IcedTasks.TaskLike
36
/// Contains methods to build Tasks using the F# computation expression syntax
47
[<AutoOpen>]
58
module CancellableTaskBase =
@@ -14,6 +17,7 @@ module CancellableTaskBase =
1417
open Microsoft.FSharp.Collections
1518
open System.Collections.Generic
1619

20+
1721
/// The extra data stored in ResumableStateMachine for tasks
1822
[<Struct; NoComparison; NoEquality>]
1923
type CancellableTaskBaseStateMachineData<'T, 'Builder> =
@@ -605,6 +609,7 @@ module CancellableTaskBase =
605609
/// <exclude/>
606610
[<AutoOpen>]
607611
module HighPriority =
612+
open IcedTasks.AsyncEx
608613

609614

610615
type AsyncEx with

src/IcedTasks/CancellableValueTask.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights
1010
// to this software to the public domain worldwide. This software is distributed without any warranty.
1111

12-
namespace IcedTasks
13-
12+
namespace IcedTasks.CancellableValueTasks
13+
open IcedTasks
14+
open IcedTasks.ValueTasks
15+
open IcedTasks.TaskLike
16+
open IcedTasks.CancellableTaskBase
1417

1518
/// Contains methods to build CancellableTasks using the F# computation expression syntax
1619
[<AutoOpen>]
@@ -243,6 +246,7 @@ module CancellableValueTasks =
243246
/// <exclude />
244247
[<AutoOpen>]
245248
module HighPriority =
249+
open IcedTasks.AsyncEx
246250

247251
type AsyncEx with
248252

@@ -313,6 +317,7 @@ module CancellableValueTasks =
313317
/// </summary>
314318
[<AutoOpen>]
315319
module AsyncExtensions =
320+
open IcedTasks.AsyncEx
316321
type AsyncExBuilder with
317322

318323
member inline this.Source([<InlineIfLambda>] t: CancellableValueTask<'T>) : Async<'T> =

src/IcedTasks/ColdTask.fs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights
1010
// to this software to the public domain worldwide. This software is distributed without any warranty.
1111

12-
namespace IcedTasks
12+
namespace IcedTasks.ColdTasks
13+
open IcedTasks
14+
open IcedTasks.Nullness
15+
open IcedTasks.TaskLike
16+
1317

1418
/// Contains methods to build ColdTasks using the F# computation expression syntax
1519
[<AutoOpen>]
@@ -633,6 +637,7 @@ module ColdTasks =
633637
/// <exclude />
634638
[<AutoOpen>]
635639
module HighPriority =
640+
open IcedTasks.AsyncEx
636641
// High priority extensions
637642

638643
type AsyncEx with
@@ -719,7 +724,7 @@ module ColdTasks =
719724
/// </summary>
720725
[<AutoOpen>]
721726
module AsyncExtensions =
722-
727+
open IcedTasks.AsyncEx
723728

724729
type AsyncExBuilder with
725730

@@ -753,7 +758,7 @@ module ColdTasks =
753758

754759
member inline this.ReturnFrom(coldTask: ColdTask) = this.ReturnFrom(coldTask ())
755760

756-
type TaskBuilderBase with
761+
type IcedTasks.TaskBase.TaskBase.TaskBuilderBase with
757762

758763
member inline this.Source(coldTask: ColdTask<'T>) = (coldTask ()).GetAwaiter()
759764

src/IcedTasks/IcedTasks.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Compile Include="CancellableValueTask.fs" />
2525
<Compile Include="CancellablePoolingValueTask.fs" />
2626
<Compile Include="CancellableTask.fs" />
27+
<Compile Include="AutoOpens.fs" />
2728
</ItemGroup>
2829

2930
<ItemGroup>

src/IcedTasks/Nullness.fs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
namespace IcedTasks
1+
namespace IcedTasks.Nullness
22

3-
open System
3+
// This file exists to define nullable and non-nullable types for compatibility with older FSharp.Core libraries.
4+
// Nullable/Nullness only works for FSharp.Core 9+. For older versions, we define types without nullability annotations and assume reference types can be null.
45

5-
type ExceptionNull =
6-
#if NULLABLE
7-
Exception | null
8-
#else
9-
Exception
10-
#endif
6+
open System
117

128
type IDisposableNull =
139
#if NULLABLE

src/IcedTasks/ParallelAsync.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
namespace IcedTasks
1+
namespace IcedTasks.ParallelAsync
22

33
open System
44
open System.Threading
5+
open IcedTasks.AsyncEx
56

67
/// Contains different implementations for parallel zip functions.
78
type ParallelAsync =

0 commit comments

Comments
 (0)