Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include an html tag in a C# summary so that it is processed as text (not parsed as XML)?

I'm writing an HTML parser in C# and want to include examples of the HTML that it handles in the summary XML blocks. How do I prevent the < and > characters from messing up the auto-documentation of Visual Studio 2008?

example:

  /// <summary>
  /// Creates a FlowSegment based on an HTML code, i.e. <bold>
  /// </summary>
  /// <param name="code"></param>
  /// <returns></returns>
  public FlowSegment(string code)
  {

Unfortunately the example causes the tool tip for this constructor to display (in part):

XML comment includes invalid XML

instead of the summary comment.

How can I escape the < and > characters?

like image 748
Fred Avatar asked Jul 04 '09 22:07

Fred


1 Answers

The best solution I found was to change it so as to replace < with &lt; and > with &gt;

as found in the XML specifications.

That makes the example look as follows:

  /// <summary>
  /// Creates a FlowSegment based on an HTML code, i.e. &lt;bold&gt;
  /// </summary>
  /// <param name="code"></param>
  /// <returns></returns>
  public FlowSegment(string code)
  {

Which makes the desired tool-tip display properly.

like image 90
Fred Avatar answered Oct 05 '22 07:10

Fred