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 :)

Example (taken from
#if CMD
// no autocompletion here in LINQPad 5
"I'm being called from lprun!".Dump();
"I'm running in the LINQPad GUI!".Dump();

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 :)


  • It would be helpful if the development team would address this issue. It's only not that you don't get auto-completion, but you also don't get syntax checking.
  • edited June 2016
    LINQPad 4 ignored preprocessor directives for the purposes of autocompletion, which solves the problem you describe, but causes problems of its own. For instance, in the following case:
    #if FOO
    string s;
    int s;
    s is always be treated as a string and never an integer.

    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.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!