如何正确地逃避<code> example in Xml documentation?

时间:2015-10-29 15:40:55

标签: c# .net vb.net documentation documentation-generation

Which would be the way to escape VB's and C-Sharp illegal characters like <>& in a <code> tag of .Net Xml documentation?.

In this example below, Intellisense highlights the > character because I need to escape it, it says the code will not be included when generating the documentation because that reason.

''' ------------------------------------------------------------------------
''' <summary>
''' </summary>
''' ------------------------------------------------------------------------
''' <example> This is a code example.
''' <code>
''' 
''' Dim currentPosition As Long = CLng(player.Position.TotalMilliseconds)
''' 
''' If Not ((currentPosition + 5000) >= player.Length) Then
'''    player.Seek(currentPosition + 5000)
''' End If
''' 
''' </code>
''' </example>
''' ------------------------------------------------------------------------
Sub Something
End Sub

Then, how I should escape the code content?.

I have the doubt because the content of <code> tag is treated as literal text, then if I add a CDATA tag to avoid an IntelliSense error what will happens when I'll generate the Chm/Html file with that documentation?, I mean the CDATA markup symbols will be represented as liter text in the code example causing residuous in this way, or what?.

Someone could provide an example to do things right?.

1 个答案:

答案 0 :(得分:2)

您需要使用与普通XML(或HTML)文档(see here)相同类型的转义来获取更多信息。

&替换为&amp;<替换为&lt;>替换为&gt;。您可能需要注意的另一个是引用字符。 "替换为&quot;