This rule warns when XML documentation parsing is disabled for the project. CommentSense relies on the compiler’s documentation parsing to analyze your code.
// Class without documentationpublic class MyClass // CSENSE001{}// Method without documentation/// <summary>A documented class.</summary>public class MyClass{ public void MyMethod() // CSENSE001 { }}// Property without documentation/// <summary>A documented class.</summary>public class MyClass{ public int MyProperty { get; set; } // CSENSE001}// Using <inheritdoc /> on a member that doesn't inherit/// <summary>A documented class.</summary>public class MyClass{ /// <inheritdoc /> public void MyMethod() // CSENSE001 - not overriding anything { }}
Correct examples
/// <summary>A documented class.</summary>public class MyClass{ /// <summary>A documented method.</summary> public void MyMethod() { } /// <summary>A documented property.</summary> /// <value>The property value.</value> public int MyProperty { get; set; } /// <summary>A documented field.</summary> public int MyField;}
/// <summary>/// See <see cref="UnresolvedType"/> // CSENSE007/// </summary>public class MyClass{}/// <summary>A documented class.</summary>public class MyClass{ /// <summary> /// See <see cref="NonExistentMethod"/> // CSENSE007 /// </summary> public void MyMethod() { }}
Correct examples
/// <summary>/// See <see cref="MyClass"/>/// See <see cref="System.String"/>/// See <see cref="MyMethod"/>/// </summary>public class MyClass{ /// <summary>A documented method.</summary> public void MyMethod() { }}
/// <summary>MyClass</summary> // CSENSE016 - repeats member namepublic class MyClass{}/// <summary>A class.</summary>public class MyClass{ /// <summary>a method</summary> // CSENSE016 - not capitalized public void MyMethod() { } /// <summary>A method</summary> // CSENSE016 - no ending punctuation public void AnotherMethod() { } /// <summary></summary> // CSENSE016 - empty public void YetAnotherMethod() { } /// <summary>TODO: Add description</summary> // CSENSE016 - contains low-quality term public void IncompleteMethod() { } /// <summary>Returns an integer.</summary> /// <param name="value">value</param> // CSENSE016 - repeats parameter name public void SetValue(int value) { }}
Correct examples
/// <summary>Represents a user account.</summary>public class MyClass{ /// <summary>Processes the user's data.</summary> public void MyMethod() { } /// <summary>Gets or sets the user's age.</summary> /// <param name="value">The new age value in years.</param> public void SetValue(int value) { }}
[*.cs]# Comma-separated list of terms (case-insensitive)comment_sense.low_quality_terms = TODO, TBD, FixMe, None, N/A
Minimum summary length
[*.cs]# Minimum length for summary text (excluding trailing punctuation and whitespace)comment_sense.min_summary_length = 10
Ending punctuation
[*.cs]# Whether to require summaries to end with punctuation (. ! ?)comment_sense.require_ending_punctuation = true
Capitalization
[*.cs]# Whether to require documentation to start with a capital lettercomment_sense.require_capitalization = true
Similarity threshold
[*.cs]# Threshold (0.0 to 1.0) for similarity between documentation and member name.# Setting this to 0.0 (default) disables similarity analysis.# A value of 1.0 only flags documentation identical to the symbol name.# Recommended: 0.7 to 0.8comment_sense.similarity_threshold = 0.8
[*.cs]# By default, overriding/implementing members can implicitly inherit documentation.# Set to false to require explicit <inheritdoc /> or other documentation.comment_sense.allow_implicit_inheritdoc = false
By default, CommentSense allows implicit documentation inheritance for overriding/implementing members. Set allow_implicit_inheritdoc = false only if you want to enforce explicit <inheritdoc /> tags.
/// <summary>Returns true if successful.</summary> // CSENSE019 on "true"public class MyClass{}/// <summary>Returns null if not found.</summary> // CSENSE019 on "null"public class AnotherClass{}/// <summary>This method returns void.</summary> // CSENSE019 on "void"public class YetAnotherClass{}
Correct examples
/// <summary>Returns <see langword="true"/> if successful.</summary>public class MyClass{}/// <summary>Returns <see langword="null"/> if not found.</summary>public class AnotherClass{}/// <summary>This method returns <see langword="void"/>.</summary>public class YetAnotherClass{}
/// <summary>A class.</summary>public class MyClass{ /// <summary>A method.</summary> /// <remarks>Additional remarks about the method.</remarks> public void MyMethod() { }}
/// <summary>A class.</summary>public class MyClass{ /// <returns>An integer.</returns> // CSENSE024 - should come after <summary> /// <summary>A method.</summary> /// <param name="value">The value.</param> public int MyMethod(int value) { return value; }}
Correct example
/// <summary>A class.</summary>public class MyClass{ /// <summary>A method.</summary> /// <param name="value">The value.</param> /// <returns>An integer.</returns> public int MyMethod(int value) { return value; }}
[*.cs]# Comma-separated list of tag names in their desired order.# Default: inheritdoc, summary, typeparam, param, returns, value, exception, remarks, example, seealso, permissioncomment_sense.tag_order = inheritdoc, summary, param, returns, exception, remarks
Flags cref attributes that point to symbols with lower accessibility than the member being documented (e.g., a public member pointing to an internal type).
internal class InternalHelper{}/// <summary>/// Uses <see cref="InternalHelper"/>. // CSENSE025 - public member referencing internal type/// </summary>public class MyClass{}
Correct example
/// <summary>A public helper class.</summary>public class PublicHelper{}/// <summary>/// Uses <see cref="PublicHelper"/>./// </summary>public class MyClass{}