• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

VisualStudio2005/2008F12"GoToDefinition"fromVBtoC#

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#DataGridView隔行显示不同的颜色发布时间:2022-07-13
下一篇:
C#使用Newtonsoft.Json读写Json文件发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap