Reputation: 20350
Is there a way to access the types (Classes, Interfaces, etc., and their meta data) that are available inside the loaded projects within a solution in Visual Studio?
To be more specific, I'm attempting to develop a simple Visual Studio Add In to provide "Go To Implementation" functionality:
https://bitbucket.org/jbubriski/go-to-implementation/
I realize that this exists in other productivity Add Ins/Extensions, but I'm making a bare bones one so I don't have to deal with slow downs, hangs, and crashes from other added "features".
If you look at the source, I'm able to get the currently selected text using a very basic and fragile method. Given the selection, I basically assume that it is an interface, strip off the 'I', and do a Solution-wide search for ProjectItems
where the file name ends in "\TypeName.cs"
.
Is there some internal list of types that Visual Studio maintains for intellisense that I have access to? It would be nice to say:
var vsType = VS.GetLocalType("TypeName")
Then access
vsType.FileName
One step further would be
foreach(var vsType in VS.GetlocalTypes())
{
if(vsType.Implements.Contains("IInterfaceName"))
{
// Found something that implements my interface!
}
}
Any ideas?
Upvotes: 2
Views: 411
Reputation: 161773
More details later, if I get time, but see http://msdn.microsoft.com/en-us/library/system.componentmodel.design.ityperesolutionservice.aspx.
Upvotes: 1
Reputation: 465
Not sure about native VS addons implementation, but if you are using DevExpress.CodeRush, goto definition functionality should be based on current position in source file, and do something like this to retrieve reference to declaring type:
((TypeReferenceExpression)CodeRush.Source.Active).GetDeclaringType()
P.S. I understand that I didn't answer on yor question, but hope this will give you a direction to search a solution
Upvotes: 1