Visual Studio 2005/2008 F12 "Go To Definition" from VB to C#

Should "Go To Definition" from a VB Web Application display C# code in a referenced C# code library project?  I created a VB Web application that calls both a VB Code Project Library and a C# Code Project Library.  When attempting to select “Go To Definition” of the VB method 'GetTestData()' I am able to view the VB class code.  However selecting “Go To Definition” on the C# method 'GetTestData()' sends me to the object browser.  Is this normal for C#?

To test against C#, I created a Test C# Web App, and both the VB and C# (F12) are sent to the code.  Am I seeing the correct behavior, or is there a way for the VB application to drill down to C# Code?  I should note the C# code does debug fine.  It will be able to maintain a large C# Code Library we are using in our Web Application unless I find a workaround for this issue.  Thanks.

----------------------

This is the reason i got from product team

This issue is by design given our current architecture and has always existed in the product.   The reason this occurs is because a different compiler is used for each type of project (the C# one for C# projects and the VB one for VB projects) and they each populate a separate symbol table.  This symbol table is not shared in a live way across the two types of projects – symbol sharing occurs once an assembly has been flushed to disk.

The project-to-project reference between a C# and VB project is treated like a file assembly reference where all symbols are treated as if coming from metadata.

----------------------

from: http://forums.asp.net/p/1260157/3482953.aspx#3482953

http://connect.microsoft.com/VisualStudio/feedback/details/107490/the-go-to-definition-thing-does-not-work-across-different-c-c-projects-in-the-same-solution

https://connect.microsoft.com/VisualStudio/feedback/details/501303/find-all-references-go-to-definition-do-not-work-across-vb-c-in-same-solution

 

F12 - Go To Definition

A few months ago when Bill Gates was on the Daily Show, Jon Stewart asked him a particularly insightful software question:

"So...what does the F12 button do?  Does it do anything?  Is it a joke button".  To which Bill replied jokingly - "I'd stay away from it if I were you." 

If you use Visual Studio though - I recommend you ignore Bill's advice here.  F12 is a quite useful keyboard shortcut.

Go To Definition

F12 itself invokes the "Go To Definition" (GTD) command.  This works on types, members, locals, range variables, etc.  It uses all the compiler's internal understanding of the code to make sure it takes you to the right member - even when there are many overloads or if your code is using a lot of type inference.

Metadata As Source

One of the additions to "Go To Definition" support in Visual Studio 2005 was something we call "Metadata as Source".  If you go to definition on a type which is defined in a referenced assembly - you will be presented with a "header file"-style view of the corresponding type and it's members.  This keeps you in the editor - and gives a convenient view of the type.  You can continue to navigate other members/types directly from the Metadata As Source view by using GTD again on those tokens.

Backward and Forward navigation

If you use GTD a lot, you'll probably find yourself wanting to go "back" to where you invoked "go to definition" from.  It turns out there is a keybinding for this:

  • ctrl-shift-8: Takes you back in the GTD stack, to the the last place you invoked GTD
  • ctrl-shift-7:  Takes you forward in the GTD stack, to the last place you invoked back
Code Definition Window

The Code Definition Window is toolwindow which shows a live GTD of whatever symbol is currently under the cursor in the editor.  If you find yourself using GTD a lot, you may want to pop up the Code Definition Window with ctrl-w-d.

BTW - If you are looking for more useful keyboard shortcuts using the C# Profile in Visual Studio - take a look at  the C# keybinding posters Karen blogged about a little while ago.

From: http://blogs.msdn.com/lukeh/archive/2007/06/04/f12-go-to-definition.aspx

你可能感兴趣的:(init)