Skip to content

Instantly share code, notes, and snippets.

@ashmind
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashmind/8ec446d16082b7dda976 to your computer and use it in GitHub Desktop.
Save ashmind/8ec446d16082b7dda976 to your computer and use it in GitHub Desktop.
// current
pvc.Task("build", () => {
pvc.Source("WebApplication.sln")
.Pipe(new PvcMSBuild(
buildTarget: "Clean;Build",
enableParallelism: true
))
.Pipe(new PvcSomethingElse(...));
});
// 1. replace Pipe with extension methods (I considered operator overloading, e.g. |, but might be weird)
pvc.Task("build", () => {
pvc.Source("WebApplication.sln")
.MSBuild(
buildTarget: "Clean;Build",
enableParallelism: true
)
.SomethingElse(...);
});
// 2. remove pvc — for task it definitely looks better, for source.. not sure (mostly due to the indent)
Task("build", () => {
Source("WebApplication.sln")
.MSBuild(
buildTarget: "Clean;Build",
enableParallelism: true
)
.SomethingElse(...);
});
// 3. can we improve it further? crazy idea!
// gives static checks on task names — on the other hand, harder to create tasks dynamically
task build = () => {
source("WebApplication.sln")
.MSBuild(
buildTarget: "Clean;Build",
enableParallelism: true
)
.SomethingElse(...);
}
task postbuild = build + (() => {
...
});
// how does 3 work?
delegate void task();
// to collect variables, append this to user code
void __stub() {}
var that = ((Action)__stub).Target; // is there a better way to get 'scope' object?
foreach (var field in that.GetType().GetFields()) {
if (field.Name == "that" || field.Name.StartsWith("<"))
continue;
pvc.Task(field.Name, field.GetValue(that));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment