diff --git a/CHANGELOG.md b/CHANGELOG.md index db39c9f8c..11b713efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [vNext] +## [8.1.1] / 2024-10-05 +- Fixed nested solution folders in `StronglyTypedSolutionGenerator` +- Fixed whitespace arguments in `ArgumentStringHandler` +- Fixed output logging in parallel execution +- Fixed exclusion of invoked targets from skipping +- Fixed definite argument in `EntityFrameworkTasks` + ## [8.1.0] / 2024-09-10 - Added schema generation with references for `build.schema.json` - Added deserialization of full objects from `parameters.json` @@ -1150,7 +1157,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added CLT tasks for Git - Fixed background color in console output -[vNext]: https://github.com/nuke-build/nuke/compare/8.1.0...HEAD +[vNext]: https://github.com/nuke-build/nuke/compare/8.1.1...HEAD +[8.1.1]: https://github.com/nuke-build/nuke/compare/8.1.0...8.1.1 [8.1.0]: https://github.com/nuke-build/nuke/compare/8.0.0...8.1.0 [8.0.0]: https://github.com/nuke-build/nuke/compare/7.0.6...8.0.0 [7.0.6]: https://github.com/nuke-build/nuke/compare/7.0.5...7.0.6 diff --git a/Directory.Packages.props b/Directory.Packages.props index aca4fe257..e571d0ad7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -56,7 +56,7 @@ - + @@ -81,4 +81,4 @@ - \ No newline at end of file + diff --git a/docs/02-fundamentals/05-targets.md b/docs/02-fundamentals/05-targets.md index 9b2fa492d..42c1c7f43 100644 --- a/docs/02-fundamentals/05-targets.md +++ b/docs/02-fundamentals/05-targets.md @@ -207,7 +207,7 @@ class Build : NukeBuild // highlight-start .OnlyWhenDynamic(() => Data.Any()) // highlight-end - .Execute(() => { }); + .Executes(() => { }); } ``` @@ -229,7 +229,7 @@ class Build : NukeBuild .WhenSkipped(DependencyBehavior.Execute) // highlight-end .DependsOn(A) - .Execute(() => { }); + .Executes(() => { }); } ``` @@ -286,7 +286,7 @@ class Build : NukeBuild Target B => _ => _ .DependsOn(A) - .Execute(() => { }); + .Executes(() => { }); } ``` @@ -309,7 +309,7 @@ class Build : NukeBuild .AssuredAfterFailure() // highlight-end .DependsOn(A) - .Execute(() => { }); + .Executes(() => { }); } ``` diff --git a/docs/03-common/07-solution-project-model.md b/docs/03-common/07-solution-project-model.md index 5410610ed..241a70fe1 100644 --- a/docs/03-common/07-solution-project-model.md +++ b/docs/03-common/07-solution-project-model.md @@ -34,7 +34,7 @@ With an instance of the `Solution` type you can **read and write the solution** ```csharp // Gather projects var globalToolProject = Solution.GetProject("Nuke.GlobalTool"); -var testProjects = Solution.GetProjects("*.Tests"); +var testProjects = Solution.GetAllProjects("*.Tests"); // Gather all solution items var allItems = Solution.AllSolutionFolders.SelectMany(x => x.Items); diff --git a/source/Nuke.Build.Tests/BuildExecutorTest.cs b/source/Nuke.Build.Tests/BuildExecutorTest.cs index 15f8f67fa..8c156e26c 100644 --- a/source/Nuke.Build.Tests/BuildExecutorTest.cs +++ b/source/Nuke.Build.Tests/BuildExecutorTest.cs @@ -36,14 +36,7 @@ public void TestDefault() } [Fact] - public void TestParameterSkipped_All() - { - ExecuteBuild(skippedTargets: new ExecutableTarget[0]); - AssertSkipped(A, B, C); - } - - [Fact] - public void TestParameterSkipped_Single() + public void TestParameterSkipped() { ExecuteBuild(skippedTargets: new[] { A }); AssertSucceeded(B, C); @@ -52,9 +45,21 @@ public void TestParameterSkipped_Single() } [Fact] - public void TestParameterSkipped_Multiple() + public void TestParameterSkipped_Default() + { + C.IsDefault = true; + C.Invoked = false; + + ExecuteBuild(skippedTargets: new ExecutableTarget[0]); + AssertSkipped(A, B, C); + } + + [Fact] + public void TestParameterSkipped_Invoked() { - ExecuteBuild(skippedTargets: new[] { A, B }); + C.Invoked = true; + + ExecuteBuild(skippedTargets: new ExecutableTarget[0]); AssertSucceeded(C); AssertSkipped(A, B); } @@ -66,6 +71,7 @@ public void TestParameterSkipped_DependencyBehavior_Skip() ExecuteBuild(skippedTargets: new[] { B }); AssertSucceeded(C); AssertSkipped(A, B); + A.Skipped.Should().Be("because of B"); } [Fact] @@ -109,6 +115,16 @@ public void TestStaticCondition_Multiple() A.OnlyWhen.Should().Be("A && B"); } + [Fact] + public void TestStaticCondition_Throwing() + { + A.StaticConditions.Add(("condition", () => throw new Exception())); + var action = () => ExecuteBuild(); + + action.Should().Throw() + .WithMessage("Target 'A' has thrown an exception."); + } + [Fact] public void TestDynamicCondition_Unchanged() { @@ -130,6 +146,16 @@ public void TestDynamicCondition_Changed() AssertSucceeded(A, B, C); } + [Fact] + public void TestDynamicCondition_Throwing() + { + B.DynamicConditions.Add(("condition", () => throw new Exception())); + var action = () => ExecuteBuild(); + + action.Should().Throw() + .WithMessage("Target 'B' has thrown an exception."); + } + [Fact] public void TestMixedConditions() { @@ -140,22 +166,13 @@ public void TestMixedConditions() } [Fact] - public void TestThrowingCondition() - { - A.StaticConditions.Add(("condition", () => throw new Exception())); - var action = () => ExecuteBuild(); - - action.Should().Throw(); - } - - [Fact] - public void TestSkipTriggers() + public void TestTriggers_Skipped() { + B.ExecutionDependencies.Clear(); + C.ExecutionDependencies.Clear(); A.DynamicConditions.Add(("condition", () => false)); A.Triggers.Add(B); B.Triggers.Add(C); - B.ExecutionDependencies.Clear(); - C.ExecutionDependencies.Clear(); ExecuteBuild(); diff --git a/source/Nuke.Build/Execution/BuildExecutor.cs b/source/Nuke.Build/Execution/BuildExecutor.cs index 085a7ece6..56f6b0fda 100644 --- a/source/Nuke.Build/Execution/BuildExecutor.cs +++ b/source/Nuke.Build/Execution/BuildExecutor.cs @@ -184,8 +184,11 @@ private static void MarkTargetSkipped(INukeBuild build, ExecutableTarget target, if (target.Status != ExecutionStatus.Scheduled) return; - target.Status = ExecutionStatus.Skipped; - target.Skipped ??= reason; + if (!target.Invoked) + { + target.Status = ExecutionStatus.Skipped; + target.Skipped ??= reason; + } if (target.DependencyBehavior == DependencyBehavior.Execute) return; diff --git a/source/Nuke.Build/Execution/BuildManager.cs b/source/Nuke.Build/Execution/BuildManager.cs index 59c9ba301..cd74bd03f 100644 --- a/source/Nuke.Build/Execution/BuildManager.cs +++ b/source/Nuke.Build/Execution/BuildManager.cs @@ -62,6 +62,7 @@ public static int Execute(Expression>[] defaultTargetExpressi if (!build.NoLogo) build.WriteLogo(); + // TODO: move InvokedTargets to ExecutableTargetFactory build.ExecutionPlan = ExecutionPlanner.GetExecutionPlan( build.ExecutableTargets, ParameterService.GetParameter(() => build.InvokedTargets)); diff --git a/source/Nuke.Build/Execution/ExecutionPlanner.cs b/source/Nuke.Build/Execution/ExecutionPlanner.cs index ec3030d24..943dffa36 100644 --- a/source/Nuke.Build/Execution/ExecutionPlanner.cs +++ b/source/Nuke.Build/Execution/ExecutionPlanner.cs @@ -21,9 +21,8 @@ public static IReadOnlyCollection GetExecutionPlan( IReadOnlyCollection executableTargets, [CanBeNull] IReadOnlyCollection invokedTargetNames) { - var invokedTargets = invokedTargetNames?.Select(x => GetExecutableTarget(x, executableTargets)).ToList() ?? - executableTargets.Where(x => x.IsDefault).ToList(); - invokedTargets.ForEach(x => x.Invoked = true); + var invokedTargets = invokedTargetNames?.Select(x => GetExecutableTarget(x, executableTargets)).ToList(); + invokedTargets?.ForEach(x => x.Invoked = true); // Repeat to create the plan with triggers taken into account until plan doesn't change IReadOnlyCollection executionPlan; @@ -74,7 +73,8 @@ private static IReadOnlyCollection GetExecutionPlanInternal( graphAsList.Remove(independent); var executableTarget = independent.Value; - if (!invokedTargets.Contains(executableTarget) && + if (!(invokedTargets != null && invokedTargets.Contains(executableTarget)) && + !(invokedTargets == null && executableTarget.IsDefault) && !scheduledTargets.SelectMany(x => x.ExecutionDependencies).Contains(executableTarget)) continue; diff --git a/source/Nuke.Build/INukeBuild.cs b/source/Nuke.Build/INukeBuild.cs index f41e584f5..e1000b8e6 100644 --- a/source/Nuke.Build/INukeBuild.cs +++ b/source/Nuke.Build/INukeBuild.cs @@ -17,7 +17,7 @@ namespace Nuke.Common; [PublicAPI] public interface INukeBuild { - void ReportSummary(Configure> configurator = null); + void ReportSummary(Configure> configurator = null); internal IReadOnlyCollection ExecutableTargets { get; } internal IReadOnlyCollection BuildExtensions { get; } diff --git a/source/Nuke.Build/NukeBuild.cs b/source/Nuke.Build/NukeBuild.cs index 6f9aa302d..91e2a4038 100644 --- a/source/Nuke.Build/NukeBuild.cs +++ b/source/Nuke.Build/NukeBuild.cs @@ -205,13 +205,13 @@ ExecutionStatus.Aborted or private bool IsInterceptorExecution => Environment.GetEnvironmentVariable(InterceptorEnvironmentKey) == "1"; - public void ReportSummary(Configure> configurator = null) + public void ReportSummary(Configure> configurator = null) { var target = ExecutionPlan.Single(x => x.Status == ExecutionStatus.Running); ReportSummary(target, configurator); } - internal void ReportSummary(ExecutableTarget target, Configure> configurator) + internal void ReportSummary(ExecutableTarget target, Configure> configurator) { target.SummaryInformation = configurator.InvokeSafe(new Dictionary()).ToDictionary(x => x.Key, x => x.Value); ExecuteExtension(x => x.OnTargetSummaryUpdated(this, target)); diff --git a/source/Nuke.Build/Telemetry/Telemetry.Events.cs b/source/Nuke.Build/Telemetry/Telemetry.Events.cs index 93bfa5ec7..204d5710e 100644 --- a/source/Nuke.Build/Telemetry/Telemetry.Events.cs +++ b/source/Nuke.Build/Telemetry/Telemetry.Events.cs @@ -76,7 +76,7 @@ public static void AddPackage() .AddDictionary(GetRepositoryProperties(EnvironmentInfo.WorkingDirectory))); } - private static void TrackEvent(string eventName, Func> propertiesProvider) + private static void TrackEvent(string eventName, Func> propertiesProvider) { if (s_client == null) return; diff --git a/source/Nuke.Build/Telemetry/Telemetry.Properties.cs b/source/Nuke.Build/Telemetry/Telemetry.Properties.cs index 8904dd6ef..8b6ace260 100644 --- a/source/Nuke.Build/Telemetry/Telemetry.Properties.cs +++ b/source/Nuke.Build/Telemetry/Telemetry.Properties.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; @@ -20,7 +21,7 @@ internal partial class Telemetry { private static readonly string[] s_knownTargets = { "Restore", "Compile", "Test" }; - private static IDictionary GetCommonProperties(INukeBuild build = null) + private static Dictionary GetCommonProperties(INukeBuild build = null) { var version = ControlFlow.SuppressErrors( () => @@ -42,7 +43,7 @@ private static IDictionary GetCommonProperties(INukeBuild build }; } - private static IDictionary GetRepositoryProperties(string directory) + private static Dictionary GetRepositoryProperties(string directory) { var repository = ControlFlow.SuppressErrors(() => GitRepository.FromLocalDirectory(directory), logWarning: false); if (repository == null) @@ -76,7 +77,7 @@ private static IDictionary GetRepositoryProperties(string direct }; } - private static IDictionary GetBuildProperties(INukeBuild build) + private static ReadOnlyDictionary GetBuildProperties(INukeBuild build) { var startTimeString = EnvironmentInfo.Variables.GetValueOrDefault(Constants.GlobalToolStartTimeEnvironmentKey); var compileTime = startTimeString != null @@ -99,10 +100,10 @@ private static IDictionary GetBuildProperties(INukeBuild build) .Select(GetTypeName).Distinct().OrderBy(x => x).JoinCommaSpace(), ["build_components"] = build.GetType().GetInterfaces().Where(x => IsCommonType(x) && x != typeof(INukeBuild)) .Select(GetTypeName).Distinct().OrderBy(x => x).JoinCommaSpace() - }; + }.AsReadOnly(); } - private static IDictionary GetTargetProperties(INukeBuild build, ExecutableTarget target) + private static Dictionary GetTargetProperties(INukeBuild build, ExecutableTarget target) { return new Dictionary { @@ -113,7 +114,7 @@ private static IDictionary GetTargetProperties(INukeBuild build, }; } - private static IDictionary GetGeneratorProperties(Type hostType, string generatorId) + private static Dictionary GetGeneratorProperties(Type hostType, string generatorId) { return new Dictionary { diff --git a/source/Nuke.Common/CI/AzurePipelines/AzurePipelines.cs b/source/Nuke.Common/CI/AzurePipelines/AzurePipelines.cs index e82cd11c9..6f008ab92 100644 --- a/source/Nuke.Common/CI/AzurePipelines/AzurePipelines.cs +++ b/source/Nuke.Common/CI/AzurePipelines/AzurePipelines.cs @@ -231,7 +231,7 @@ private string GetText(AzurePipelinesIssueType type) public void WriteCommand( string command, string message = null, - Func, IDictionary> dictionaryConfigurator = null) + Func, Dictionary> dictionaryConfigurator = null) { var escapedTokens = dictionaryConfigurator? diff --git a/source/Nuke.Common/CI/GitHubActions/GitHubActions.cs b/source/Nuke.Common/CI/GitHubActions/GitHubActions.cs index 1fdf51c5d..f3132927a 100644 --- a/source/Nuke.Common/CI/GitHubActions/GitHubActions.cs +++ b/source/Nuke.Common/CI/GitHubActions/GitHubActions.cs @@ -149,7 +149,7 @@ public void WriteError(string message) public void WriteCommand( string command, string message = null, - Configure> dictionaryConfigurator = null) + Configure> dictionaryConfigurator = null) { var parameters = dictionaryConfigurator.InvokeSafe(new Dictionary()) .Select(x => $"{x.Key}={EscapeProperty(x.Value.ToString())}") diff --git a/source/Nuke.Common/CI/TeamCity/TeamCity.cs b/source/Nuke.Common/CI/TeamCity/TeamCity.cs index a58f36ec9..6a094d290 100644 --- a/source/Nuke.Common/CI/TeamCity/TeamCity.cs +++ b/source/Nuke.Common/CI/TeamCity/TeamCity.cs @@ -281,7 +281,7 @@ public void WriteError(string text, string errorDetails = null) .AddPairWhenValueNotNull("errorDetails", errorDetails)); } - public void Write(string command, Func, IDictionary> dictionaryConfigurator) + public void Write(string command, Func, Dictionary> dictionaryConfigurator) { Write(new[] { command }.Concat(dictionaryConfigurator(new Dictionary()) .Select(x => $"{x.Key}='{Escape(x.Value.ToString())}'") diff --git a/source/Nuke.Common/Tools/Docker/DockerTargetDefinitionExtensions.cs b/source/Nuke.Common/Tools/Docker/DockerTargetDefinitionExtensions.cs index bfd4a58a3..8e49ff4a6 100644 --- a/source/Nuke.Common/Tools/Docker/DockerTargetDefinitionExtensions.cs +++ b/source/Nuke.Common/Tools/Docker/DockerTargetDefinitionExtensions.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Linq; using JetBrains.Annotations; @@ -142,7 +141,7 @@ bool IsUpToDate() => build.BuildAssemblyDirectory.GlobFiles("*.dll") return definition; } - private static IReadOnlyDictionary GetEnvironmentVariables( + private static Dictionary GetEnvironmentVariables( ToolSettings settings, AbsolutePath rootDirectory, AbsolutePath tempDirectory) @@ -184,7 +183,6 @@ private static IReadOnlyDictionary GetEnvironmentVariables( !x.Key.Contains(' ') && !x.Key.EqualsAnyOrdinalIgnoreCase(excludedEnvironmentVariables) && !x.Value.Contains(EnvironmentInfo.NewLine)) - .ToDictionary(x => x.Key, _ => default(string)).AsReadOnly()) - .ToImmutableSortedDictionary(); + .ToDictionary(x => x.Key, _ => default(string))); } } diff --git a/source/Nuke.Common/Tools/DotNet/DotNet.Generated.cs b/source/Nuke.Common/Tools/DotNet/DotNet.Generated.cs index dbd8f89cf..ef3aac717 100644 --- a/source/Nuke.Common/Tools/DotNet/DotNet.Generated.cs +++ b/source/Nuke.Common/Tools/DotNet/DotNet.Generated.cs @@ -2810,7 +2810,7 @@ public partial class DotNetPublishSettings : ToolSettings /// public virtual string Output { get; internal set; } /// - /// Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6. + /// Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6. /// public virtual string OperatingSystem { get; internal set; } /// @@ -20108,7 +20108,7 @@ public static T ResetOutput(this T toolSettings) where T : DotNetPublishSetti #region OperatingSystem /// ///

