I have this:
/// <summary>
/// Foo
/// </summary>
/// <seealso href="https://www.example.com/foo?q=bar&qux=2"/>
That gives:
XML comment has badly formed XML -- 'Reference to undefined entity 'qux'.' csharp(CS1570)
The problem is the &
is invalid XML.
Workarounds:
&
to &
#pragma warning disable CS1570
<NoWarn>1570</NoWarn>
&
with &
These are non ideal and a waste of time - I just want to paste my URLs into the code and move on.
Is it possible to configure the analyzer to allow ampersands?
While you could disable this warning by adding <NoWarn>1570</NoWarn>
to your .csproj file, this is also not an ideal solution, as the compiler will ignore documentation comments that have invalid XML - such comments will not be included in the compiler's XML output, and will not show up in tooltips in IDEs.
The best solution, if you are pasting a lot of URLs into your comments and don't want to fix them yourself, would be to do a find-and-replace on your source files to fix the invalid &s to &
. This could be done as a pre-build event so that it runs before every build.