Given a string that represents a specific class/field/property (eg MyNameSpace.MyClass
or System.String.Length
), how can I programmatically cause Visual Studio to go to that class/field/property (ie, make Visual Studio do the same thing that would happen if I was to type in the reference in the code editor and then hit F12)?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You probably need to do the following.
IVsObjectManager2
interface (implemented by theSVsObjectManager
object)IVsObjectManager2.FindLibrary
to get the C# library, and cast the result toIVsSimpleLibrary2
.Call
IVsSimpleLibrary2.GetList2
with the correctVSOBSEARCHCRITERIA2
in order to locate the symbol within the projects for your solution.If the resulting
IVsSimpleObjectList2
hasGetItemCount()
==1
, andCanGoToSource
withVSOBJGOTOSRCTYPE.GS_DEFINITION
returnspfOK==true
, use theGoToSource
method to jump to the source.Otherwise, rather than jumping to the source, simply display the possible options to the user. You will be able to use the
IVsFindSymbol
interface (implemented by theSVsObjectSearch
object) to for this.