How do I comment a publicly visible type Enum?

C#EnumsComments

C# Problem Overview


How do I comment this Enum so that the warning does not appear? Yes I realize that comments are unnecessary, but if commenting is easy and it resolves the warnings then I'd like to do it.

Warnings that appear: Missing XML comment for publicly visible type or member

/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
    Equal,
    NotEqual,
    GreaterThan,
    GreaterThanOrEqual,
    LessThan,
    LessThanOrEqual
}

C# Solutions


Solution 1 - C#

Like this:

/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
    ///<summary>A == B</summary>
    Equal,
    ///<summary>A != B</summary>
    NotEqual,
    ///<summary>A > B</summary>
    GreaterThan,
    ///<summary>A >= B</summary>
    GreaterThanOrEqual,
    ///<summary>A < B</summary>
    LessThan,
    ///<summary>A <= B</summary>
    LessThanOrEqual
}

(Yes, this can get very tedious)

You may want to use different texts in the comments.

By the way. your enum should actually be called ComparisonType.

Solution 2 - C#

Comment each member:

/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
    /// <summary>
    /// Tests for equality
    /// </summary>
    Equal,
    /// <summary>
    /// Tests for inequality
    /// </summary>
    NotEqual,
    // etc..
}

You may also want to check out GhostDoc for easy commenting

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEricView Question on Stackoverflow
Solution 1 - C#SLaksView Answer on Stackoverflow
Solution 2 - C#Willem van RumptView Answer on Stackoverflow