0

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.

Community
  • 1
  • 1
Devastator
  • 11
  • 1
  • What version of visual studio are you using? VS2013 Ultimate does this already. – Scott Solmer Dec 18 '13 at 23:06
  • I am using VS2013. I am looking to make a simple addin/package that will take me to the first concrete implementation of an interface, which VS2013 does in a round about way with "View Call Hierarchy". But I would rather have a quicker way to navigate to it. I am aware that ReSharper and CodeRush do this, but don't want to install their whole suite in order to get that one piece of functionality. – Devastator Dec 19 '13 at 15:22

1 Answers1

0

Have you tried right click, go to definition / go to declaration?

  • Ha, I guess my question looks pretty dumb without mentioning to what end I need that info. I am looking to make a simple addin/package that will take me to the first concrete implementation of an interface, as described above. It is similar to go to definition for sure. I just wish that there was a way of getting the definition info before going to the definition, make sense? – Devastator Dec 19 '13 at 16:17