Skip to main content

CSENSE002-005: Parameter and Type Parameter Rules

These diagnostics ensure that parameter and type parameter documentation is accurate, complete, and synchronized with the actual method or type signature.

CSENSE002: Missing Parameter Documentation

ID
string
default:"CSENSE002"
The diagnostic identifier
Category
string
default:"Documentation"
The diagnostic category
Severity
DiagnosticSeverity
default:"Warning"
The default severity level
Enabled by Default
boolean
default:"true"
Whether this rule is enabled by default

Description

All parameters of a publicly accessible member should be documented. This diagnostic is reported when a parameter exists in the method signature but is not documented with a <param> tag.

Examples

Violation

/// <summary>
/// Calculates the total price.
/// </summary>
/// <param name="quantity">The quantity of items.</param>
public decimal CalculateTotal(int quantity, decimal unitPrice)
// CSENSE002: The parameter 'unitPrice' is missing documentation
{
    return quantity * unitPrice;
}

Fixed

/// <summary>
/// Calculates the total price.
/// </summary>
/// <param name="quantity">The quantity of items.</param>
/// <param name="unitPrice">The price per unit.</param>
public decimal CalculateTotal(int quantity, decimal unitPrice)
{
    return quantity * unitPrice;
}

CSENSE003: Stray Parameter Documentation

ID
string
default:"CSENSE003"
The diagnostic identifier
Category
string
default:"Documentation"
The diagnostic category
Severity
DiagnosticSeverity
default:"Warning"
The default severity level
Enabled by Default
boolean
default:"true"
Whether this rule is enabled by default

Description

Documentation should not contain <param> tags for parameters that do not exist in the signature. This often occurs after refactoring when a parameter is renamed or removed but the documentation is not updated.

Examples

Violation

/// <summary>
/// Processes a user request.
/// </summary>
/// <param name="userId">The user identifier.</param>
public void ProcessRequest(string username)
// CSENSE003: The parameter 'userId' is misplaced or does not exist in the signature
{
    // Implementation
}

Fixed

/// <summary>
/// Processes a user request.
/// </summary>
/// <param name="username">The username.</param>
public void ProcessRequest(string username)
{
    // Implementation
}

CSENSE004: Missing Type Parameter Documentation

ID
string
default:"CSENSE004"
The diagnostic identifier
Category
string
default:"Documentation"
The diagnostic category
Severity
DiagnosticSeverity
default:"Warning"
The default severity level
Enabled by Default
boolean
default:"true"
Whether this rule is enabled by default

Description

All type parameters of a publicly accessible member should be documented. This diagnostic is reported when a type parameter exists but is not documented with a <typeparam> tag.

Examples

Violation

/// <summary>
/// Converts an item from one type to another.
/// </summary>
/// <typeparam name="TInput">The input type.</typeparam>
public TOutput Convert<TInput, TOutput>(TInput value)
// CSENSE004: The type parameter 'TOutput' is missing documentation
{
    // Implementation
}

Fixed

/// <summary>
/// Converts an item from one type to another.
/// </summary>
/// <typeparam name="TInput">The input type.</typeparam>
/// <typeparam name="TOutput">The output type.</typeparam>
public TOutput Convert<TInput, TOutput>(TInput value)
{
    // Implementation
}

CSENSE005: Stray Type Parameter Documentation

ID
string
default:"CSENSE005"
The diagnostic identifier
Category
string
default:"Documentation"
The diagnostic category
Severity
DiagnosticSeverity
default:"Warning"
The default severity level
Enabled by Default
boolean
default:"true"
Whether this rule is enabled by default

Description

Documentation should not contain <typeparam> tags for type parameters that do not exist in the signature. This often occurs after refactoring when a type parameter is renamed or removed.

Examples

Violation

/// <summary>
/// A generic repository.
/// </summary>
/// <typeparam name="T">The entity type.</typeparam>
/// <typeparam name="TKey">The key type.</typeparam>
public class Repository<TEntity>
// CSENSE005: The type parameter 'T' is misplaced or does not exist in the signature
// CSENSE005: The type parameter 'TKey' is misplaced or does not exist in the signature
{
    // Implementation
}

Fixed

/// <summary>
/// A generic repository.
/// </summary>
/// <typeparam name="TEntity">The entity type.</typeparam>
public class Repository<TEntity>
{
    // Implementation
}

Configuration

These rules respect the visibility_level setting to determine which members are analyzed:
comment_sense.visibility_level = protected
See Configuration Options Reference for more details.

Build docs developers (and LLMs) love