Finding methods in a C # file programmatically

I want to write code to search for a defination method and methods called in a C # file.

Thus, it is obvious that my template should look for text, for example

1. public void xyz (blahtype blahvalue);

2.string construct = SearchData (blahvalue);

Someone has done similar to this, in which case Regex is useful. if yes, give me a sample. Any other workarounds. I do not know reflection (this will help in my case)


Thanks, you guys tried, I didn’t know that this wud would be so complicated. All I wanted to do was assume that I have such a method

public method1 (int val)

{

method2 ();

method3 ();

}

void method2 (int val2)

{

method4 ()

}

Method1: Method2: method4 Method1: Method3....

,

+3
3

regex, :

(?<=^|;|\{|\})[^;{}]*\s([\w.]+)\s*\([^;{}]*

. RegExr, .

, , . , , , .

: , , , if for. , . =)

+1

. , IL- . , , , Cecil, .

, , . , . , .

, ( ). . , . . .

, - , @ , , , . . ref out. , . .

, , , , . , , - . - .

 ((public|protected|internal|private|static|abstract|sealed|extern|override|new|virtual)\s+)*[a-zA-Z0-9_]+\s+[a-zA-Z0-9_]+\s*\(.*\)
+1

Source: https://habr.com/ru/post/1747194/


All Articles