views:

20

answers:

1

I am in a c# project, in this project I reference (using a project reference) another class library written in vb.net.

Now, when I right click and view definition on the class. It doesn't take me to the exact source code in the vb.net project, instead it takes me to a dynamically generated c# representation of the vb.net class.

I've tried the experiment in reverse, starting with a vb.net project, and referencing a c# project, this time on a right click view definition, it takes me to the code explorer, so again, not the original code for editing.

If both projects are the same language, everything works like nicely.

Is there an explanation for this? And possibly a solution to allow easy code navigation between projects of different languages?

To reproduce:

  1. Create a blank solution
  2. Add a c# class library
  3. Add a vb.net class library
  4. In the vb.net class library, class1 - create any old method. (optional)
  5. In the c# class, add a reference to the vb.net class, for example:

    VBClassLibrary.VBClass myVBClass = new VBClassLibrary.VBClass();

Now, right click on VBCLass and select "Go To Definition".

Notice where you end up....

+3  A: 

There is nothing you are doing wrong here. This is an unfortunte side effect of how Visual Studio is designed. When you have two projects in different languages a reference between them does not behave like a project reference but instead resembles a file reference.

Project to Project references of the same language share a single language service. Hence it is in control of all of it's code and can provide special live content benefits. The primary one being the goto definition and instant intellisense. There is just no facility in Visual Studio today to allow language services to communicate with each other across the reference boundary like you desire.

JaredPar
I've run into the same exact thing. Another annoying side effect is the <summary> tag information doesn't cross the language boundary in the IDE either.
RQDQ