Sets

- ///

Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.

+ ///

Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.

///
[Pure] public static T SetOperatingSystem(this T toolSettings, string operatingSystem) where T : DotNetPublishSettings @@ -20119,7 +20119,7 @@ public static T SetOperatingSystem(this T toolSettings, string operatingSyste } /// ///

Resets

- ///

Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.

+ ///

Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.

///
[Pure] public static T ResetOperatingSystem(this T toolSettings) where T : DotNetPublishSettings diff --git a/source/Nuke.Common/Tools/DotNet/DotNet.json b/source/Nuke.Common/Tools/DotNet/DotNet.json index 6b94c37d6..6d399a39d 100644 --- a/source/Nuke.Common/Tools/DotNet/DotNet.json +++ b/source/Nuke.Common/Tools/DotNet/DotNet.json @@ -736,7 +736,7 @@ "name": "OperatingSystem", "type": "string", "format": "--os {value}", - "help": "Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6." + "help": "Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6." }, { "name": "SelfContained", diff --git a/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs b/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs index 930b98249..2f1ce2f2a 100644 --- a/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs +++ b/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs @@ -47,7 +47,7 @@ public static IReadOnlyCollection EntityFramework(ArgumentStringHandler return process.Output; } /// - ///

The dotnet ef database drop command is used to drop the database.

+ ///

The dotnet-ef database drop command is used to drop the database.

///

For more details, visit the official website.

///
/// @@ -76,7 +76,7 @@ public static IReadOnlyCollection EntityFrameworkDatabaseDrop(EntityFram return process.Output; } /// - ///

The dotnet ef database drop command is used to drop the database.

+ ///

The dotnet-ef database drop command is used to drop the database.

///

For more details, visit the official website.

///
/// @@ -102,7 +102,7 @@ public static IReadOnlyCollection EntityFrameworkDatabaseDrop(Configure< return EntityFrameworkDatabaseDrop(configurator(new EntityFrameworkDatabaseDropSettings())); } /// - ///

The dotnet ef database drop command is used to drop the database.

+ ///

The dotnet-ef database drop command is used to drop the database.

///

For more details, visit the official website.

///
/// @@ -128,7 +128,7 @@ public static IReadOnlyCollection EntityFrameworkDatabaseDrop(Configure< return configurator.Invoke(EntityFrameworkDatabaseDrop, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef database update command is used to update the database to the last migration or to a specified migration.

+ ///

The dotnet-ef database update command is used to update the database to the last migration or to a specified migration.

///

For more details, visit the official website.

///
/// @@ -157,7 +157,7 @@ public static IReadOnlyCollection EntityFrameworkDatabaseUpdate(EntityFr return process.Output; } /// - ///

The dotnet ef database update command is used to update the database to the last migration or to a specified migration.

+ ///

The dotnet-ef database update command is used to update the database to the last migration or to a specified migration.

///

For more details, visit the official website.

///
/// @@ -183,7 +183,7 @@ public static IReadOnlyCollection EntityFrameworkDatabaseUpdate(Configur return EntityFrameworkDatabaseUpdate(configurator(new EntityFrameworkDatabaseUpdateSettings())); } /// - ///

The dotnet ef database update command is used to update the database to the last migration or to a specified migration.

+ ///

The dotnet-ef database update command is used to update the database to the last migration or to a specified migration.

///

For more details, visit the official website.

///
/// @@ -209,7 +209,7 @@ public static IReadOnlyCollection EntityFrameworkDatabaseUpdate(Configur return configurator.Invoke(EntityFrameworkDatabaseUpdate, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef dbcontext info command is used to get information about a DbContext type.

+ ///

The dotnet-ef dbcontext info command is used to get information about a DbContext type.

///

For more details, visit the official website.

///
/// @@ -236,7 +236,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextInfo(EntityFra return process.Output; } /// - ///

The dotnet ef dbcontext info command is used to get information about a DbContext type.

+ ///

The dotnet-ef dbcontext info command is used to get information about a DbContext type.

///

For more details, visit the official website.

///
/// @@ -260,7 +260,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextInfo(Configure return EntityFrameworkDbContextInfo(configurator(new EntityFrameworkDbContextInfoSettings())); } /// - ///

The dotnet ef dbcontext info command is used to get information about a DbContext type.

+ ///

The dotnet-ef dbcontext info command is used to get information about a DbContext type.

///

For more details, visit the official website.

///
/// @@ -284,7 +284,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextInfo(Configure return configurator.Invoke(EntityFrameworkDbContextInfo, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef dbcontext list command is used to list available DbContext types.

+ ///

The dotnet-ef dbcontext list command is used to list available DbContext types.

///

For more details, visit the official website.

///
/// @@ -311,7 +311,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextList(EntityFra return process.Output; } /// - ///

The dotnet ef dbcontext list command is used to list available DbContext types.

+ ///

The dotnet-ef dbcontext list command is used to list available DbContext types.

///

For more details, visit the official website.

///
/// @@ -335,7 +335,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextList(Configure return EntityFrameworkDbContextList(configurator(new EntityFrameworkDbContextListSettings())); } /// - ///

The dotnet ef dbcontext list command is used to list available DbContext types.

+ ///

The dotnet-ef dbcontext list command is used to list available DbContext types.

///

For more details, visit the official website.

///
/// @@ -359,7 +359,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextList(Configure return configurator.Invoke(EntityFrameworkDbContextList, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.

+ ///

The dotnet-ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.

///

For more details, visit the official website.

///
/// @@ -399,7 +399,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextScaffold(Entit return process.Output; } /// - ///

The dotnet ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.

+ ///

The dotnet-ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.

///

For more details, visit the official website.

///
/// @@ -436,7 +436,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextScaffold(Confi return EntityFrameworkDbContextScaffold(configurator(new EntityFrameworkDbContextScaffoldSettings())); } /// - ///

The dotnet ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.

+ ///

The dotnet-ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.

///

For more details, visit the official website.

///
/// @@ -473,7 +473,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextScaffold(Confi return configurator.Invoke(EntityFrameworkDbContextScaffold, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.

+ ///

The dotnet-ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.

///

For more details, visit the official website.

///
/// @@ -501,7 +501,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextScript(EntityF return process.Output; } /// - ///

The dotnet ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.

+ ///

The dotnet-ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.

///

For more details, visit the official website.

///
/// @@ -526,7 +526,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextScript(Configu return EntityFrameworkDbContextScript(configurator(new EntityFrameworkDbContextScriptSettings())); } /// - ///

The dotnet ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.

+ ///

The dotnet-ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.

///

For more details, visit the official website.

///
/// @@ -551,7 +551,7 @@ public static IReadOnlyCollection EntityFrameworkDbContextScript(Configu return configurator.Invoke(EntityFrameworkDbContextScript, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef migrations add command is used to add a new migration.

+ ///

The dotnet-ef migrations add command is used to add a new migration.

///

For more details, visit the official website.

///
/// @@ -581,7 +581,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsAdd(EntityFra return process.Output; } /// - ///

The dotnet ef migrations add command is used to add a new migration.

+ ///

The dotnet-ef migrations add command is used to add a new migration.

///

For more details, visit the official website.

///
/// @@ -608,7 +608,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsAdd(Configure return EntityFrameworkMigrationsAdd(configurator(new EntityFrameworkMigrationsAddSettings())); } /// - ///

The dotnet ef migrations add command is used to add a new migration.

+ ///

The dotnet-ef migrations add command is used to add a new migration.

///

For more details, visit the official website.

///
/// @@ -635,7 +635,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsAdd(Configure return configurator.Invoke(EntityFrameworkMigrationsAdd, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef migrations list command is used to list available migrations.

+ ///

The dotnet-ef migrations list command is used to list available migrations.

///

For more details, visit the official website.

///
/// @@ -664,7 +664,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsList(EntityFr return process.Output; } /// - ///

The dotnet ef migrations list command is used to list available migrations.

+ ///

The dotnet-ef migrations list command is used to list available migrations.

///

For more details, visit the official website.

///
/// @@ -690,7 +690,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsList(Configur return EntityFrameworkMigrationsList(configurator(new EntityFrameworkMigrationsListSettings())); } /// - ///

The dotnet ef migrations list command is used to list available migrations.

+ ///

The dotnet-ef migrations list command is used to list available migrations.

///

For more details, visit the official website.

///
/// @@ -716,7 +716,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsList(Configur return configurator.Invoke(EntityFrameworkMigrationsList, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).

+ ///

The dotnet-ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).

