Rider incorrectly reports Syntax error for valid XML doc constructor cref references (#ctor)
Rider marks the XML doc comment itself as invalid.
public sealed class Class1
{
public Class1() { }
}
internal static class ClassDocs
{
/// <summary>
/// Dispose a Instance of <see cref="Class1"/>.
/// </summary>
/// <seealso cref="Class1.#ctor"/>
public static extern void Dispose();
}
Rider highlights:
#ctor
with:
Syntax error
The same happens with qualified members:/// <seealso cref="M:Class1.#ctor"/>
Rider should accept constructor references using:#ctor#ctor(System.Int32,System.String)
Please sign in to leave a comment.
Hello Cig,
This is a valid warning, not a false-positive.
The goal of writing xml documentation is to generate xml documentation. Once you enable “<GenerateDocumentationFile>true</GenerateDocumentationFile>” in .csproj file, you will start getting compiler warnings like this:
The syntax you provided
M:Class1.#ctoris the resulting string ID produced in the xml documentation file output, but you shouldn't use this for documenting purpose ‘on frontend’ (when writing .cs). Such a syntax isn't valid.I wasn't able to find exactly statement prohibiting that, but I assume we can trust compiler here. And I found this:
The
crefattribute can be attached to any tag to provide a reference to a code element. The documentation generator must verify that this code element exists. If the verification fails, the documentation generator issues a warning. When looking for a name described in acrefattribute, the documentation generator must respect namespace visibility according to using statements appearing within the source code.oiAnd if you add “<TreatWarningsAsErrors>true</TreatWarningsAsErrors>” the project will fail to build:
Hope that helps. Have a nice day!