I have been using SourceMonitor on my project for a couple of years to keep records of source-code complexity and basic SLOC (including comments) for C# and C++ components. These are used for external reporting to our customer, so I'm not in a position to argue their merits or lack of.
I've been working on a repository analysis tool which is able to give me a snap-shot view of the project at any date/time. The next stage I want to add is caching of the metrics for a specified file and revision.
I know SourceMonitor can be scripted to allow me to supply the files to be tested and grab the metrics out of the result file CSV or XML.
Is there a native library in .NET that I could use to do the same thing -- e.g. avoid spawning an external process and parsing the results.
I only really need the following metrics:
- SLOC
- Number of comment lines
- Complexity of most complex method
- Name of most complex method
I need to run this on C# code and normal C++ code.
Edit: since I already have tool which provides the GUI and reports I want, the metrics need to be scripted or generated using a library/API without manual steps. Ideally I want to get metrics for a specified file/revision (rather than a whole project) which my utility will drag from version-control automatically.
NOTE: I created a bounty for this and was on holiday when it expired... the NDepends answer does NOT satisfy me as it doesn't look at source-code but the assembly itself!!!