1
当Visual Studio中的插入符号位于对象创建或引用某个其他类的方法时,我想获得完整的文件路径。是否有可能使用coderush API获取源代码所在类的完整文件路径?
喜欢的东西
Class CurrentClass
{
Class2 object1=new Class2();
object1.method1();
}
我能得到这样c中的完整的文件路径:\ ProjectLocation \ Class2.cs。
当我在visual studio中得到这一行。
Class2 object1=new Class2();
谢谢亚历克斯...这工作正常.. :) – Sachin 2011-05-17 13:24:43
我只是想与coderush做一些基本的东西,像获得父类中的所有方法...并且我尝试**类** **父= ** ** declaraton。 GetDeclaration()** **作为** **类**并试图使用** parent.AllMethods **,这并没有给予该类中所有方法的访问权限....我试着用** TypeReferenceExpression **有没有她需要看的类或函数? – Sachin 2011-05-20 12:28:37
我们的代码中的'声明'应该是ITypeElement类型的实例,因此请尝试使用如下代码: ITypeElement typeInstance =声明为ITypeElement; if(typeInstance!= null) foreach(typeInstance.Members中的IMemberElement成员) IMethodElement method = member as IMethodElement; if(method!= null) { // do something something method ... } } – 2011-05-20 16:04:36