Allow to set some lines to use Util.Cache
Util.Cache is very useful when iteratively running the same code, but switching back and forth between
var x = somecalculation
var x = Util.Cache(() => somecalculation,"x")
can be a bitt painful
It would be nice if one could set a given line to be "expensive", so that it appears as a simple line in LinqPad, but behind the scenes, that line is using Util.Cache.
Alternatively, some directive could be put on that line as a comment by the user, to achieve the same result.
The implementation should not be too tricky, just some regex to apply before compilation.
The benefit is that it would simplify sharing of code between production and LinqPad.
Joris Talma commented
As an alternative, you could unload the query process after run (SHIFT-F5).
Joe could implement an Util.UnloadProcessAfterRun() function or this.UnloadProcessAfterRun property to achieve the requested behavior (without Regexing the script file which could result in unexpected results).
If I'm following this correctly, I use something similar depending on the context. Environment Variables or the password store.
`var servers= System.Environment.GetEnvironmentVariable("servers", EnvironmentVariableTarget.User).Split(';').Dump();`
or `var targetPath= Util.ReadLine("Target Path to blow away?", System.Environment.GetEnvironmentVariable("devroot", EnvironmentVariableTarget.User));`
Or for more sensitive info:
`Util.SetPassword` or `wc.Headers.Add("Authorization","Basic "+ Convert.ToBase64String(Encoding.ASCII.GetBytes("bdimperio:"+Util.GetPassword("atlassian",true))));`