I have some source code files where I would like to extract all the comments (C-style) and search them for a specific construct that I can then use in my source generator to make some additional code...
Example:
...
var v = something();//comment I just want to skip
//record Car (
//string CarId This is the CarId
//)
var whatever = ()=>{...};
/*record AnotherCar(
string CarId This is the CarId
)*/
...
I have 2 problems. First, I cannot figure out how to skip all of the things but the comments, and Second how do I make it only return the records encoded therein? Alternatively, just search for the keywords and attempt to parse from there, but cannot figure that out either.
Old question, but the answer may help someone.
You can use Linq query to parse the sequence and select only what you need as given below:
Output result
Try it