New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear the Actions list through CakeTaskBuilder #2269
Comments
Could it perhaps be simpler to wait and add the action conditionally later on, rather than eagerly adding and then conditionally removing? Builder patterns like this are usually additive. |
The problem that we wrote some utility cake scripts and tasks with some default behavior which is appropriate most of the time. |
@Kemyke Interesting. I've done this the other way around, calling class DefaultTasks
{
protected ICakeContext Context { get; }
public DefaultTasks(ICakeContext context)
{
Context = context ?? throw new ArgumentNullException(nameof(context));
Context.Task("Build").Does((Action)Build);
Context.Task("Test").Does((Action)Test);
}
public virtual Build()
{
Context.MSBuild(...);
}
public virtual Test()
{
Context.NUnit3(...);
}
} _ = new MyTasks(Context);
class MyTasks : DefaultTasks
{
public MyTasks(ICakeContext context) : base(context)
{
}
public override Build()
{
// Before
base.Build();
// After
}
public override Test()
{
// Replace
}
} |
@jnm2 hm, that is a nice idea, however the heavy use of classes could be a little bit confusing in cake scripts in my opinion. I use only inmutable, data classes in our 'cake build system'. I only raised this issue because the lack of |
@Kemyke I think this request is a little bit niche and adding and removing tasks manually is not a path that we normally encourage. Since |
What You Are Seeing?
The only way to clear Actions from a
CakeTaskBuilder
is not cast itsICakeTaskInfo
toCakeTask
.What is Expected?
I need to clean the actions from a Task. I have the
CakeTaskBuilder
which builds that task. I expect to be able to clearActions
without casting to exact type.Possible solutions came to my mind:
ICakeTaskInfo
might contains a List<Func<ICakeContext, Task>> Actions { get; } methodClearActions()
method to clean the actions list.ICakeTaskInfo
should be read-only then maybe the CakeTaskBuilder could have a funcion to clear the previously added tasks.The text was updated successfully, but these errors were encountered: