How to parse sections of ncover report using regular expressions

So, today I was faced with an problem at work where i had to find out how many lines of executable code does each project have in our solution.
Opening a code file and counting each line individually is not a great approach, especially if you have 100+ projects.
So, I thought of using regular expressions to get different parts of the ncover report.
At first I was getting a list of all projects by using the following regular expression:

<module.*?name=".*?
Project1.dll|
Project2.dll
".*?>[\s\n\r\f]*
(<method.*?>[\s\n\r\f]*(<seqpnt.*?/>[\s\n\r\f]*)*</method>[\s\n\r\f]*)*
</module>

This expression is going to give a list of modules with all of its internals: methods and lines;

Next I was finding all methods by the following expression:

<method.*?>[\s\n\r\f]*(<seqpnt.*?/>[\s\n\r\f]*)*</method>

Finally, you can get list of all lines by using the following expression:

[\s\n\r\f]*<seqpnt.*?/>

To make it easier to analyze, you might want to save the output into a text file after each regular expression execution.

Comments