在.NET中使用XML注释有什么好处? [英] What are the virtues of using XML comments in .NET?

查看:98
本文介绍了在.NET中使用XML注释有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白使用XML注释的好处.我知道可以将它们转换为代码外部的漂亮文档,但是可以使用更加简洁的DOxygen语法来实现.我认为XML注释是错误的,因为:

I can't understand the virtues of using XML comments. I know they can be converted into nice documentation external to the code, but the same can be achieved with the much more concise DOxygen syntax. In my opinion the XML comments are wrong, because:

  1. 他们通常会混淆注释和代码. (它们更难于人类阅读.)
  2. 更少的代码可以在一个屏幕上查看,因为"summary"和"/summary"需要多行.
  3. (已删除)

那可能是什么原因,为什么在.NET中首选XML而不是简单的DOxygen语法?

What then could have been be the reasons, why XML was preferred in .NET rather that the simple DOxygen syntax?

推荐答案

此处imo并没有正确的答案.在现实中,这两个系统都不比另一个系统好"-它们最终都完成相同的工作,这使您可以生成代码文档.

There is not really a correct answer here imo. Neither system is "better" than the other in reality - they both do the same job in the end, which is allow you to generate code documentation.

最终输出可以用完全相同的方式格式化,而且它们在支持的标签等方面确实具有几乎相同的功能,因此,这实际上取决于个人选择.

The final output can be formatted in exactly the same way for each of them, and they do have pretty much the same functionality in terms of what labels etc they support, so its really down to personal choice here.

我个人认为XML注释更具可读性,逻辑性和简单易用性-但这具有Visual Studio自动生成供我填充的存根的附加优点,以及出色的支持它可以折叠它们,因此它们不会在屏幕上占用很多空间.我敢肯定,来自VI或some_other_IDE中的后台编辑的人会有不同的看法,但两者都没有真正的优势.

Personally I find XML comments to be much more human readable, much more logical and just plain easy to use - but that is with the added advantage of having visual studio automatically generate stubs for me to just fill in, and the excellent support it has for collapsing them so they don't take up lots of space on the screen. I am sure that someone who comes from a background editing in VI or some_other_IDE will have a different opinion, but there is no real advantage to either.

所以我要说的是,这实际上取决于您使用的是什么IDE,以及您和您的团队习惯了什么.

So I would say that really it depends on what IDE you are using and what you and your team are used to using.

现在,如果您要问微软为什么选择在Visual Studio中与XML注释紧密集成,那就是另一个问题.最有可能是由于以下事实:对于他们来说,在VS中实施会更简单(因为他们可以重用现有代码来生成/读取注释并构建智能感知等),因此他们倾向于遵循标准" "(无论是他们自己的还是行业的),还有Jeff提到的许可原因.

Now if you are asking why Microsoft have chosen to integrate so tightly with XML commenting within Visual Studio, that is a different question. Most probably it is due to the facts that: it would be simpler for them to implement within VS (as they can re-use existing code to generate/read the comments and build intellisense etc), they have a trend for sticking to "standards" anyway (be it their own or industry ones), and also licensing reasons as mentioned by Jeff.

只需补充一点,Microsoft在VS中使用的产品称为"Sandcastle",它是内部XML文档生成工具.它有自己的Wiki页面@ http://docproject.codeplex.com/Wikipage

Just to add that the product Microsoft is using within VS is called "Sandcastle", which is an in-house XML doc generation tool. It has its own wiki page @ http://docproject.codeplex.com/Wikipage

这篇关于在.NET中使用XML注释有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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