Build feature like "Find all references" in VS2008
-
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.
-
-
Then I guess that you should write your parser and parse all the source files
-
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.
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
-
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.
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:
-
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.
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.
-
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.
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.
-
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:
-
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
-
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.
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.
-
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.
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.