Visual Studio XML注释(摘要)和特殊字符 [英] Visual Studio XML comments (summary) and special characters

查看:229
本文介绍了Visual Studio XML注释(摘要)和特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#/Wpf项目中有一个方法,我想使用这样的XML注释来注释/记录它

I have a method in a C# / Wpf project and I'd like to comment / document it using the XML comments like this

    /// <summary>
    /// Initialises Drag & Drop
    /// </summary>
    void initDragDrop()
    {

    }

当我现在在项目中的某处使用此方法并将鼠标悬停在该方法上时,我会收到消息 "XML注释包含无效的XML:在此位置不允许有空格"(我将冒号后的文本手动翻译为英语,因此在您的Visual Studio中可能不是字面上的意思). 我发现问题是&"标志,如果我将其删除,则效果很好.但是我想保留它,那么如何在XML摘要中对其进行转义?我尝试过"\&"但这不起作用.

When I now use this method somewhere in my project and hover the mouse over it, I get the message "XML comment contains invalid XML: At this place, no spaces are allowed" (I translated the text after the colon manually to english, so it may not be literally in your visual studio). I found out the problem is the "&" sign, if I remove it, it works fine. But I want to keep it, so how to I escape it in the XML summary? I tried "\&" but this isn't working.

谢谢您的提示!

推荐答案

请记住,&字符在xml(实体的开始)中具有特殊含义.您需要改为这样写评论(讨厌,我知道):

Remember that the & character has special meaning in xml (the start of an entity). You need to write your comment like this instead (annoying, I know):

/// <summary>
/// Initialises Drag &amp; Drop
/// </summary>
void initDragDrop()
{

}

在接下来的这一点上我可能是错的,但是我认为您甚至不能使用CDATA节来避免该实体,因为它破坏了注释.您必须输入整个&amp;实体.

I might be wrong on this next point, but I don't think you can even use a CDATA section to avoid the entity, because it breaks the comments. You must type out the entire &amp; entity.

这篇关于Visual Studio XML注释(摘要)和特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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