Assuming the file is valid (i.e. compiles), you can start by reading the entire file into a string.
From your question, I understand that you are interested in method names, not class names. Then you need a regular expression that will give you all instances of public | protected | private, optional virtual / override keywords, etc., MethodName, (, optional parameters). It would help if you were coding conventions, so you can assume that all the determination methods have always been on the same line rather than scattered across multiple lines.
Once you do this, it's just a matter of counting {and} to get the body of the function.
And one last tip: Beware of assumptions . They have an unpleasant habit of biting you in the butt.
EDIT: Oh, forgot about the comments! if you have brackets in the comments in the body of the method, your count may go wrong. Therefore, you need to remove all comments from the source as your first step.
source share