Skip to content

BRO1602: Single-line comments should not use documentation style slashes

A comment that doesn't document a type or member uses //, not ///. Replaces StyleCop SA1626.

Example

Before

public class Totals
{
    public int Sum(int[] values)
    {
        /// Start from zero.
        var sum = 0;
        foreach (var value in values)
        {
            sum += value;
        }

        return sum;
    }
}

After

public class Totals
{
    public int Sum(int[] values)
    {
        // Start from zero.
        var sum = 0;
        foreach (var value in values)
        {
            sum += value;
        }

        return sum;
    }
}

Why

/// starts XML documentation. Inside a method it documents nothing, and the compiler warns about it (CS1587) when the project generates documentation.

How the fix works

Each line's /// becomes //. When text follows the slashes directly (///note), a space is added (// note), so the comment also satisfies BRO1002. //// (commented-out code) isn't a documentation comment and isn't reported.

Compared with StyleCop

Same results as StyleCop.