///

For more details, visit the official website.

///
/// @@ -744,7 +744,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsRemove(Entity return process.Output; } /// - ///

The dotnet ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).

+ ///

The dotnet-ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).

///

For more details, visit the official website.

///
/// @@ -769,7 +769,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsRemove(Config return EntityFrameworkMigrationsRemove(configurator(new EntityFrameworkMigrationsRemoveSettings())); } /// - ///

The dotnet ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).

+ ///

The dotnet-ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).

///

For more details, visit the official website.

///
/// @@ -794,7 +794,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsRemove(Config return configurator.Invoke(EntityFrameworkMigrationsRemove, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef migrations bundle command is used to create a bundle.

+ ///

The dotnet-ef migrations bundle command is used to create a bundle.

///

For more details, visit the official website.

///
/// @@ -825,7 +825,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsBundle(Entity return process.Output; } /// - ///

The dotnet ef migrations bundle command is used to create a bundle.

+ ///

The dotnet-ef migrations bundle command is used to create a bundle.

///

For more details, visit the official website.

///
/// @@ -853,7 +853,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsBundle(Config return EntityFrameworkMigrationsBundle(configurator(new EntityFrameworkMigrationsBundleSettings())); } /// - ///

The dotnet ef migrations bundle command is used to create a bundle.

