[英]Browsing the .NET Framework source code from Visual Studio
I know that I can set up Visual Studio to debug through the .NET framework source code .我知道我可以设置 Visual Studio 以通过 .NET 框架源代码进行调试。
But is there a way that I can browse the code while NOT debugging - ie, being able to press F12 or "Go to definition"?但是有没有一种方法可以让我在不调试的同时浏览代码——即,能够按 F12 或“转到定义”?
I thought that if that feature isn't built into Visual Studio then there may be a plug-in that might add it?我想如果该功能没有内置到 Visual Studio 中,那么可能会有一个插件可以添加它?
There is a very new feature in Visual Studio 2017 version 15.6 Visual Studio 2017版本15.6 中有一个非常新的功能
You can see decompiled source code without any plugin!不用任何插件就可以看到反编译的源码! Btw, Ref12 doesn't work for VS2017.顺便说一句,Ref12 不适用于 VS2017。
Tools > Options , expand Text Editor > C# > Advanced , and enable " Enable navigation to decompiled sources (experimental) ".工具>选项,展开文本编辑器> C# >高级,并启用“启用导航到反编译源(实验) ”。
Ref: https://docs.microsoft.com/en-us/visualstudio/ide/go-to-and-peek-definition?view=vs-2017#view-decompiled-source-definitions-instead-of-metadata-c参考: https : //docs.microsoft.com/en-us/visualstudio/ide/go-to-and-peek-definition? view = vs-2017#view-decompiled-source-definitions-instead-of- metadata- C
With ReSharper it's possible to browse .NET sources by enabling ReSharper -> Options -> Tools -> External Sources -> Navigation to Sources.使用 ReSharper,可以通过启用 ReSharper -> Options -> Tools -> External Sources -> Navigation to Sources 来浏览 .NET 源。 After enabling this option new menu item "Navigate To -> Decompiled Sources" appears by right click on type/method/whatever.启用此选项后,通过右键单击类型/方法/任何内容,会出现新菜单项“导航到-> 反编译源”。 Navigation also works with F12 for me.导航也适用于我的 F12。
I just discovered this extension that pretty much addresses my problem.我刚刚发现这个扩展几乎解决了我的问题。 The only thing is that it opens the source in the browser rather than in Visual Studio, but it's no big deal because even in the browser you can click the source code to navigate to types etc.唯一的问题是它在浏览器中而不是在 Visual Studio 中打开源代码,但这没什么大不了的,因为即使在浏览器中,您也可以单击源代码以导航到类型等。
It was presented on Scott Hanselman's blog a couple of days ago:几天前,它出现在 Scott Hanselman 的博客上:
Community member and fabulous coder Schabse Laks has created a Visual Studio extension for VS2010, 2012, and 2013!社区成员和出色的编码员 Schabse Laks 为 VS2010、2012和 2013 创建了 Visual Studio 扩展! This extension sends calls to Go To Definition (or pressing F12 on a symbol) directly to the code online (when it's .NET Framework code, not yours).此扩展将调用 Go To Definition(或在符号上按 F12)直接发送到在线代码(如果它是 .NET Framework 代码,而不是您的代码)。
You can download this companion "Ref12" Visual Studio Extension now !您现在可以下载这个配套的“Ref12”Visual Studio 扩展! Just Goto Definition on any .NET type we have source for and it'll launch your default browser so you can explore the .NET Framework source yourself!只需在我们拥有源代码的任何 .NET 类型上转到定义,它就会启动您的默认浏览器,以便您可以自己探索 .NET Framework 源代码! Thanks Schabse!谢谢沙布斯!
I downloaded the .NET Framework source code from here http://referencesource.microsoft.com/netframework.aspx .我从这里下载了 .NET Framework 源代码http://referencesource.microsoft.com/netframework.aspx 。
Since I am working with .NET 4.0, I chose ".Net/4" from the list.由于我使用 .NET 4.0,因此我从列表中选择了“.Net/4”。 (What is ".NET/8.0" in that list? No idea.) (该列表中的“.NET/8.0”是什么?不知道。)
I wrote some scripts to rearrange the bloody mess they give us:我写了一些脚本来重新安排他们给我们的血腥混乱:
Then follow these steps:然后按照以下步骤操作:
Intellisense/ReSharper still complains about heaps of problems, but now I can right click and select "Go to Declaration/Implementation". Intellisense/ReSharper 仍然抱怨大量问题,但现在我可以右键单击并选择“转到声明/实施”。
Visual Studio is about 600MB with this project loaded.加载此项目后,Visual Studio 大约有 600MB。
I am using Visual Studio 2013 Ultimate.我正在使用 Visual Studio 2013 Ultimate。
1. Choose menu: TOOLS \\ Extensions and Updates... 1.选择菜单:工具\\扩展和更新...
2. Choose Visual Studio Gallery \\ Search Results . 2.选择Visual Studio Gallery \\ Search Results 。 Search term: Ref12
.搜索词: Ref12
。
3. Download then install. 3.下载然后安装。
4. Restart Visual Studio. 4.重新启动 Visual Studio。
5. Try: Click mouse on Class or method, press F12 and see result at http://referencesource.microsoft.com/ 5.尝试:在类或方法上单击鼠标,按F12并在http://referencesource.microsoft.com/ 上查看结果
I've never tried this but supposedly the code is publicly available:我从来没有试过这个,但据说代码是公开的:
[Edit] [编辑]
http://referencesource.microsoft.com/ http://referencesource.microsoft.com/
There is the .NET Mass Downloader , but I think the straightforward answer to your question is, no.有.NET Mass Downloader ,但我认为对您的问题的直接答案是,不。
However I now see Microsoft has made the code more easily downloadable.但是,我现在看到 Microsoft 使代码更易于下载。
Nevertheless note that even for your own code, when not debugging, unless you have the project open, VS does not help you locate source code (even though when you find it yourself break points will work when you start debugging again, if the .pdb
files correspond).不过请注意,即使对于您自己的代码,在不调试时,除非您打开了项目,否则 VS 不会帮助您定位源代码(即使您自己找到了断点,当您再次开始调试时,如果.pdb
文件对应)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.