From 2892ec3445c095b85a82a564f767a02bef67f5a2 Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Tue, 17 Jan 2023 19:24:09 -0600 Subject: [PATCH] feat!: added cancellation token support to pipelines and operations --- examples/CopyFiles/CopyFilesPipeline.cs | 15 ++-- examples/CopyFiles/CopyFilesTest.cs | 7 +- .../CreateCalender.cs | 5 +- .../MfGames.Nitride.Calendar.csproj | 14 ++-- src/MfGames.Nitride.Feeds/CreateAtomFeed.cs | 5 +- .../MfGames.Nitride.Feeds.csproj | 12 +-- .../MfGames.Nitride.Generators.csproj | 8 +- .../SingletonComponentSourceGenerator.cs | 81 ++++++++++--------- .../ApplyStyleTemplate.cs | 5 +- .../IdentifyHandlebarsFromComponent.cs | 5 +- .../IdentifyHandlebarsFromContent.cs | 5 +- .../MfGames.Nitride.Handlebars.csproj | 12 +-- .../RenderContentTemplate.cs | 5 +- .../ConvertHtmlEntitiesToUnicode.cs | 5 +- .../MfGames.Nitride.Html.csproj | 4 +- src/MfGames.Nitride.IO/Contents/ReadFiles.cs | 10 ++- src/MfGames.Nitride.IO/Contents/WriteFiles.cs | 6 +- .../Directories/ClearDirectory.cs | 10 ++- .../FileSystemOperationBase.cs | 5 +- .../MfGames.Nitride.IO.csproj | 16 ++-- src/MfGames.Nitride.IO/Paths/AddPathPrefix.cs | 5 +- .../Paths/ChangePathExtension.cs | 5 +- .../Paths/LinkDirectChildren.cs | 5 +- .../Paths/MoveToIndexPath.cs | 5 +- .../Paths/RemovePathPrefix.cs | 5 +- src/MfGames.Nitride.IO/Paths/ReplacePath.cs | 6 +- .../MfGames.Nitride.Json.csproj | 6 +- .../ConvertMarkdownToBase.cs | 5 +- .../IdentifyMarkdown.cs | 5 +- .../MakeSingleLinkListItems.cs | 5 +- .../MfGames.Nitride.Markdown.csproj | 16 ++-- .../ApplySchedules.cs | 5 +- .../MfGames.Nitride.Temporal.Schedules.csproj | 12 +-- .../README.md | 6 +- .../CreateDateIndexes.cs | 5 +- .../FilterOutExpiredInstant.cs | 5 +- .../FilterOutFutureInstant.cs | 5 +- .../MfGames.Nitride.Temporal.csproj | 18 ++--- .../SetInstantFromComponent.cs | 5 +- .../SetInstantFromPath.cs | 5 +- .../MfGames.Nitride.Yaml.csproj | 6 +- src/MfGames.Nitride.Yaml/ParseYamlHeader.cs | 5 +- src/MfGames.Nitride/Commands/BuildCommand.cs | 6 +- .../Entities/CreateOrUpdateIndex.cs | 5 +- src/MfGames.Nitride/Entities/EntityScanner.cs | 5 +- .../Entities/LinkEntitySequence.cs | 5 +- src/MfGames.Nitride/IOperation.cs | 6 +- src/MfGames.Nitride/MfGames.Nitride.csproj | 32 ++++---- .../NitrideOperationExtensions.cs | 7 +- src/MfGames.Nitride/OperationBase.cs | 5 +- src/MfGames.Nitride/Pipelines/IPipeline.cs | 6 +- src/MfGames.Nitride/Pipelines/PipelineBase.cs | 7 +- .../Pipelines/PipelineManager.cs | 35 +++++--- .../Pipelines/PipelineRunner.cs | 12 +-- .../MfGames.Nitride.IO.Tests.csproj | 18 ++--- .../MfGames.Nitride.Json.Tests.csproj | 14 ++-- .../MfGames.Nitride.Markdown.Tests.csproj | 18 ++--- .../MfGames.Nitride.Slugs.Tests.csproj | 16 ++-- ...es.Nitride.Temporal.Schedules.Tests.csproj | 18 ++--- .../MfGames.Nitride.Temporal.Tests.csproj | 16 ++-- .../MfGames.Nitride.Tests.csproj | 16 ++-- .../MfGames.Nitride.Yaml.Tests.csproj | 14 ++-- 62 files changed, 386 insertions(+), 255 deletions(-) diff --git a/examples/CopyFiles/CopyFilesPipeline.cs b/examples/CopyFiles/CopyFilesPipeline.cs index 3e48edf..8a496f6 100644 --- a/examples/CopyFiles/CopyFilesPipeline.cs +++ b/examples/CopyFiles/CopyFilesPipeline.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using MfGames.Gallium; using MfGames.Nitride; @@ -43,7 +44,9 @@ public class CopyFilesPipeline : PipelineBase } /// - public override IAsyncEnumerable RunAsync(IEnumerable _) + public override IAsyncEnumerable RunAsync( + IEnumerable _, + CancellationToken cancellationToken = default) { // We don't care about the incoming entities which means we can // ignore them and use the entities from the ReadFiles operation @@ -73,8 +76,9 @@ public class CopyFilesPipeline : PipelineBase // read. Coming out of this, we will have one entity that fulfills: // // entity.Get == "/output/a.txt" - entities = entities.Run(this.removePathPrefix) - .Run(this.addPathPrefix); + entities = entities + .Run(this.removePathPrefix, cancellationToken) + .Run(this.addPathPrefix, cancellationToken); // Then we write out the files to the output. First we make sure we // clear out the output. This operation performs an action when it @@ -95,8 +99,9 @@ public class CopyFilesPipeline : PipelineBase // The third way is to use an extension on entities which lets us // chain calls, ala Gulp's pipelines. The below code does this along // with writing the files to the output. - entities = entities.Run(this.clearDirectory) - .Run(this.writeFiles); + entities = entities + .Run(this.clearDirectory, cancellationToken) + .Run(this.writeFiles, cancellationToken); // If we are chaining this pipeline into another, we return the // entities. Otherwise, we can just return an empty list. The diff --git a/examples/CopyFiles/CopyFilesTest.cs b/examples/CopyFiles/CopyFilesTest.cs index 7ca6ea6..60c4bcd 100644 --- a/examples/CopyFiles/CopyFilesTest.cs +++ b/examples/CopyFiles/CopyFilesTest.cs @@ -27,9 +27,10 @@ public class CopyFilesTest : NitrideTestBase public async Task Run() { // Figure out the paths for this test. - DirectoryInfo rootDir = - typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()! - .GetDirectory("examples/CopyFiles"); + DirectoryInfo rootDir = typeof(CopyFilesProgram) + .GetDirectory() + !.FindGitRoot()! + .GetDirectory("examples/CopyFiles"); DirectoryInfo outputDir = rootDir.GetDirectory("output"); FileInfo projectFile = rootDir.GetFile("CopyFiles.csproj"); diff --git a/src/MfGames.Nitride.Calendar/CreateCalender.cs b/src/MfGames.Nitride.Calendar/CreateCalender.cs index 1acda4b..db1dd21 100644 --- a/src/MfGames.Nitride.Calendar/CreateCalender.cs +++ b/src/MfGames.Nitride.Calendar/CreateCalender.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -57,7 +58,9 @@ public partial class CreateCalender : OperationBase public UPath? Path { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Calendar/MfGames.Nitride.Calendar.csproj b/src/MfGames.Nitride.Calendar/MfGames.Nitride.Calendar.csproj index f2a7916..e7da070 100644 --- a/src/MfGames.Nitride.Calendar/MfGames.Nitride.Calendar.csproj +++ b/src/MfGames.Nitride.Calendar/MfGames.Nitride.Calendar.csproj @@ -10,16 +10,16 @@ - - - + + + - - - - + + + + diff --git a/src/MfGames.Nitride.Feeds/CreateAtomFeed.cs b/src/MfGames.Nitride.Feeds/CreateAtomFeed.cs index 3673e12..4ff06ae 100644 --- a/src/MfGames.Nitride.Feeds/CreateAtomFeed.cs +++ b/src/MfGames.Nitride.Feeds/CreateAtomFeed.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -93,7 +94,9 @@ public partial class CreateAtomFeed : OperationBase public Func? GetUrl { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Feeds/MfGames.Nitride.Feeds.csproj b/src/MfGames.Nitride.Feeds/MfGames.Nitride.Feeds.csproj index 21b4f95..abcac48 100644 --- a/src/MfGames.Nitride.Feeds/MfGames.Nitride.Feeds.csproj +++ b/src/MfGames.Nitride.Feeds/MfGames.Nitride.Feeds.csproj @@ -10,15 +10,15 @@ - - - + + + - - - + + + diff --git a/src/MfGames.Nitride.Generators/MfGames.Nitride.Generators.csproj b/src/MfGames.Nitride.Generators/MfGames.Nitride.Generators.csproj index c1dace6..0ea3208 100644 --- a/src/MfGames.Nitride.Generators/MfGames.Nitride.Generators.csproj +++ b/src/MfGames.Nitride.Generators/MfGames.Nitride.Generators.csproj @@ -10,10 +10,10 @@ - - - - + + + + diff --git a/src/MfGames.Nitride.Generators/SingletonComponentSourceGenerator.cs b/src/MfGames.Nitride.Generators/SingletonComponentSourceGenerator.cs index e634570..e8abb53 100644 --- a/src/MfGames.Nitride.Generators/SingletonComponentSourceGenerator.cs +++ b/src/MfGames.Nitride.Generators/SingletonComponentSourceGenerator.cs @@ -42,46 +42,47 @@ public class SingletonComponentSourceGenerator // Create the namespace. SyntaxToken cls = cds.Identifier; - - buffer.AppendLine(string.Join( - "\n", - $"using MfGames.Gallium;", - $"", - $"namespace {unit.Namespace}", - $"{{", - $" public partial class {cls}", - $" {{", - $" static {cls}()", - $" {{", - $" Instance = new {cls}();", - $" }}", - $"", - $" private {cls}()", - $" {{", - $" }}", - $"", - $" public static {cls} Instance {{ get; }}", - $" }}", - $"", - $" public static class {cls}Extensions", - $" {{", - $" public static bool Has{cls}(this Entity entity)", - $" {{", - $" return entity.Has<{cls}>();", - $" }}", - $"", - $" public static Entity Remove{cls}(this Entity entity)", - $" {{", - $" return entity.Remove<{cls}>();", - $" }}", - $"", - $" public static Entity Set{cls}(this Entity entity)", - $" {{", - $" return entity.Set({cls}.Instance);", - $" }}", - $" }}", - $"}}", - "")); + + buffer.AppendLine( + string.Join( + "\n", + $"using MfGames.Gallium;", + $"", + $"namespace {unit.Namespace}", + $"{{", + $" public partial class {cls}", + $" {{", + $" static {cls}()", + $" {{", + $" Instance = new {cls}();", + $" }}", + $"", + $" private {cls}()", + $" {{", + $" }}", + $"", + $" public static {cls} Instance {{ get; }}", + $" }}", + $"", + $" public static class {cls}Extensions", + $" {{", + $" public static bool Has{cls}(this Entity entity)", + $" {{", + $" return entity.Has<{cls}>();", + $" }}", + $"", + $" public static Entity Remove{cls}(this Entity entity)", + $" {{", + $" return entity.Remove<{cls}>();", + $" }}", + $"", + $" public static Entity Set{cls}(this Entity entity)", + $" {{", + $" return entity.Set({cls}.Instance);", + $" }}", + $" }}", + $"}}", + "")); // Create the source text and write out the file. var sourceText = SourceText.From(buffer.ToString(), Encoding.UTF8); diff --git a/src/MfGames.Nitride.Handlebars/ApplyStyleTemplate.cs b/src/MfGames.Nitride.Handlebars/ApplyStyleTemplate.cs index ef58c44..fd142ed 100644 --- a/src/MfGames.Nitride.Handlebars/ApplyStyleTemplate.cs +++ b/src/MfGames.Nitride.Handlebars/ApplyStyleTemplate.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -46,7 +47,9 @@ public partial class ApplyStyleTemplate : OperationBase public IHandlebars? Handlebars { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Make sure we have sane data. this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromComponent.cs b/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromComponent.cs index f6589ac..d573d0a 100644 --- a/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromComponent.cs +++ b/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -27,7 +28,9 @@ public partial class IdentifyHandlebarsFromComponent : IOperation public Func HasHandlebarsTest { get; set; } = null!; /// - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromContent.cs b/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromContent.cs index b2f73b6..ade344f 100644 --- a/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromContent.cs +++ b/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromContent.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; using MfGames.Nitride.Contents; @@ -12,7 +13,9 @@ namespace MfGames.Nitride.Handlebars; public class IdentifyHandlebarsFromContent : IOperation { /// - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { return input.SelectEntity(this.ScanContent); } diff --git a/src/MfGames.Nitride.Handlebars/MfGames.Nitride.Handlebars.csproj b/src/MfGames.Nitride.Handlebars/MfGames.Nitride.Handlebars.csproj index 47c9801..0a87f06 100644 --- a/src/MfGames.Nitride.Handlebars/MfGames.Nitride.Handlebars.csproj +++ b/src/MfGames.Nitride.Handlebars/MfGames.Nitride.Handlebars.csproj @@ -10,15 +10,15 @@ - - - - - + + + + + - + diff --git a/src/MfGames.Nitride.Handlebars/RenderContentTemplate.cs b/src/MfGames.Nitride.Handlebars/RenderContentTemplate.cs index 12c118a..2c6a5c9 100644 --- a/src/MfGames.Nitride.Handlebars/RenderContentTemplate.cs +++ b/src/MfGames.Nitride.Handlebars/RenderContentTemplate.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -39,7 +40,9 @@ public partial class RenderContentTemplate : OperationBase public Func? CreateModelCallback { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Html/ConvertHtmlEntitiesToUnicode.cs b/src/MfGames.Nitride.Html/ConvertHtmlEntitiesToUnicode.cs index f7cf0d9..479f567 100644 --- a/src/MfGames.Nitride.Html/ConvertHtmlEntitiesToUnicode.cs +++ b/src/MfGames.Nitride.Html/ConvertHtmlEntitiesToUnicode.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Net; +using System.Threading; using MfGames.Gallium; using MfGames.Nitride.Contents; @@ -13,7 +14,9 @@ namespace MfGames.Nitride.Html; public class ConvertHtmlEntitiesToUnicode : OperationBase { /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { return input.SelectEntity(this.ResolveHtmlEntities); } diff --git a/src/MfGames.Nitride.Html/MfGames.Nitride.Html.csproj b/src/MfGames.Nitride.Html/MfGames.Nitride.Html.csproj index d9ed940..b780b76 100644 --- a/src/MfGames.Nitride.Html/MfGames.Nitride.Html.csproj +++ b/src/MfGames.Nitride.Html/MfGames.Nitride.Html.csproj @@ -9,7 +9,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/src/MfGames.Nitride.IO/Contents/ReadFiles.cs b/src/MfGames.Nitride.IO/Contents/ReadFiles.cs index e909e53..1beed73 100644 --- a/src/MfGames.Nitride.IO/Contents/ReadFiles.cs +++ b/src/MfGames.Nitride.IO/Contents/ReadFiles.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using DotNet.Globbing; @@ -43,9 +44,10 @@ public partial class ReadFiles : FileSystemOperationBase /// minimatch pattern (as defined by DotNet.Blob). /// /// A populated collection of entities. - public IEnumerable Run() + public IEnumerable Run( + CancellationToken cancellationToken = default) { - return this.Run(Array.Empty()); + return this.Run(Array.Empty(), cancellationToken); } /// @@ -53,7 +55,9 @@ public partial class ReadFiles : FileSystemOperationBase /// minimatch pattern (as defined by DotNet.Blob). /// /// A populated collection of entities. - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/Contents/WriteFiles.cs b/src/MfGames.Nitride.IO/Contents/WriteFiles.cs index 57846f1..8d69d78 100644 --- a/src/MfGames.Nitride.IO/Contents/WriteFiles.cs +++ b/src/MfGames.Nitride.IO/Contents/WriteFiles.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Threading; using FluentValidation; @@ -63,8 +64,11 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation /// a path and a registered writer will be written. /// /// The entities to parse. + /// /// The same list of entities without changes. - public override IEnumerable Run(IEnumerable entities) + public override IEnumerable Run( + IEnumerable entities, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/Directories/ClearDirectory.cs b/src/MfGames.Nitride.IO/Directories/ClearDirectory.cs index 8df94c7..c5a1e0b 100644 --- a/src/MfGames.Nitride.IO/Directories/ClearDirectory.cs +++ b/src/MfGames.Nitride.IO/Directories/ClearDirectory.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -40,13 +41,16 @@ public partial class ClearDirectory : FileSystemOperationBase, IOperation /// public UPath? Path { get; set; } - public IEnumerable Run() + public IEnumerable Run( + CancellationToken cancellationToken = default) { - return this.Run(new List()); + return this.Run(new List(), cancellationToken); } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/FileSystemOperationBase.cs b/src/MfGames.Nitride.IO/FileSystemOperationBase.cs index b243638..6f4e67b 100644 --- a/src/MfGames.Nitride.IO/FileSystemOperationBase.cs +++ b/src/MfGames.Nitride.IO/FileSystemOperationBase.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; @@ -16,5 +17,7 @@ public abstract class FileSystemOperationBase : IOperation public IFileSystem FileSystem { get; set; } /// - public abstract IEnumerable Run(IEnumerable input); + public abstract IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default); } diff --git a/src/MfGames.Nitride.IO/MfGames.Nitride.IO.csproj b/src/MfGames.Nitride.IO/MfGames.Nitride.IO.csproj index 41e802c..03a1803 100644 --- a/src/MfGames.Nitride.IO/MfGames.Nitride.IO.csproj +++ b/src/MfGames.Nitride.IO/MfGames.Nitride.IO.csproj @@ -8,17 +8,17 @@ - - - - - - - + + + + + + + - + diff --git a/src/MfGames.Nitride.IO/Paths/AddPathPrefix.cs b/src/MfGames.Nitride.IO/Paths/AddPathPrefix.cs index 142246f..41198a4 100644 --- a/src/MfGames.Nitride.IO/Paths/AddPathPrefix.cs +++ b/src/MfGames.Nitride.IO/Paths/AddPathPrefix.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -29,7 +30,9 @@ public partial class AddPathPrefix : OperationBase /// public UPath? PathPrefix { get; set; } - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/Paths/ChangePathExtension.cs b/src/MfGames.Nitride.IO/Paths/ChangePathExtension.cs index 2690318..b169e84 100644 --- a/src/MfGames.Nitride.IO/Paths/ChangePathExtension.cs +++ b/src/MfGames.Nitride.IO/Paths/ChangePathExtension.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -32,7 +33,9 @@ public partial class ChangePathExtension : IOperation /// public string? Extension { get; set; } - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/Paths/LinkDirectChildren.cs b/src/MfGames.Nitride.IO/Paths/LinkDirectChildren.cs index 2fd1f68..0aafe37 100644 --- a/src/MfGames.Nitride.IO/Paths/LinkDirectChildren.cs +++ b/src/MfGames.Nitride.IO/Paths/LinkDirectChildren.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -29,7 +30,9 @@ public partial class LinkDirectChildren : CreateOrUpdateIndex } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { if (this.Scanner != null!) { diff --git a/src/MfGames.Nitride.IO/Paths/MoveToIndexPath.cs b/src/MfGames.Nitride.IO/Paths/MoveToIndexPath.cs index 4b9feea..8a7d11c 100644 --- a/src/MfGames.Nitride.IO/Paths/MoveToIndexPath.cs +++ b/src/MfGames.Nitride.IO/Paths/MoveToIndexPath.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -53,7 +54,9 @@ public partial class MoveToIndexPath : OperationBase }; } - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/Paths/RemovePathPrefix.cs b/src/MfGames.Nitride.IO/Paths/RemovePathPrefix.cs index 3bc3194..5b79748 100644 --- a/src/MfGames.Nitride.IO/Paths/RemovePathPrefix.cs +++ b/src/MfGames.Nitride.IO/Paths/RemovePathPrefix.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -32,7 +33,9 @@ public partial class RemovePathPrefix : IOperation /// public UPath PathPrefix { get; set; } - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.IO/Paths/ReplacePath.cs b/src/MfGames.Nitride.IO/Paths/ReplacePath.cs index 67780a2..db8cd70 100644 --- a/src/MfGames.Nitride.IO/Paths/ReplacePath.cs +++ b/src/MfGames.Nitride.IO/Paths/ReplacePath.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -36,8 +37,11 @@ public partial class ReplacePath : IOperation /// will be updated, the others will be passed on as-is. /// /// The list of input entities. + /// /// The output entities. - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Json/MfGames.Nitride.Json.csproj b/src/MfGames.Nitride.Json/MfGames.Nitride.Json.csproj index a630521..a437583 100644 --- a/src/MfGames.Nitride.Json/MfGames.Nitride.Json.csproj +++ b/src/MfGames.Nitride.Json/MfGames.Nitride.Json.csproj @@ -10,12 +10,12 @@ - + - - + + diff --git a/src/MfGames.Nitride.Markdown/ConvertMarkdownToBase.cs b/src/MfGames.Nitride.Markdown/ConvertMarkdownToBase.cs index 80a30de..71f6a06 100644 --- a/src/MfGames.Nitride.Markdown/ConvertMarkdownToBase.cs +++ b/src/MfGames.Nitride.Markdown/ConvertMarkdownToBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -28,7 +29,9 @@ public abstract partial class ConvertMarkdownToBase : IOperation public Action? ConfigureMarkdown { get; set; } /// - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Validate the inputs. this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Markdown/IdentifyMarkdown.cs b/src/MfGames.Nitride.Markdown/IdentifyMarkdown.cs index 3f9808f..c76018b 100644 --- a/src/MfGames.Nitride.Markdown/IdentifyMarkdown.cs +++ b/src/MfGames.Nitride.Markdown/IdentifyMarkdown.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -29,7 +30,9 @@ public partial class IdentifyMarkdown : IOperation public Func IsMarkdownTest { get; set; } = null!; /// - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Markdown/MakeSingleLinkListItems.cs b/src/MfGames.Nitride.Markdown/MakeSingleLinkListItems.cs index 323f818..2d9365d 100644 --- a/src/MfGames.Nitride.Markdown/MakeSingleLinkListItems.cs +++ b/src/MfGames.Nitride.Markdown/MakeSingleLinkListItems.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using System.Threading; using MfGames.Gallium; using MfGames.Nitride.Contents; @@ -23,7 +24,9 @@ public class MakeSingleLinkListItems : IOperation } /// - public IEnumerable Run(IEnumerable input) + public IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { return input .SelectManyEntity( diff --git a/src/MfGames.Nitride.Markdown/MfGames.Nitride.Markdown.csproj b/src/MfGames.Nitride.Markdown/MfGames.Nitride.Markdown.csproj index d2e64f9..4f95341 100644 --- a/src/MfGames.Nitride.Markdown/MfGames.Nitride.Markdown.csproj +++ b/src/MfGames.Nitride.Markdown/MfGames.Nitride.Markdown.csproj @@ -10,17 +10,17 @@ - - - - + + + + - - - - + + + + diff --git a/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs b/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs index de65567..25df83c 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -39,7 +40,9 @@ public partial class ApplySchedules : OperationBase public Timekeeper Timekeeper { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Temporal.Schedules/MfGames.Nitride.Temporal.Schedules.csproj b/src/MfGames.Nitride.Temporal.Schedules/MfGames.Nitride.Temporal.Schedules.csproj index 9871895..d62aeda 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/MfGames.Nitride.Temporal.Schedules.csproj +++ b/src/MfGames.Nitride.Temporal.Schedules/MfGames.Nitride.Temporal.Schedules.csproj @@ -10,15 +10,15 @@ - - - - + + + + - - + + diff --git a/src/MfGames.Nitride.Temporal.Schedules/README.md b/src/MfGames.Nitride.Temporal.Schedules/README.md index a08c9eb..478d8ff 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/README.md +++ b/src/MfGames.Nitride.Temporal.Schedules/README.md @@ -28,10 +28,10 @@ builder.UseTemporalSchedules(); A schedule is a class that implements `ISchedule` which has the following methods: - CanApply(Entity) ⟶ bool - - This returns true if the schedule can apply to the given entity. + - This returns true if the schedule can apply to the given entity. - Apply(Entity) ⟶ Entity - - This makes the changes for the schedule on the entity and returns the results. - - If the entity doesn't apply, then it should return the entity without changes. + - This makes the changes for the schedule on the entity and returns the results. + - If the entity doesn't apply, then it should return the entity without changes. ## ApplySchedules diff --git a/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs b/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs index 397e351..15e243b 100644 --- a/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs +++ b/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -53,7 +54,9 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation public Timekeeper Timekeeper { get; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Validate our input. this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs b/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs index 358f7f6..8b2deca 100644 --- a/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs +++ b/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -28,7 +29,9 @@ public partial class FilterOutExpiredInstant : OperationBase public Timekeeper Timekeeper { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs b/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs index 88de2dd..9df0ae0 100644 --- a/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs +++ b/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; using MfGames.Nitride.Generators; @@ -22,7 +23,9 @@ public partial class FilterOutFutureInstant : OperationBase public Timekeeper Timekeeper { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { Instant now = this.Timekeeper.Clock.GetCurrentInstant(); diff --git a/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj b/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj index 1f29e72..0bb52ff 100644 --- a/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj +++ b/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj @@ -10,18 +10,18 @@ - - - - - - - - + + + + + + + + - + diff --git a/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs b/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs index eba9ad8..8c996f0 100644 --- a/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs +++ b/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using FluentValidation; @@ -39,7 +40,9 @@ public class SetInstantFromComponent : OperationBase } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs b/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs index 8a71bd8..0fea943 100644 --- a/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs +++ b/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; +using System.Threading; using FluentValidation; @@ -43,7 +44,9 @@ public partial class SetInstantFromPath : OperationBase public Regex? PathRegex { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride.Yaml/MfGames.Nitride.Yaml.csproj b/src/MfGames.Nitride.Yaml/MfGames.Nitride.Yaml.csproj index 9cc8072..fb24c2d 100644 --- a/src/MfGames.Nitride.Yaml/MfGames.Nitride.Yaml.csproj +++ b/src/MfGames.Nitride.Yaml/MfGames.Nitride.Yaml.csproj @@ -10,12 +10,12 @@ - + - - + + diff --git a/src/MfGames.Nitride.Yaml/ParseYamlHeader.cs b/src/MfGames.Nitride.Yaml/ParseYamlHeader.cs index fc132e1..47266b0 100644 --- a/src/MfGames.Nitride.Yaml/ParseYamlHeader.cs +++ b/src/MfGames.Nitride.Yaml/ParseYamlHeader.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading; using MfGames.Gallium; using MfGames.Nitride.Contents; @@ -44,7 +45,9 @@ public class ParseYamlHeader : OperationBase private bool RemoveHeader { get; set; } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Set up the YAML parsing. DeserializerBuilder builder = diff --git a/src/MfGames.Nitride/Commands/BuildCommand.cs b/src/MfGames.Nitride/Commands/BuildCommand.cs index c370af2..54c9481 100644 --- a/src/MfGames.Nitride/Commands/BuildCommand.cs +++ b/src/MfGames.Nitride/Commands/BuildCommand.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.CommandLine; using System.CommandLine.Invocation; +using System.Threading; using System.Threading.Tasks; using MfGames.Nitride.Pipelines; @@ -48,6 +49,9 @@ public class BuildCommand : Command, ICommandHandler /// public async Task InvokeAsync(InvocationContext context) { + // Get the cancellation token so we can be interrupted. + CancellationToken cancellationToken = context.GetCancellationToken(); + // Process any injected options. this.logger.Debug( "Processing {Count:N0} pipeline options", @@ -63,7 +67,7 @@ public class BuildCommand : Command, ICommandHandler // all the pipelines once and then quits when it finishes. this.logger.Information("Running pipelines"); - int pipelinesResults = await this.pipelines.RunAsync(); + int pipelinesResults = await this.pipelines.RunAsync(cancellationToken); return pipelinesResults; } diff --git a/src/MfGames.Nitride/Entities/CreateOrUpdateIndex.cs b/src/MfGames.Nitride/Entities/CreateOrUpdateIndex.cs index 9ed4c64..28f5e4f 100644 --- a/src/MfGames.Nitride/Entities/CreateOrUpdateIndex.cs +++ b/src/MfGames.Nitride/Entities/CreateOrUpdateIndex.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -67,7 +68,9 @@ public partial class CreateOrUpdateIndex : OperationBase } = null!; /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Make sure we have sane data. this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride/Entities/EntityScanner.cs b/src/MfGames.Nitride/Entities/EntityScanner.cs index cdca26e..27451ac 100644 --- a/src/MfGames.Nitride/Entities/EntityScanner.cs +++ b/src/MfGames.Nitride/Entities/EntityScanner.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using System.Threading; using FluentValidation; @@ -92,7 +93,9 @@ public partial class EntityScanner : OperationBase } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Make sure we have sane data. this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride/Entities/LinkEntitySequence.cs b/src/MfGames.Nitride/Entities/LinkEntitySequence.cs index 53d5177..76b37e3 100644 --- a/src/MfGames.Nitride/Entities/LinkEntitySequence.cs +++ b/src/MfGames.Nitride/Entities/LinkEntitySequence.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using FluentValidation; @@ -46,7 +47,9 @@ public partial class LinkEntitySequence : OperationBase, IResolvingOperation } /// - public override IEnumerable Run(IEnumerable input) + public override IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default) { // Make sure everything is good. this.validator.ValidateAndThrow(this); diff --git a/src/MfGames.Nitride/IOperation.cs b/src/MfGames.Nitride/IOperation.cs index 20b6fd6..8fddf8a 100644 --- a/src/MfGames.Nitride/IOperation.cs +++ b/src/MfGames.Nitride/IOperation.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; @@ -10,6 +11,9 @@ public interface IOperation /// Runs the input entities through the operation and returns the results. /// /// + /// /// - IEnumerable Run(IEnumerable input); + IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default); } diff --git a/src/MfGames.Nitride/MfGames.Nitride.csproj b/src/MfGames.Nitride/MfGames.Nitride.csproj index 9206a33..230f602 100644 --- a/src/MfGames.Nitride/MfGames.Nitride.csproj +++ b/src/MfGames.Nitride/MfGames.Nitride.csproj @@ -15,22 +15,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/src/MfGames.Nitride/NitrideOperationExtensions.cs b/src/MfGames.Nitride/NitrideOperationExtensions.cs index abd6de8..f005a43 100644 --- a/src/MfGames.Nitride/NitrideOperationExtensions.cs +++ b/src/MfGames.Nitride/NitrideOperationExtensions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; @@ -15,11 +16,13 @@ public static class NitrideOperationExtensions /// /// The entities to perform the operation against. /// The operation to run. + /// The cancellation token of the request. /// The results of the operation. public static IEnumerable Run( this IEnumerable input, - IOperation operation) + IOperation operation, + CancellationToken cancellationToken = default) { - return operation.Run(input); + return operation.Run(input, cancellationToken); } } diff --git a/src/MfGames.Nitride/OperationBase.cs b/src/MfGames.Nitride/OperationBase.cs index 03c6461..6208dbe 100644 --- a/src/MfGames.Nitride/OperationBase.cs +++ b/src/MfGames.Nitride/OperationBase.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; @@ -10,5 +11,7 @@ namespace MfGames.Nitride; public abstract class OperationBase : IOperation { /// - public abstract IEnumerable Run(IEnumerable input); + public abstract IEnumerable Run( + IEnumerable input, + CancellationToken cancellationToken = default); } diff --git a/src/MfGames.Nitride/Pipelines/IPipeline.cs b/src/MfGames.Nitride/Pipelines/IPipeline.cs index c664787..0b11697 100644 --- a/src/MfGames.Nitride/Pipelines/IPipeline.cs +++ b/src/MfGames.Nitride/Pipelines/IPipeline.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; @@ -22,6 +23,9 @@ public interface IPipeline /// entities. /// /// The entities to process. + /// The token for cancelling processing. /// The resulting entities after the process runs. - IAsyncEnumerable RunAsync(IEnumerable entities); + IAsyncEnumerable RunAsync( + IEnumerable entities, + CancellationToken cancellationToken = default); } diff --git a/src/MfGames.Nitride/Pipelines/PipelineBase.cs b/src/MfGames.Nitride/Pipelines/PipelineBase.cs index 0e885aa..310bba7 100644 --- a/src/MfGames.Nitride/Pipelines/PipelineBase.cs +++ b/src/MfGames.Nitride/Pipelines/PipelineBase.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using MfGames.Gallium; @@ -41,12 +42,12 @@ public abstract class PipelineBase : IPipeline /// public abstract IAsyncEnumerable RunAsync( - IEnumerable entities); + IEnumerable entities, + CancellationToken cancellationToken = default); /// public override string ToString() { - return this.GetType() - .Name; + return this.GetType().Name; } } diff --git a/src/MfGames.Nitride/Pipelines/PipelineManager.cs b/src/MfGames.Nitride/Pipelines/PipelineManager.cs index 9a145ba..73d6498 100644 --- a/src/MfGames.Nitride/Pipelines/PipelineManager.cs +++ b/src/MfGames.Nitride/Pipelines/PipelineManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Humanizer; @@ -48,8 +49,9 @@ public class PipelineManager /// Runs all of the pipelines in the appropriate order while running /// across multiple threads. /// + /// The token for cancelling processing. /// A task with zero for success or otherwise an error code. - public Task RunAsync() + public Task RunAsync(CancellationToken cancellationToken) { // Make sure everything is setup. DateTime started = DateTime.UtcNow; @@ -66,14 +68,18 @@ public class PipelineManager "pipeline".ToQuantity(this.pipelines.Count)); Task[] tasks = this.entries - .Select(x => Task.Run(async () => await x.RunAsync())) + .Select( + x => Task.Run( + async () => await x.RunAsync(cancellationToken), + cancellationToken)) .ToArray(); var report = TimeSpan.FromSeconds(15); while (!Task.WaitAll(tasks, report)) { - var waiting = this.entries.Where(x => !x.IsFinished) + var waiting = this.entries + .Where(x => !x.IsFinished) .ToList(); this.logger.Debug( @@ -81,14 +87,15 @@ public class PipelineManager "pipeline".ToQuantity(waiting.Count)); IOrderedEnumerable> - states = - waiting.GroupBy(x => x.State, x => x) - .OrderBy(x => (int)x.Key); + states = waiting + .GroupBy(x => x.State, x => x) + .OrderBy(x => (int)x.Key); foreach (IGrouping? state in states) { - var statePipelines = state.OrderBy(x => x.Pipeline.ToString()) + var statePipelines = state + .OrderBy(x => x.Pipeline.ToString()) .ToList(); this.logger.Verbose( @@ -106,8 +113,8 @@ public class PipelineManager } // Figure out our return code. - bool hasErrors = - this.entries.Any(x => x.State == PipelineRunnerState.Errored); + bool hasErrors = this.entries + .Any(x => x.State == PipelineRunnerState.Errored); this.logger.Information( "Completed in {Elapsed}", @@ -144,20 +151,22 @@ public class PipelineManager // Wrap all the pipelines into entries. We do this before the next // step so we can have the entries depend on the entries. - this.entries = this.pipelines.Select(x => this.createEntry(x)) + this.entries = this.pipelines + .Select(x => this.createEntry(x)) .ToList(); // Go through and connect the pipelines together. foreach (PipelineRunner? entry in this.entries) { - var dependencies = entry.Pipeline.GetDependencies() + var dependencies = entry.Pipeline + .GetDependencies() .ToList(); foreach (IPipeline? dependency in dependencies) { // Get the entry for the dependency. - PipelineRunner dependencyPipeline = - this.entries.Single(x => x.Pipeline == dependency); + PipelineRunner dependencyPipeline = this.entries + .Single(x => x.Pipeline == dependency); // Set up the bi-directional connection. entry.Incoming.Add(dependencyPipeline); diff --git a/src/MfGames.Nitride/Pipelines/PipelineRunner.cs b/src/MfGames.Nitride/Pipelines/PipelineRunner.cs index 2d92265..57b2fe9 100644 --- a/src/MfGames.Nitride/Pipelines/PipelineRunner.cs +++ b/src/MfGames.Nitride/Pipelines/PipelineRunner.cs @@ -149,7 +149,7 @@ public class PipelineRunner /// Executes the pipeline, including waiting for any or all /// dependencies. /// - public async Task RunAsync() + public async Task RunAsync(CancellationToken cancellationToken = default) { try { @@ -194,7 +194,7 @@ public class PipelineRunner // Run the pipeline. This may not be resolved until we gather // the output below. - await this.RunPipeline(input); + await this.RunPipeline(input, cancellationToken); // At this point, we are completely done with our inputs, so signal // to them in case they have to clean up any of their structures. @@ -274,12 +274,14 @@ public class PipelineRunner return input; } - private async Task RunPipeline(List input) + private async Task RunPipeline( + List input, + CancellationToken cancellationToken) { // Get the sequence of data, but this doesn't drain the enumeration. List output = await this.Pipeline - .RunAsync(input) - .ToListAsync(); + .RunAsync(input, cancellationToken) + .ToListAsync(cancellationToken); // Gather all the output. this.logger.Verbose("{Pipeline:l}: Gathering output", this.Pipeline); diff --git a/tests/MfGames.Nitride.IO.Tests/MfGames.Nitride.IO.Tests.csproj b/tests/MfGames.Nitride.IO.Tests/MfGames.Nitride.IO.Tests.csproj index 00106dc..5e58093 100644 --- a/tests/MfGames.Nitride.IO.Tests/MfGames.Nitride.IO.Tests.csproj +++ b/tests/MfGames.Nitride.IO.Tests/MfGames.Nitride.IO.Tests.csproj @@ -6,22 +6,22 @@ - - + + - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/MfGames.Nitride.Json.Tests/MfGames.Nitride.Json.Tests.csproj b/tests/MfGames.Nitride.Json.Tests/MfGames.Nitride.Json.Tests.csproj index e4b5f6c..24ec771 100644 --- a/tests/MfGames.Nitride.Json.Tests/MfGames.Nitride.Json.Tests.csproj +++ b/tests/MfGames.Nitride.Json.Tests/MfGames.Nitride.Json.Tests.csproj @@ -6,10 +6,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,9 +21,9 @@ - - - + + + diff --git a/tests/MfGames.Nitride.Markdown.Tests/MfGames.Nitride.Markdown.Tests.csproj b/tests/MfGames.Nitride.Markdown.Tests/MfGames.Nitride.Markdown.Tests.csproj index c8214fc..bf2b6ee 100644 --- a/tests/MfGames.Nitride.Markdown.Tests/MfGames.Nitride.Markdown.Tests.csproj +++ b/tests/MfGames.Nitride.Markdown.Tests/MfGames.Nitride.Markdown.Tests.csproj @@ -6,18 +6,18 @@ - - + + - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/MfGames.Nitride.Slugs.Tests/MfGames.Nitride.Slugs.Tests.csproj b/tests/MfGames.Nitride.Slugs.Tests/MfGames.Nitride.Slugs.Tests.csproj index 5d0468e..abfc052 100644 --- a/tests/MfGames.Nitride.Slugs.Tests/MfGames.Nitride.Slugs.Tests.csproj +++ b/tests/MfGames.Nitride.Slugs.Tests/MfGames.Nitride.Slugs.Tests.csproj @@ -6,21 +6,21 @@ - - - + + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/MfGames.Nitride.Temporal.Schedules.Tests/MfGames.Nitride.Temporal.Schedules.Tests.csproj b/tests/MfGames.Nitride.Temporal.Schedules.Tests/MfGames.Nitride.Temporal.Schedules.Tests.csproj index b0e4ff2..0023d6b 100644 --- a/tests/MfGames.Nitride.Temporal.Schedules.Tests/MfGames.Nitride.Temporal.Schedules.Tests.csproj +++ b/tests/MfGames.Nitride.Temporal.Schedules.Tests/MfGames.Nitride.Temporal.Schedules.Tests.csproj @@ -6,17 +6,17 @@ - - + + - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -25,7 +25,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/tests/MfGames.Nitride.Temporal.Tests/MfGames.Nitride.Temporal.Tests.csproj b/tests/MfGames.Nitride.Temporal.Tests/MfGames.Nitride.Temporal.Tests.csproj index b4120aa..9f7d8a4 100644 --- a/tests/MfGames.Nitride.Temporal.Tests/MfGames.Nitride.Temporal.Tests.csproj +++ b/tests/MfGames.Nitride.Temporal.Tests/MfGames.Nitride.Temporal.Tests.csproj @@ -6,17 +6,17 @@ - - + + - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/MfGames.Nitride.Tests/MfGames.Nitride.Tests.csproj b/tests/MfGames.Nitride.Tests/MfGames.Nitride.Tests.csproj index 7e99b4e..da327a0 100644 --- a/tests/MfGames.Nitride.Tests/MfGames.Nitride.Tests.csproj +++ b/tests/MfGames.Nitride.Tests/MfGames.Nitride.Tests.csproj @@ -8,13 +8,13 @@ - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -26,7 +26,7 @@ - + diff --git a/tests/MfGames.Nitride.Yaml.Tests/MfGames.Nitride.Yaml.Tests.csproj b/tests/MfGames.Nitride.Yaml.Tests/MfGames.Nitride.Yaml.Tests.csproj index c6b094c..810c6fe 100644 --- a/tests/MfGames.Nitride.Yaml.Tests/MfGames.Nitride.Yaml.Tests.csproj +++ b/tests/MfGames.Nitride.Yaml.Tests/MfGames.Nitride.Yaml.Tests.csproj @@ -6,10 +6,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,9 +21,9 @@ - - - + + +