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
  1. Home
  2. General Programming
  3. C#
  4. Build feature like "Find all references" in VS2008

Build feature like "Find all references" in VS2008

Scheduled Pinned Locked Moved C#
visual-studiohelptutorialquestion
12 Posts 6 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.
  • N Offline
    N Offline
    ndkit
    wrote on last edited by
    #1

    Hi all, I want to build my own feature like "Find all references" in VS 2008. Is there anyone know how to build it? Pls. help me.

    S P L T L 5 Replies Last reply
    0
    • N ndkit

      Hi all, I want to build my own feature like "Find all references" in VS 2008. Is there anyone know how to build it? Pls. help me.

      S Offline
      S Offline
      Sauro Viti
      wrote on last edited by
      #2

      I think that the answer stays inside the Visual Studio Extensibility and the Visual Studio SDK. Try starting from here[^]...

      N 1 Reply Last reply
      0
      • S Sauro Viti

        I think that the answer stays inside the Visual Studio Extensibility and the Visual Studio SDK. Try starting from here[^]...

        N Offline
        N Offline
        ndkit
        wrote on last edited by
        #3

        Thank you for reply. But I want to build independent tool (not a add-in tool)

        S 1 Reply Last reply
        0
        • N ndkit

          Thank you for reply. But I want to build independent tool (not a add-in tool)

          S Offline
          S Offline
          Sauro Viti
          wrote on last edited by
          #4

          Then I guess that you should write your parser and parse all the source files

          1 Reply Last reply
          0
          • N ndkit

            Hi all, I want to build my own feature like "Find all references" in VS 2008. Is there anyone know how to build it? Pls. help me.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            One way to do this would be to use something like an Abstract Syntax Tree to represent the code you are trying to model.

            I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Onyx

            N 1 Reply Last reply
            0
            • N ndkit

              Hi all, I want to build my own feature like "Find all references" in VS 2008. Is there anyone know how to build it? Pls. help me.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              ndkit wrote:

              I want to build my own feature like "Find all references" in VS 2008.

              Using the source-code as a source, or would you accept using a compiled assembly as a source? The latter could be done using reflection, like so;

              foreach(AssemblyName referencedAssemblyName in Assembly
              .GetExecutingAssembly()
              .GetReferencedAssemblies())
              {
              Console.WriteLine(referencedAssemblyName.FullName);
              }

              I are Troll :suss:

              N 1 Reply Last reply
              0
              • N ndkit

                Hi all, I want to build my own feature like "Find all references" in VS 2008. Is there anyone know how to build it? Pls. help me.

                T Offline
                T Offline
                T M Gray
                wrote on last edited by
                #7

                Your requirements aren't very clear. If it isn't in Studio, what do you want to find the references in? Are you planning on using the solution or project files? Are you going to try to find references across projects? I would suggest finding a textbook for a university level class on compiler theory and see if the concepts are comfortable to you. If they seem way over your head, then find a different project to work on.

                1 Reply Last reply
                0
                • N ndkit

                  Hi all, I want to build my own feature like "Find all references" in VS 2008. Is there anyone know how to build it? Pls. help me.

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  what references? type references (classes, structs, enums...)? file references (dll)? and why? give some context, it will help you get useful answers. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  N 1 Reply Last reply
                  0
                  • L Lost User

                    ndkit wrote:

                    I want to build my own feature like "Find all references" in VS 2008.

                    Using the source-code as a source, or would you accept using a compiled assembly as a source? The latter could be done using reflection, like so;

                    foreach(AssemblyName referencedAssemblyName in Assembly
                    .GetExecutingAssembly()
                    .GetReferencedAssemblies())
                    {
                    Console.WriteLine(referencedAssemblyName.FullName);
                    }

                    I are Troll :suss:

                    N Offline
                    N Offline
                    ndkit
                    wrote on last edited by
                    #9

                    The source is source-code, not a compiled assembly.

                    1 Reply Last reply
                    0
                    • P Pete OHanlon

                      One way to do this would be to use something like an Abstract Syntax Tree to represent the code you are trying to model.

                      I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                      Forgive your enemies - it messes with their heads

                      My blog | My articles | MoXAML PowerToys | Onyx

                      N Offline
                      N Offline
                      ndkit
                      wrote on last edited by
                      #10

                      Thank for your help! I google to find some information about AST, but I can find a litle infor about it. Beside, I found CODEDOM parser (also in this site) and also looking on it. Can you explain or give more information about AST parser for me?

                      1 Reply Last reply
                      0
                      • L Luc Pattyn

                        what references? type references (classes, structs, enums...)? file references (dll)? and why? give some context, it will help you get useful answers. :)

                        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                        N Offline
                        N Offline
                        ndkit
                        wrote on last edited by
                        #11

                        Sorry, I explain more details as below: This is my context I have two solutions A & B which have many projects. In each project, I have class C (or method, or variable) that can be used in other project of same solution (example: A solution) or another solution (B). Each time I want to find class C (all places that is used), I must find in both solutions A & B. It can take more time and not easy to track information between two solutions. So I want to build a tool to analyze both solutions & give all references of class C in A & B. So, in order to find all references of class C, I just searching on a tool.

                        L 1 Reply Last reply
                        0
                        • N ndkit

                          Sorry, I explain more details as below: This is my context I have two solutions A & B which have many projects. In each project, I have class C (or method, or variable) that can be used in other project of same solution (example: A solution) or another solution (B). Each time I want to find class C (all places that is used), I must find in both solutions A & B. It can take more time and not easy to track information between two solutions. So I want to build a tool to analyze both solutions & give all references of class C in A & B. So, in order to find all references of class C, I just searching on a tool.

                          L Offline
                          L Offline
                          Luc Pattyn
                          wrote on last edited by
                          #12

                          That is a big job. The proper way to do this is by creating a full C# parser, and let it loose on the source files of all the projects in the solution(s). Are you sure you can't just use your IDE's class browsing facilities? You could cheat quite a bit, like so: - just scan all source files for curly brackets { and } to locate classes; if you assume namespaces are used, a class would be at nesting level 2 of {}; - within each class, search for the type name you're interested in; - within each class that mentions the type name of interest, look for the type's member you're interested in. This will yield some false positives, as it: - does not discern code from comment; - does not recognize string literals; - does not associate the member name with the type you're looking for (i.e. while looking for: TextBox.Text, it will also find

                          TextBox tb;
                          string s=myButton.Text;

                          However it will also not work well with nested types, e.g. a class nested inside another class. When the inner class holds what you are looking for, it would flag the outer class as positive (hence even more false positives). :)

                          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                          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