Util.Compile and Util.Run questions
Before I ask my questions I would like to state my end goal. I would like to do the following
1)Call a Subscript and output its Dump() in the main window.
2) Return a value from a Subscript.
3) Input a highly type object into a subscript.
I have manage to achieve 3 and sort of achieve 1 and 2
I can achieve 1 by using the Util.Run() method and also pass in string argument which is pretty nice. I also get the subscript .Dump() into my Results view window. Pretty cool and useful.
I can achieve 3 and 2 by using the following code and having the TestObject defined in MyExtensions script.
Parent Script
}
SubScript with working return value
Using this method though I do not get my "Test Dump".Dump() in my results window in the parent script.
Once I change the subscript return value to async Task my ReturnValue becomes null. I still do not get the "Test Dump".Dump() in my parent script results window either which is expected from the result of the above test case.
Is it possible to achieve all 3 ( well I guess 4) goals ? I have ran these scripts in the release version of linqpad 5 and the Download LINQPad 5.23.05 (Any CPU) beta.
1)Call a Subscript and output its Dump() in the main window.
2) Return a value from a Subscript.
3) Input a highly type object into a subscript.
I have manage to achieve 3 and sort of achieve 1 and 2
I can achieve 1 by using the Util.Run() method and also pass in string argument which is pretty nice. I also get the subscript .Dump() into my Results view window. Pretty cool and useful.
I can achieve 3 and 2 by using the following code and having the TestObject defined in MyExtensions script.
Parent Script
void Main()
{
Directory.SetCurrentDirectory (Path.GetDirectoryName (Util.CurrentQueryPath));
var details = new TestObject { /* whatever I want */ }
var compiledQuery = Util.Compile(@".\SubTestQuery.linq", false);
var retVal = compiledQuery.Run(QueryResultFormat.Html, details);
retVal.ReturnValue.Dump();
}
SubScript with working return value
int Main(EnvironmentDetails input)
{
"Test Dump".Dump();
return 5;
}
Using this method though I do not get my "Test Dump".Dump() in my results window in the parent script.
Once I change the subscript return value to async Task my ReturnValue becomes null. I still do not get the "Test Dump".Dump() in my parent script results window either which is expected from the result of the above test case.
async Task<int> Main(EnvironmentDetails input)
{
"Test Dump".Dump();
return 5;
}
Is it possible to achieve all 3 ( well I guess 4) goals ? I have ran these scripts in the release version of linqpad 5 and the Download LINQPad 5.23.05 (Any CPU) beta.
Comments
The subquery with a Task returns null though and I have been playing around with the following
Parent Query
SubQuery
but honestly I think should reformulated my approach on my designs instead of getting this to work. I could always switch to a non Task subquery and get my results from that.