Skip to content

doc-returns-required

C#styleno fixdefault: offcsharp/stylecop

Reports a documented method or delegate that does not return void and has no <returns> (and no <inheritdoc />). Private members are not reported. No fix.

The summary says what a method does, and <returns> says what comes back, which a caller needs to use it right: units, meaning of null, which failure value.

To fix, add a <returns> that describes the value.

Reported
...
/// <summary>Returns.</summary>
public int NoReturns() => 0;
/// <summary>Returns.</summary>
...
/// <summary>Does.</summary>
public Task AsyncNoReturns() => null;
/// <summary>Does.</summary>
...
/// <summary>Does.</summary>
internal int InternalNoReturns() => 0;
/// <summary>Does.</summary>
protected int ProtectedNoReturns() => 0;
/// <summary>Does.</summary>
...
/// <summary>Delegate.</summary>
public delegate int Callback();
/// <summary>Delegate.</summary>
...
/// <summary>Does.</summary>
public ref int RefReturn() => throw null;
}
csharp:
lint:
rules:
doc-returns-required: warn # off (default), warn, error

Enabled by the presets: csharp/stylecop.

Suppress one line with sudsy-disable-next-line doc-returns-required in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
StyleCop SA1615 full