wraith
wraith

Reputation: 401

C# xml documentation error

I am trying to add documentation to my C# code. But the following gives me a malformed xml error. I know that the error is because of 'List"Display"'. It's trying to find "/Display". But there won't be a "/Display" because it's a part of my code example. Can someone help me with this? Thank you.

    /// <summary>
    ///   Retrieves a list of <c>Display</c>
    /// </summary>
    /// <example>
    ///   <code>
    ///     List<Display> templates = DisplayManager.GetDisplays();
    ///   </code>
    /// </example>

Upvotes: 2

Views: 201

Answers (3)

Fredrik M&#246;rk
Fredrik M&#246;rk

Reputation: 158289

It's quite common to write List{Display} in XML documentation.

Upvotes: 2

pollirrata
pollirrata

Reputation: 5286

Try wrapping yout code content within CDATA

<![CDATA[List<Display> templates = DisplayManager.GetDisplays();]]>

All text in an XML document will be parsed by the parser.

But text inside a CDATA section will be ignored by the parser.

Upvotes: 1

D Stanley
D Stanley

Reputation: 152501

Wrap your code in a CDATA block:

///   <code>
///     <![CDATA[
///     List<Display> templates = DisplayManager.GetDisplays();
///     ]]>
///   </code>

or encode the angle brackets:

///   <code>
///     List&lt;Display&gt; templates = DisplayManager.GetDisplays();
///   </code>

Upvotes: 3

Related Questions