I want to write a code to search for method defination and methods called in a c# file.
So obviously my pattern should search for text like
1.public void xyz(blahtype blahvalue);
2.string construct = SearchData(blahvalue);
Has anyone done similar to this, is Regex helpful in this case. if yes provide me the pattern.
Any other workarounds. I dont know reflection(will it help in my case)
Thanks, you guys gave it a try, i did not know this wud be so complex.
All i wanted to do was suppose i have method like this
public method1(int val)
{
method2();
method3();
}
void method2(int val2)
{
method4()
}
i wanted to construct a string as Method1:Method2:method4 and Method1:Method3….
I guess its really complex
With reflection you can load an assembly and find out what methods etc it contains so that sounds suitable for what you need unless I’ve misunderstood the question and you mean that you want to look in the source files.
First Load the Assembly, then get out the Types and then you can get the methods for each type.
Type.GetMethodshttp://msdn.microsoft.com/en-us/library/4d848zkb.aspx
Assembly.GetTypeshttp://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettypes.aspx