LINQPad 5 beta & preprocessor directives
Hi @JoeAlbahari,
I'm guessing this is something I will have to live with, but I thought I would ask, just in case
In LINQPad 4, it is possible to use autocompletion even when the code you are writing falls inside a preprocessor block where the specified symbol hasn't been defined.
In LINQPad 5 beta, however, it gray's out the code and autocompletion isn't possible.
It's handy that it colors the code gray - for visual clarity that it won't be executed, but I would prefer that it color the background instead (for example, to retain the clarity), and still syntax highlight the code and allow autocompletion to function.
(In case anyone reading this wonders what a preprocessor directive is, here is a link to some documentation https://msdn.microsoft.com/en-us/library/4y6tbswk.aspx)
Example (taken from https://www.linqpad.net/lprun.aspx):
#if CMD
// no autocompletion here in LINQPad 5
"I'm being called from lprun!".Dump();
#else
"I'm running in the LINQPad GUI!".Dump();
#endif
It's no biggie, it just means I'm less likely to use preprocessor directives in LINQPad 5, and instead I will find other ways of achieving the same results, but maybe that's not such a bad thing after all...
Related question: is there a way to check whether the query is running from the GUI or lprun without using the CMD preprocessor directive? I realise I can check the arguments to void Main, if there are some then it is definitely running from lprun - but how to tell in the case that there are no args?
Thanks for your time
Keith
I'm guessing this is something I will have to live with, but I thought I would ask, just in case
In LINQPad 4, it is possible to use autocompletion even when the code you are writing falls inside a preprocessor block where the specified symbol hasn't been defined.
In LINQPad 5 beta, however, it gray's out the code and autocompletion isn't possible.
It's handy that it colors the code gray - for visual clarity that it won't be executed, but I would prefer that it color the background instead (for example, to retain the clarity), and still syntax highlight the code and allow autocompletion to function.
(In case anyone reading this wonders what a preprocessor directive is, here is a link to some documentation https://msdn.microsoft.com/en-us/library/4y6tbswk.aspx)
Example (taken from https://www.linqpad.net/lprun.aspx):
#if CMD
// no autocompletion here in LINQPad 5
"I'm being called from lprun!".Dump();
#else
"I'm running in the LINQPad GUI!".Dump();
#endif
It's no biggie, it just means I'm less likely to use preprocessor directives in LINQPad 5, and instead I will find other ways of achieving the same results, but maybe that's not such a bad thing after all...
Related question: is there a way to check whether the query is running from the GUI or lprun without using the CMD preprocessor directive? I realise I can check the arguments to void Main, if there are some then it is definitely running from lprun - but how to tell in the case that there are no args?
Thanks for your time
Keith
Comments
LINQPad 5 uses the Roslyn libraries to feed the autocompletion service, which means you get the same behavior as in Visual Studio, where preprocessor directives are properly parsed. I can see how this can be frustrating, though.
An interesting solution would be to re-parse without #if directives should you request autocompletion while inside preprocessor trivia. I'll try creating a prototype next week to see how it works.