获取类的源$ C ​​$ C,而不是元数据在Visual Studio [英] Get class source code instead of Metadata in Visual Studio

查看:84
本文介绍了获取类的源$ C ​​$ C,而不是元数据在Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候当我在一个项目上工作的时候,我会打我的按钮转到定义(F12是我觉得默认的)一个类或方法或什么的。大!这就像一个梦期待在那里我有一个内置的组件code的情况。在这些情况下,定义被包含在所产生的[由元数据]'文件。当然,这是有道理的,尤其是对第三方的东西,但在哪里,我知道其中源$ C ​​$ C位于情况怎样?有没有一种方法可以让我的Visual Studio将在额外的努力,导航到code?是否有一个宏或东西在那里,可以做到这一点?难道我注定?

Sometimes when I am working away on a project, I will hit my button for 'go to definition' (F12 is the default I think) on a class or method or whatever. Great! This works like a dream expect for cases where I have code that is built into an assembly. In these cases the 'definition' is contained in a generated '[from metadata]' file. Of course this makes sense, especially for 3rd party stuff, but what about cases where I know where the source code is located? Is there a way I can Visual Studio to put in the extra effort to navigate to the code? Is there a macro or something out there that can do this? Am I doomed?

P.S。结果
我知道ReSharper的和类似的工具大概可以做到这一点,但我没有他们,所以我们只排除这些类型的答案出来了。

p.s.
I know that Resharper and similar tools can probably do this, but I don't have them so let's just rule those type of answers out now.

推荐答案

底线是,你不能使用转到定义对于那些通过文件引用包含在项目类(查看源代码code通常情况下,第三方组件)。对于通过项目引用包括类,您将能够查看code这个样子。所有的去定义所做的是试图找到code文件在您的项目或类型引用的项目。如果没有可用的code文件(这将是第三方组件的情况下),这将无法表现出来,让您从类型的元数据生成的定义。

The bottom line is that you can't view source code using "Go to definition" for classes which are included in your project via file references (typically, third-party assemblies). For classes which are included via project references, you will be able to view the code in this way. All "Go to definition" does is try to locate the code file for the type in your project or a referenced project. If you don't have the code file available (which would be the case for third-party assemblies), it won't be able to show it and gives you the definition generated from the type metadata.

如果您知道源$ C ​​$ C的位置,你可能做到这一点使用某种类型的宏或只是把它作为一个项目引用而非文件引用。

If you know where the source code is located, you could possibly do this using a macro of some sort or just include it as a project reference rather than a file reference.

这篇关于获取类的源$ C ​​$ C,而不是元数据在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