Search for statements in CS files.
-
Hello . I am looking for a program or an idea how to parse C# files . What I mainly need to find is disposing of created objects in the methods In each method in each class that is in the file , I want to look for object creation statement :
myObject = new CMyObject()
And then to see whether this object is disposed in the end of the method ( in the finally ) . And I also want to analyze more stuff . The question is whether anyone knows a program that can help me , or can give me an idea how to do it ? CodeDom can help me ? Is it possible to create CodeDom objects hierarhy from source code ? Thanks -
Hello . I am looking for a program or an idea how to parse C# files . What I mainly need to find is disposing of created objects in the methods In each method in each class that is in the file , I want to look for object creation statement :
myObject = new CMyObject()
And then to see whether this object is disposed in the end of the method ( in the finally ) . And I also want to analyze more stuff . The question is whether anyone knows a program that can help me , or can give me an idea how to do it ? CodeDom can help me ? Is it possible to create CodeDom objects hierarhy from source code ? ThanksHello Well, regular expressions is pretty much what you are looking for. Use it to identify the pattern of creation, then extract the object's name from it. Using that name you can search for disposal code if exists. Since I'm not that good in Regex, I wouldn't be much helpful in phrasing your Regex, but if you don't know Regex: The namespace you'd use :
System.Text.RegularExpressions
A very good tutorial site: This site[^]VoidPointer wrote:
CodeDom can help me ?
CodeDom would be a choice if you want to modify the code and compile it through your program. But if you just want to search and modify something in the cs files -which could be much treated as text files-, then you wouldn't need CodeDom. Ps. You application sounds pretty much as a Visual Studio Add-in!! Is that what you're trying to make?
Regards:rose:
-
Hello Well, regular expressions is pretty much what you are looking for. Use it to identify the pattern of creation, then extract the object's name from it. Using that name you can search for disposal code if exists. Since I'm not that good in Regex, I wouldn't be much helpful in phrasing your Regex, but if you don't know Regex: The namespace you'd use :
System.Text.RegularExpressions
A very good tutorial site: This site[^]VoidPointer wrote:
CodeDom can help me ?
CodeDom would be a choice if you want to modify the code and compile it through your program. But if you just want to search and modify something in the cs files -which could be much treated as text files-, then you wouldn't need CodeDom. Ps. You application sounds pretty much as a Visual Studio Add-in!! Is that what you're trying to make?
Regards:rose:
Thanks . Let's see whether others have some ideas too . I mainly need this for my personal use . ( I have a huge project and we add modules all the time to it and checking this manually is not much fun ) Though maybe I'll convert this functionality ( when and if I'll write it ) into an add-in for VS .