+ ///

The dotnet-ef migrations bundle command is used to create a bundle.

///

For more details, visit the official website.

///
/// @@ -881,7 +881,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsBundle(Config return configurator.Invoke(EntityFrameworkMigrationsBundle, EntityFrameworkLogger, degreeOfParallelism, completeOnFailure); } /// - ///

The dotnet ef migrations script command is used to generate a SQL script from migrations.

+ ///

The dotnet-ef migrations script command is used to generate a SQL script from migrations.

///

For more details, visit the official website.

///
/// @@ -913,7 +913,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsScript(Entity return process.Output; } /// - ///

The dotnet ef migrations script command is used to generate a SQL script from migrations.

+ ///

The dotnet-ef migrations script command is used to generate a SQL script from migrations.

///

For more details, visit the official website.

///
/// @@ -942,7 +942,7 @@ public static IReadOnlyCollection EntityFrameworkMigrationsScript(Config return EntityFrameworkMigrationsScript(configurator(new EntityFrameworkMigrationsScriptSettings())); } /// - ///

The dotnet ef migrations script command is used to generate a SQL script from migrations.

+ ///

The dotnet-ef migrations script command is used to generate a SQL script from migrations.

///

For more details, visit the official website.

///
/// @@ -1041,7 +1041,7 @@ public partial class EntityFrameworkDatabaseDropSettings : EntityFrameworkSettin protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef database drop") + .Add("database drop") .Add("--force", Force) .Add("--dry-run", DryRun) .Add("--json", Json) @@ -1129,7 +1129,7 @@ public partial class EntityFrameworkDatabaseUpdateSettings : EntityFrameworkSett protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef database update") + .Add("database update") .Add("{value}", Migration) .Add("--connection {value}", Connection) .Add("--json", Json) @@ -1209,7 +1209,7 @@ public partial class EntityFrameworkDbContextInfoSettings : EntityFrameworkSetti protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef dbcontext info") + .Add("dbcontext info") .Add("--json", Json) .Add("--context {value}", Context) .Add("--project {value}", Project) @@ -1287,7 +1287,7 @@ public partial class EntityFrameworkDbContextListSettings : EntityFrameworkSetti protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef dbcontext list") + .Add("dbcontext list") .Add("--json", Json) .Add("--context {value}", Context) .Add("--project {value}", Project) @@ -1514,7 +1514,7 @@ public partial class EntityFrameworkDbContextScriptSettings : EntityFrameworkSet protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef dbcontext script") + .Add("dbcontext script") .Add("--output {value}", Output) .Add("--json", Json) .Add("--context {value}", Context) @@ -1605,7 +1605,7 @@ public partial class EntityFrameworkMigrationsAddSettings : EntityFrameworkSetti protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef migrations add") + .Add("migrations add") .Add("{value}", Name) .Add("--output-dir {value}", OutputDirectory) .Add("--namespace {value}", Namespace) @@ -1694,7 +1694,7 @@ public partial class EntityFrameworkMigrationsListSettings : EntityFrameworkSett protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef migrations list") + .Add("migrations list") .Add("--connection {value}", Connection) .Add("--no-connect", NoConnect) .Add("--json", Json) @@ -1778,7 +1778,7 @@ public partial class EntityFrameworkMigrationsRemoveSettings : EntityFrameworkSe protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef migrations remove") + .Add("migrations remove") .Add("--force", Force) .Add("--json", Json) .Add("--context {value}", Context) @@ -1873,7 +1873,7 @@ public partial class EntityFrameworkMigrationsBundleSettings : EntityFrameworkSe protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef migrations bundle") + .Add("migrations bundle") .Add("--output {value}", Output) .Add("--force", Force) .Add("--self-contained", SelfContained) @@ -1975,7 +1975,7 @@ public partial class EntityFrameworkMigrationsScriptSettings : EntityFrameworkSe protected override Arguments ConfigureProcessArguments(Arguments arguments) { arguments - .Add("ef migrations script") + .Add("migrations script") .Add("{value}", From) .Add("{value}", To) .Add("--output {value}", Output) diff --git a/source/Nuke.Common/Tools/EntityFramework/EntityFramework.json b/source/Nuke.Common/Tools/EntityFramework/EntityFramework.json index 99d9b81be..8be6ee9be 100644 --- a/source/Nuke.Common/Tools/EntityFramework/EntityFramework.json +++ b/source/Nuke.Common/Tools/EntityFramework/EntityFramework.json @@ -10,9 +10,9 @@ "customExecutable": true, "tasks": [ { - "help": "The dotnet ef database drop command is used to drop the database.", + "help": "The dotnet-ef database drop command is used to drop the database.", "postfix": "DatabaseDrop", - "definiteArgument": "ef database drop", + "definiteArgument": "database drop", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -32,9 +32,9 @@ } }, { - "help": "The dotnet ef database update command is used to update the database to the last migration or to a specified migration.", + "help": "The dotnet-ef database update command is used to update the database to the last migration or to a specified migration.", "postfix": "DatabaseUpdate", - "definiteArgument": "ef database update", + "definiteArgument": "database update", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -54,23 +54,23 @@ } }, { - "help": "The dotnet ef dbcontext info command is used to get information about a DbContext type.", + "help": "The dotnet-ef dbcontext info command is used to get information about a DbContext type.", "postfix": "DbContextInfo", - "definiteArgument": "ef dbcontext info", + "definiteArgument": "dbcontext info", "settingsClass": { "baseClass": "EntityFrameworkSettings" } }, { - "help": "The dotnet ef dbcontext list command is used to list available DbContext types.", + "help": "The dotnet-ef dbcontext list command is used to list available DbContext types.", "postfix": "DbContextList", - "definiteArgument": "ef dbcontext list", + "definiteArgument": "dbcontext list", "settingsClass": { "baseClass": "EntityFrameworkSettings" } }, { - "help": "The dotnet ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.", + "help": "The dotnet-ef dbcontext scaffold command is used to generate code for a DbContext and entity types for a database. In order for this command to generate an entity type, the database table must have a primary key.", "postfix": "DbContextScaffold", "definiteArgument": "ef dbcontext scaffold", "settingsClass": { @@ -164,9 +164,9 @@ } }, { - "help": "The dotnet ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.", + "help": "The dotnet-ef dbcontext script command is used to generate a SQL script from the DbContext, bypassing any migrations.", "postfix": "DbContextScript", - "definiteArgument": "ef dbcontext script", + "definiteArgument": "dbcontext script", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -180,9 +180,9 @@ } }, { - "help": "The dotnet ef migrations add command is used to add a new migration.", + "help": "The dotnet-ef migrations add command is used to add a new migration.", "postfix": "MigrationsAdd", - "definiteArgument": "ef migrations add", + "definiteArgument": "migrations add", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -208,9 +208,9 @@ } }, { - "help": "The dotnet ef migrations list command is used to list available migrations.", + "help": "The dotnet-ef migrations list command is used to list available migrations.", "postfix": "MigrationsList", - "definiteArgument": "ef migrations list", + "definiteArgument": "migrations list", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -230,9 +230,9 @@ } }, { - "help": "The dotnet ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).", + "help": "The dotnet-ef migrations remove command is used to remove the last migration (rolls back the code changes that were done for the migration).", "postfix": "MigrationsRemove", - "definiteArgument": "ef migrations remove", + "definiteArgument": "migrations remove", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -246,9 +246,9 @@ } }, { - "help": "The dotnet ef migrations bundle command is used to create a bundle.", + "help": "The dotnet-ef migrations bundle command is used to create a bundle.", "postfix": "MigrationsBundle", - "definiteArgument": "ef migrations bundle", + "definiteArgument": "migrations bundle", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ @@ -280,9 +280,9 @@ } }, { - "help": "The dotnet ef migrations script command is used to generate a SQL script from migrations.", + "help": "The dotnet-ef migrations script command is used to generate a SQL script from migrations.", "postfix": "MigrationsScript", - "definiteArgument": "ef migrations script", + "definiteArgument": "migrations script", "settingsClass": { "baseClass": "EntityFrameworkSettings", "properties": [ diff --git a/source/Nuke.SourceGenerators/StronglyTypedSolutionGenerator.cs b/source/Nuke.SourceGenerators/StronglyTypedSolutionGenerator.cs index 25a8fba70..04c351235 100644 --- a/source/Nuke.SourceGenerators/StronglyTypedSolutionGenerator.cs +++ b/source/Nuke.SourceGenerators/StronglyTypedSolutionGenerator.cs @@ -92,14 +92,18 @@ private ClassDeclarationSyntax GetSolutionFolderDeclaration( string name, IReadOnlyCollection solutionFolders, IReadOnlyCollection projects, - bool isSolution = false) + bool isSolution = false, + int depth = 0) { string GetMemberName(string name) => name .ReplaceRegex(@"(^[\W^\d]|[\W])", _ => "_") .TrimToOne("_"); + string GetSolutionFolderReferenceName(string name) + => $"{new string('_', depth + 1)}{GetMemberName(name)}"; + string GetSolutionFolderTypeName(string name) - => $"_{GetMemberName(name)}"; + => $"{new string('_', depth)}{GetMemberName(name)}"; MemberDeclarationSyntax GetSolutionFolderPropertyDeclaration() => isSolution @@ -114,7 +118,7 @@ MemberDeclarationSyntax GetProjectPropertyDeclaration(string name) MemberDeclarationSyntax GetSolutionFolderProperty(string name) => ParseMemberDeclaration( - $@"public {GetSolutionFolderTypeName(name)} {GetMemberName(name)} => new(SolutionFolder.GetSolutionFolder(""{name}""));"); + $@"public {GetSolutionFolderReferenceName(name)} {GetMemberName(name)} => new(SolutionFolder.GetSolutionFolder(""{name}""));"); return ClassDeclaration(isSolution ? name : GetSolutionFolderTypeName(name)) // TODO: check for multiple solution fields .AddModifiers(Token(SyntaxKind.InternalKeyword)) @@ -125,7 +129,7 @@ MemberDeclarationSyntax GetSolutionFolderProperty(string name) .AddMembers(GetSolutionFolderConstructorDeclaration())) .AddMembers(projects.Select(project => GetProjectPropertyDeclaration(project.Name)).ToArray()) .AddMembers(solutionFolders.Select(x => GetSolutionFolderProperty(x.Name)).ToArray()) - .AddMembers(solutionFolders.Select(x => GetSolutionFolderDeclaration(x.Name, x.SolutionFolders, x.Projects)) + .AddMembers(solutionFolders.Select(x => GetSolutionFolderDeclaration(x.Name, x.SolutionFolders, x.Projects, depth: depth + 1)) .ToArray()); } diff --git a/source/Nuke.Tooling.Tests/ArgumentStringHandlerTest.cs b/source/Nuke.Tooling.Tests/ArgumentStringHandlerTest.cs index 394cee0a5..3085f2099 100644 --- a/source/Nuke.Tooling.Tests/ArgumentStringHandlerTest.cs +++ b/source/Nuke.Tooling.Tests/ArgumentStringHandlerTest.cs @@ -23,6 +23,8 @@ public void Test() public void TestString() { ArgsToString("start end").Should().Be("start end"); + ArgsToString("").Should().Be(""); + ArgsToString(" ").Should().Be(""); } [Fact] diff --git a/source/Nuke.Tooling/ArgumentStringHandler.cs b/source/Nuke.Tooling/ArgumentStringHandler.cs index 19f134f0e..318e2ef54 100644 --- a/source/Nuke.Tooling/ArgumentStringHandler.cs +++ b/source/Nuke.Tooling/ArgumentStringHandler.cs @@ -81,9 +81,7 @@ public void AppendFormatted(IEnumerable paths, int alignmen public string ToStringAndClear() { var value = _builder.ToStringAndClear(); - return value.IndexOf(value: '"', startIndex: 1) == value.Length - 1 - ? value.TrimMatchingDoubleQuotes() - : value; + return value.TrimMatchingDoubleQuotes(); } public Func GetFilter() diff --git a/source/Nuke.Tooling/Configure.cs b/source/Nuke.Tooling/Configure.cs index f3b92c135..20a11bf51 100644 --- a/source/Nuke.Tooling/Configure.cs +++ b/source/Nuke.Tooling/Configure.cs @@ -70,8 +70,6 @@ private static IReadOnlyCollection Invoke( bool completeOnFailure) where TSettings : ToolSettings, new() { - var singleExecution = degreeOfParallelism == 1; - var invocations = new ConcurrentBag<(TSettings Settings, TResult Result, Exception Exception)>(); try @@ -83,7 +81,7 @@ private static IReadOnlyCollection Invoke( { try { - invocations.Add((x, executor(x.SetProcessLogOutput(singleExecution)), default)); + invocations.Add((x, executor(x.DisableProcessLogOutput()), default)); } catch (Exception exception) { @@ -101,23 +99,20 @@ private static IReadOnlyCollection Invoke( } finally { - if (!singleExecution) - { - invocations - .Where(x => x.Settings.ProcessLogOutput ?? ProcessTasks.DefaultLogOutput) - .SelectMany(x => + invocations + .Where(x => x.Settings.ProcessLogOutput ?? ProcessTasks.DefaultLogOutput) + .SelectMany(x => + { + var (settings, result, exception) = x; + var output = exception switch { - var (settings, result, exception) = x; - var output = exception switch - { - ProcessException processException => processException.Process.Output, - _ => outputSelector(result), - }; + ProcessException processException => processException.Process.Output, + _ => outputSelector(result), + }; - return output.Select(x => (Logger: logger ?? settings.ProcessLogger, Line: x)); - }) - .ForEach(x => x.Logger(x.Line.Type, x.Line.Text)); - } + return output.Select(x => (Logger: logger ?? settings.ProcessLogger, Line: x)); + }) + .ForEach(x => x.Logger(x.Line.Type, x.Line.Text)); } } } diff --git a/source/Nuke.Utilities/Collections/Dictionary.AddDictionary.cs b/source/Nuke.Utilities/Collections/Dictionary.AddDictionary.cs index b871e9198..05a24506e 100644 --- a/source/Nuke.Utilities/Collections/Dictionary.AddDictionary.cs +++ b/source/Nuke.Utilities/Collections/Dictionary.AddDictionary.cs @@ -3,25 +3,24 @@ // https://github.com/nuke-build/nuke/blob/master/LICENSE using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Nuke.Common.Utilities.Collections; public static partial class DictionaryExtensions { - public static TDictionary AddDictionary( - this TDictionary dictionary, - IDictionary otherDictionary) - where TDictionary : IDictionary + public static Dictionary AddDictionary( + this Dictionary dictionary, + Dictionary otherDictionary) { foreach (var (key, value) in otherDictionary) dictionary.AddPair(key, value); return dictionary; } - public static TDictionary AddDictionary( - this TDictionary dictionary, - IReadOnlyDictionary otherDictionary) - where TDictionary : IDictionary + public static Dictionary AddDictionary( + this Dictionary dictionary, + ReadOnlyDictionary otherDictionary) { foreach (var (key, value) in otherDictionary) dictionary.AddPair(key, value); diff --git a/source/Nuke.Utilities/Collections/Dictionary.AddKeyValue.cs b/source/Nuke.Utilities/Collections/Dictionary.AddKeyValue.cs index 7a7c8169e..0b2a47cf4 100644 --- a/source/Nuke.Utilities/Collections/Dictionary.AddKeyValue.cs +++ b/source/Nuke.Utilities/Collections/Dictionary.AddKeyValue.cs @@ -11,8 +11,8 @@ namespace Nuke.Common.Utilities.Collections; public static partial class DictionaryExtensions { - public static IDictionary AddPair( - this IDictionary dictionary, + public static Dictionary AddPair( + this Dictionary dictionary, TKey key, [CanBeNull] TValue value = default) { @@ -20,8 +20,8 @@ public static IDictionary AddPair( return dictionary; } - public static IDictionary AddPair( - this IDictionary dictionary, + public static Dictionary AddPair( + this Dictionary dictionary, TKey key, [CanBeNull] TValue value = default) { @@ -29,8 +29,8 @@ public static IDictionary AddPair( return dictionary; } - public static IDictionary AddPairWhenKeyNotNull( - this IDictionary dictionary, + public static Dictionary AddPairWhenKeyNotNull( + this Dictionary dictionary, [CanBeNull] TKey key, [CanBeNull] TValue value = default) where TKey : class @@ -40,8 +40,8 @@ public static IDictionary AddPairWhenKeyNotNull( : dictionary; } - public static IDictionary AddPairWhenValueNotNull( - this IDictionary dictionary, + public static Dictionary AddPairWhenValueNotNull( + this Dictionary dictionary, [CanBeNull] TKey key, [CanBeNull] TValue value) where TValue : class diff --git a/source/Nuke.Utilities/Collections/Dictionary.AsReadOnly.cs b/source/Nuke.Utilities/Collections/Dictionary.AsReadOnly.cs index 8929f30d5..354e7bbcd 100644 --- a/source/Nuke.Utilities/Collections/Dictionary.AsReadOnly.cs +++ b/source/Nuke.Utilities/Collections/Dictionary.AsReadOnly.cs @@ -11,7 +11,7 @@ namespace Nuke.Common.Utilities.Collections; public static partial class DictionaryExtensions { - public static IReadOnlyDictionary AsReadOnly(this IDictionary dictionary) + public static ReadOnlyDictionary AsReadOnly(this IDictionary dictionary) { return new ReadOnlyDictionary(dictionary); }