Skip to content

Commit b899a67

Browse files
authored
Refactor Graph to speed up compile times (#59)
* Refactor namespaces and enhance module organization for IcedTasks components * Update fantomas version to 7.0.3 in dotnet-tools configuration
1 parent 084f55c commit b899a67

18 files changed

+103
-20
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"rollForward": false
1111
},
1212
"fantomas": {
13-
"version": "7.0.1",
13+
"version": "7.0.3",
1414
"commands": [
1515
"fantomas"
1616
],

src/IcedTasks/AsyncEx.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
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+
open IcedTasks.Nullness
9+
open IcedTasks.TaskLike
810

9-
type private Async =
11+
type internal Async =
1012
static member inline map f x =
1113
async.Bind(x, (fun v -> async.Return(f v)))
1214

@@ -343,6 +345,7 @@ namespace IcedTasks.Polyfill.Async
343345
[<AutoOpen>]
344346
module PolyfillBuilders =
345347
open IcedTasks
348+
open IcedTasks.AsyncEx
346349

347350
/// <summary>
348351
/// 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: 11 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 =
@@ -261,6 +267,8 @@ module CancellablePoolingValueTasks =
261267
[<AutoOpen>]
262268
module HighPriority =
263269

270+
open IcedTasks.AsyncEx
271+
264272
type AsyncEx with
265273

266274
/// <summary>Return an asynchronous computation that will wait for the given task to complete and return
@@ -330,6 +338,8 @@ module CancellablePoolingValueTasks =
330338
/// </summary>
331339
[<AutoOpen>]
332340
module AsyncExtensions =
341+
open IcedTasks.AsyncEx
342+
333343
type AsyncExBuilder with
334344

335345
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
namespace IcedTasks
1+
namespace IcedTasks.CancellableTaskBase
2+
3+
open IcedTasks
4+
open IcedTasks.Nullness
5+
open IcedTasks.TaskLike
26

37
/// Contains methods to build Tasks using the F# computation expression syntax
48
[<AutoOpen>]
@@ -14,6 +18,7 @@ module CancellableTaskBase =
1418
open Microsoft.FSharp.Collections
1519
open System.Collections.Generic
1620

21+
1722
/// The extra data stored in ResumableStateMachine for tasks
1823
[<Struct; NoComparison; NoEquality>]
1924
type CancellableTaskBaseStateMachineData<'T, 'Builder> =
@@ -605,6 +610,7 @@ module CancellableTaskBase =
605610
/// <exclude/>
606611
[<AutoOpen>]
607612
module HighPriority =
613+
open IcedTasks.AsyncEx
608614

609615

610616
type AsyncEx with

src/IcedTasks/CancellableValueTask.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
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.CancellableValueTasks
1313

14+
open IcedTasks
15+
open IcedTasks.ValueTasks
16+
open IcedTasks.TaskLike
17+
open IcedTasks.CancellableTaskBase
1418

1519
/// Contains methods to build CancellableTasks using the F# computation expression syntax
1620
[<AutoOpen>]
@@ -243,6 +247,7 @@ module CancellableValueTasks =
243247
/// <exclude />
244248
[<AutoOpen>]
245249
module HighPriority =
250+
open IcedTasks.AsyncEx
246251

247252
type AsyncEx with
248253

@@ -313,6 +318,8 @@ module CancellableValueTasks =
313318
/// </summary>
314319
[<AutoOpen>]
315320
module AsyncExtensions =
321+
open IcedTasks.AsyncEx
322+
316323
type AsyncExBuilder with
317324

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

src/IcedTasks/ColdTask.fs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
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+
14+
open IcedTasks
15+
open IcedTasks.Nullness
16+
open IcedTasks.TaskLike
17+
1318

1419
/// Contains methods to build ColdTasks using the F# computation expression syntax
1520
[<AutoOpen>]
@@ -633,6 +638,7 @@ module ColdTasks =
633638
/// <exclude />
634639
[<AutoOpen>]
635640
module HighPriority =
641+
open IcedTasks.AsyncEx
636642
// High priority extensions
637643

638644
type AsyncEx with
@@ -719,7 +725,7 @@ module ColdTasks =
719725
/// </summary>
720726
[<AutoOpen>]
721727
module AsyncExtensions =
722-
728+
open IcedTasks.AsyncEx
723729

724730
type AsyncExBuilder with
725731

@@ -753,7 +759,7 @@ module ColdTasks =
753759

754760
member inline this.ReturnFrom(coldTask: ColdTask) = this.ReturnFrom(coldTask ())
755761

756-
type TaskBuilderBase with
762+
type IcedTasks.TaskBase.TaskBase.TaskBuilderBase with
757763

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

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace IcedTasks
1+
namespace IcedTasks.Nullness
2+
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.
25

36
open System
47

0 commit comments

Comments
 (0)