Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Search for statements in CS files.

Search for statements in CS files.

Scheduled Pinned Locked Moved C#
questioncsharphelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Iagovsky
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • A Alex Iagovsky

      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

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      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:

      A 1 Reply Last reply
      0
      • N Nader Elshehabi

        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:

        A Offline
        A Offline
        Alex Iagovsky
        wrote on last edited by
        #3

        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 .

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups