Inside roslyn diagnostic (analyzer) - is there a way to know what preprocessor symbols are defined for a current compilation?
Asked
Active
Viewed 51 times
1 Answers
1
Maybe use CSharpCompilation
class in Roslyn to get a list of preprocessor symbols that are defined for a current compilation.
to get current compilation :
CSharpCompilation compilation = (CSharpCompilation)context.Compilation;
to get the list of preprocessor symbols that are defined
ImmutableArray<SymbolDisplayPart> preprocessorSymbols = compilation.PreprocessorSymbolNames;

Charfeddine Mohamed Ali
- 943
- 2
- 14
-
PreprocessorSymbolNames is inseide CSharpParseOptions, but you got me into the right direction, thanks – Przemaas Apr 11 '23 at 14:06
-
If you correct your answer to use proper class, I will accept it – Przemaas Apr 11 '23 at 14:06