|
I think that the answer stays inside the Visual Studio Extensibility and the Visual Studio SDK. Try starting from here[^]...
|
|
|
|
|
Thank you for reply.
But I want to build independent tool (not a add-in tool)
|
|
|
|
|
Then I guess that you should write your parser and parse all the source files
|
|
|
|
|
One way to do this would be to use something like an Abstract Syntax Tree to represent the code you are trying to model.
|
|
|
|
|
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?
|
|
|
|
|
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
|
|
|
|
|
The source is source-code, not a compiled assembly.
|
|
|
|
|
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.
|
|
|
|
|
what references? type references (classes, structs, enums...)? file references (dll)? and why? give some context, it will help you get useful answers.
|
|
|
|
|
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).
|
|
|
|
|
Hi
Just seeking some help with a linked list in C# and if it can do what I require it to do. Below is a simple version of what I want to do.
public LinkedList<Object> createList()<br />
{<br />
LinkedList<Object> l = null;<br />
MyObject oj = new MyObject;<br />
l.addLast(oj);<br />
<br />
return l;<br />
}<br />
<br />
public convertObject()<br />
{<br />
LinkedList<MyObject> list = (MyObject)executeSQL(sql, array);<br />
}
The reason for this is because i want the createList to remain generic as the actual code will be used to collect data from a database, place the data in objects and then add it to the linkedlist. At all times the link list will only contain 1 object type but i want to be able to re-use the method regardless of what object type it is. Originally I had this working using ArrayList but I would prefer to use LinkedList due to the added features.
I hope the above explained what I wanted without having to type the actual code which is a couple of pages long.
Any help would be appreciated, if you need more info then let me know.
Cheers
|
|
|
|
|
You can work around the List(T) Class (System.Collections.Generic)[^]: it gives you all the functionalities of a linked-list and it's a generic type. What you need is to write down a class, that internally uses a List<object> member, and that expose the methods that you need to do your job.
|
|
|
|
|
I have managed to get the following to work but I would like to keep it as a linkedList rather then converting it to an array.
public Access[] findAll()<br />
{<br />
string sql = "SELECT * FROM access";<br />
<br />
LinkedList<Object> list = executeSQL(sql);
<br />
Access[] aArray = new Access[list.Count];<br />
list.CopyTo(aArray, 0);<br />
<br />
return aArray;<br />
}
|
|
|
|
|
Apologies about my first reply, I misunderstood your question. How about:
public LinkedList<T> ExecuteSQL<T>(sql)
{
}
public LinkedList<T> findAll<T>()
{
string sql = "SELECT * FROM access";
return ExecuteSQL<T>(sql);
return aArray;
}
Then you can specify the type, or you can change T to Object .
[Edit]: added the l to "public", Freud would have a field-day with me
|
|
|
|
|
Thank You so much. That works, all i needed to do was add the <t> in front of the method name
|
|
|
|
|
|
I now have a new problem. My code is as follows
private LinkedList<T> makeList<T>( SqlDataReader reader )<br />
{<br />
LinkedList<T> list = new LinkedList<T>();<br />
<br />
while( reader.Read() )<br />
{<br />
list.AddLast(makeObject(reader));<br />
}<br />
<br />
return list;<br />
}<br />
<br />
public abstract object makeObject( SqlDataReader r );
this line list.AddLast(makeObject(reader)); is showwing the error "cannot convert from object to t"
What have I done wrong? and how can I fix it?
Nevermind, Problem solved by
list.AddLast((T)makeObject(reader))<code><br />
<div class="signature"><br />
<div class="modified">modified on Monday, October 18, 2010 6:22 AM</div></div>
|
|
|
|
|
The following is safer, unless you know you are only getting Type T objects, (or T is not a class)
T value = makeObject(reader) as T
if(value != null)
{
list.AddLast(value)
}
You'll Also need to :
private LinkedList<T> makeList<T>( SqlDataReader reader )
where T: class
{
}
|
|
|
|
|
I don't know if this could help, but I wonder if a makeObject<t> method would do what you want, I mean:
public abstract T makeObject<T>(SqlDataReader r);
bye
|
|
|
|
|
There is a generic linked list[^] in .net 3.5 and above, this will do exactly as you ask, or you could just use the generic List<T> type, but this doesn't expose the AddBefore/AddAfter etc members that the LinkedList<T> does.
[Edit]
See previous thread, this isn't what the OP was asking for.
|
|
|
|
|
Yes but how do I keep it generic untill the last minute?
I have tried
public Access[] findAll()<br />
{<br />
string sql = "SELECT * FROM access";<br />
<br />
LinkedList<T> list = executeSQL(sql);
<br />
Access[] aArray = new Access[list.Count];<br />
list.CopyTo(aArray, 0);<br />
<br />
return aArray;<br />
}<br />
<br />
public LinkedList<T> executeSQL( string sql, string [] array )<br />
{<br />
LinkedList<T> list = null;<br />
<br />
try{<br />
<br />
...<br />
<br />
return list;<br />
}
but that does not work
|
|
|
|
|
Hello Friends,
I have made a Web Service and am using its reference in a Window Service that is being executed/called every 1 min. Through the Web Service, I am connecting to a remote MySQL Server database in which some of the table are accessed and data is being inserted/updated into them.
As the current window service is still in development phase, so whenever i install the batch file of the window service every other day, just in order to check that whether the whole process is running fine or not, The web-service throws an error:-"Unable to connect to server". This error comes only when the web-service is unable to connect to the remote server .
But the moment i rebuild the web-service at my my machine and then update (replace) it on the web-server and again add it as a reference to the window service then after rebuilding the window service when i run the batch installation file of window service; the whole process executes absolutely fine and the web-server database tables gets updated.
I am not able to sort out why an unusual behavior is being shown by web service. Please help me out.
Thanks
Varun Sareen
|
|
|
|
|
I believe your webservice reference includes the IP (is pointing directly) to the remote server.
This is probably what is creating the problem.
Remove this reference by changing your code to point to a dynamic IP and things should be fine.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Thanks dear Abhinav for providing such clarity but are you talking about:-
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053");
the italicized text or the Server address in the connection string.?
<add key ="ConnectionString" value="Server="ip address"; Uid="userId"; Pwd="password"; Host="hostname"; Port=3306; Database="dbName"; Compress=false; Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0;"/>
Thanks
Varun Sareen
|
|
|
|