Last active
August 29, 2015 14:03
-
-
Save ashmind/8ec446d16082b7dda976 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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