this is my first post, so bear with me.
i have scoured google for the last couple of days looking for how to do this.
i even found something that appeared to be similar here:
Find out if cursor is inside a method, class or namespace block
but what i am looking for is slightly different.
I am looking to make a simple addin/package that will take me to the first concrete implementation of an interface.
so, given the code below:
class Program
{
static void Main(string[] args)
{
var t = new Test();
var testValue = t.Prop1;
}
}
class Test : ITest
{
public string Prop1 { get; set; }
}
public interface ITest
{
string Prop1 { get; set; }
}
suppose the caret ("|") is on this line: "var testValue = t.Pr|op1;"
how can i tell what class the property Prop1 belongs to?
i set up both a package and add in project that attempted to get this info. the closest i got was getting the current CodeElement, which is not exactly the same thing as i described above. the CodeElement at the caret returned me Program.Main, which is not what i was looking for.
i also tried finding out how Edit.GoToDefinition works (using reflector) to no avail.
i could list all of the lengths i went through to find this out, but want to keep this post short.
thanks for any help. this site is the best.