Skip to content

Commit 5fd3cc6

Browse files
committed
Provide tasks rather than just names since the engine looks them up anyway
1 parent 5c7da37 commit 5fd3cc6

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/Cake.Core/CakeEngine.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,23 @@ public CakeReport RunTarget(ICakeContext context, IExecutionStrategy strategy, s
129129

130130
try
131131
{
132-
var executingTasks = graph.Traverse(target);
132+
var executingTaskNames = graph.Traverse(target);
133+
134+
var executingTasks = new CakeTask[executingTaskNames.Count];
135+
for (var i = 0; i < executingTasks.Length; i++)
136+
{
137+
var name = executingTaskNames[i];
138+
executingTasks[i] = _tasks.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
139+
Debug.Assert(executingTasks[i] != null, "Node should not be null.");
140+
}
141+
133142
PerformSetup(strategy, context, executingTasks);
134143

135144
var stopWatch = new Stopwatch();
136145
var report = new CakeReport();
137146

138-
foreach (var taskNode in executingTasks)
147+
foreach (var task in executingTasks)
139148
{
140-
// Get the task.
141-
var task = _tasks.FirstOrDefault(x => x.Name.Equals(taskNode, StringComparison.OrdinalIgnoreCase));
142-
Debug.Assert(task != null, "Node should not be null.");
143-
144149
// Is this the current target?
145150
var isTarget = task.Name.Equals(target, StringComparison.OrdinalIgnoreCase);
146151

@@ -199,7 +204,7 @@ public void RegisterTaskTeardownAction(Action<ITaskTeardownContext> action)
199204
/// </summary>
200205
public event EventHandler<TaskTeardownEventArgs> TaskTeardown;
201206

202-
private void PerformSetup(IExecutionStrategy strategy, ICakeContext context, IReadOnlyList<string> tasksToExecute)
207+
private void PerformSetup(IExecutionStrategy strategy, ICakeContext context, IReadOnlyList<CakeTask> tasksToExecute)
203208
{
204209
var setupContext = new SetupContext(context, tasksToExecute);
205210
PublishEvent(Setup, new SetupEventArgs(setupContext));

src/Cake.Core/ISetupContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public interface ISetupContext : ICakeContext
1515
/// Gets the ordered list of tasks which are about to be executed.
1616
/// The target task is listed last.
1717
/// </summary>
18-
IReadOnlyList<string> TasksToExecute { get; }
18+
IReadOnlyList<CakeTask> TasksToExecute { get; }
1919
}
2020
}

src/Cake.Core/SetupContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public sealed class SetupContext : CakeContextAdapter, ISetupContext
1616
/// </summary>
1717
/// <param name="context">The Cake Context</param>
1818
/// <param name="tasksToExecute">The ordered list of tasks which are about to be executed with the target task listed last.</param>
19-
public SetupContext(ICakeContext context, IReadOnlyList<string> tasksToExecute)
19+
public SetupContext(ICakeContext context, IReadOnlyList<CakeTask> tasksToExecute)
2020
: base(context)
2121
{
2222
TasksToExecute = tasksToExecute;
@@ -26,6 +26,6 @@ public SetupContext(ICakeContext context, IReadOnlyList<string> tasksToExecute)
2626
/// Gets the ordered list of tasks which are about to be executed.
2727
/// The target task is listed last.
2828
/// </summary>
29-
public IReadOnlyList<string> TasksToExecute { get; }
29+
public IReadOnlyList<CakeTask> TasksToExecute { get; }
3030
}
3131
}

0 commit comments

Comments
 (0)