lexer - What is the easiest way to extract all string literals from a C# file? -


i need extract string literals given c# file. conditional compilation constants (e.g. #if debug) assumed false, , file can assumed syntactically correct. both single-line ("a\u1000b") , verbatim (@"x""\y") literals should supported.

first tried use regular expressions, realized need correctly handle single- , multi-line comments , logical expressions in #if directives.

so, before started write own c# lexer, ask existing solutions.


Comments