Skip to content
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

Allow use of ICakeContext in WithCriteria #512

Closed
jrnail23 opened this issue Nov 11, 2015 · 5 comments
Closed

Allow use of ICakeContext in WithCriteria #512

jrnail23 opened this issue Nov 11, 2015 · 5 comments
Milestone

Comments

@jrnail23
Copy link
Contributor

Overload CakeTaskBuilder.WithCriteria to accept Func<ICakeContext,bool>.
I'm factoring out some common behaviors in my scripts into reusable tasks, but not having the context available in WithCriteria is causing some friction.

Anyone have a reason that context shouldn't be allowed there?

@patriksvensson
Copy link
Member

Sounds like a reasonable addition. Will make the task API more consistent as well 👍

@ErikSchierboom
Copy link
Contributor

I am looking into this, and was wondering how I should add it to the existing CakeTask class. This class has a property that contains all existing boolean criterias: public IReadOnlyList<Func<bool>> Criterias. In the ShouldTaskExecute method in the CakeEngine class, the aforementioned Criterias property is iterated over. Should I create an additional property which signature is like this: public IReadOnlyList<Func<ICakeContext, bool>> ContextCriterias? Or should Func<bool> instances be converted to Func<ICakeContext, bool> instances and the existing Criterias property thus return IReadOnlyList<Func<ICakeContext, bool>>?

@patriksvensson
Copy link
Member

@ErikSchierboom I don't have the source code in front of me but will get back to you later tonight. 👍

@patriksvensson
Copy link
Member

@ErikSchierboom I would prefer if we changed CakeTask.Criterias to be a IReadOnlyList<Func<ICakeContext, bool>> and converted the Func<bool> to a Func<ICakeContext, bool>.

We could also make the void AddCriteria(Func<bool> criteria) an extension method (since it's more or less a convenience method) and change the implementation in CakeTask to void AddCriteria(Func<ICakeContext, bool> criteria)

@patriksvensson
Copy link
Member

Merged via #663.

@patriksvensson patriksvensson changed the title Allow use of ICakeContext in WithCriteria Allow use of ICakeContext in WithCriteria Feb 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants