框架goto定义显示注释,这些注释是从xml注释生成的吗? [英] Framework goto definition shows comments, are these generated from xml comments?

查看:52
本文介绍了框架goto定义显示注释,这些注释是从xml注释生成的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我发现我精心设计的xml注释没有出现在我的同事的智能感知中,对此我感到有些惊讶.始终将关联的程序集与项目引用一起使用,我还没有意识到您也必须导出.xml文档才能访问此信息.

I was mildly surprised recently to discover that my carefully crafted xml comments weren't showing up in intellisense for my colleagues. Having always used the associated assemblies with project references, I hadn't realised that you had to export the .xml document as well to access this information.

这使我想知道.Net框架intellisense是如何工作的.如果我理解正确,那么.xml文件必须隐藏在特殊文件夹中的某个地方吗?

This led me to wondering how the .Net framework intellisense works. If I understand correctly, the .xml files must be hidden away somewhere in a special folder?

但是我的主要问题是关于转到定义"的-如果您在.Net框架程序集上转到定义,您会从元数据生成信息-而且还包含大量有用的注释-这些是神奇地从Xml注释生成的,还是是否有人必须编写一个宏+才能将其转换为仅用于构建?换句话说:我如何为我的程序集获得这种效果?

But my main question is about 'Goto definition' - if you goto definition on a .Net framework assembly, you get the info generated from metadata - but also with plenty of helpful comments - are these magically generated from Xml comments, or did someone have to write a macro + to convert them just for the build? Putting it differently: how can I get this effect for my assemblies?

推荐答案

您的项目是否配置为生成XML文档?仅仅是因为您将注释添加到了源代码中,否则编译器将不会生成.xml文件,除非被告知.

Are your projects configured to generate the XML documentation? Just because you add the comments to the source code, the compiler won't generate the .xml file unless it's told to.

在项目属性页面中,转到构建"选项卡,然后查看输出"部分.您应该看到一个标题为"XML文档文件"的复选框.如果该复选框后的文本框为空,则不会生成XML文档文件.

In the project properties page, go to the "Build" tab and look at the "Output" section. You should see a checkbox entry titled "XML documentation file". If textbox following that checkbox is empty you aren't generating the XML documentation file.

一旦生成了XML文档文件,您应该在IntelliSense工具提示中看到您的注释.如果您包含对其他项目的引用作为项目引用,则应自动进行.如果包含对程序集的引用,则需要确保xml文件与所引用的程序集位于同一位置. (在构建时,应该为分别位于bin/debug或bin/release文件夹中的所有程序集获取xml文件.)

Once you get the XML documentation file generated, you should see your comments in the IntelliSense tooltips. If you include references to other projects as a project reference this should happen automatically. If you include references to assemblies, you need to ensure that the xml file is in the same location as the referenced assembly. (When you build, you should get xml files for all of the assemblies that have them in the bin/debug or bin/release folder respectively.)

对于.NET Framework程序集本身,相应的xml文档文件作为Framework的一部分安装.对于.NET 2.0、3.0或3.5,文档文件位于C:\Windows\Microsoft.NET\Framework\v2.0.50727\en(假定框架为默认安装).这些文件由IntelliSense工具提示和Visual Studio中的转到定义"功能使用,以便显示此信息.没有进行任何特殊处理或运行宏来实现此目的. Visual Studio最有可能使用的唯一信息是注册表项的组合,以确定文档文件的正确路径.

For the .NET Framework assemblies themselves, the corresponding xml documentation files are installed as part of the Framework. For .NET 2.0, 3.0, or 3.5 the documentation files are located at C:\Windows\Microsoft.NET\Framework\v2.0.50727\en (assuming a default installation of the Framework). These files are used by both the IntelliSense tooltips and the "Go to Definition" functionality in Visual Studio in order to display this information. There is not any special processing that takes place or macros run in order to make this happen. The only information Visual Studio most likely uses is a combination of registry keys to determine the correct path to the documentation files.

虽然您可能可以在同一文件夹中找到自己的程序集的xml文档文件,但我建议您不要这样做,因为这样您便会使用与非Framework相关的文件来污染Framework安装.

While you probably could locate the xml documentation files for your own assemblies in the same folder, I would recommend against doing so as you then pollute the Framework installation with non-Framework related files.

这篇关于框架goto定义显示注释,这些注释是从xml注释生成的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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