Search code examples
c#preprocessor-directive

C# How to get a list of defined preprocessor?


I know I can check if a preprocessor directive is defined using the #if syntax.

But I want to get a list of defined preprocessor directives to pass it over to a realtime compiling using CSharpCodeProvider

Thanks for advance.


Solution

  • I don't think that is possible. Related.

    The compiler itself doesn't know about preprocessor. It receives already preprocessed code so there is no reason to remember what directives were defined.