RCS1181 code fix can produce code with CS1570 (XML comment has badly formed XML)
Bergam64 opened this issue · 0 comments
Bergam64 commented
Product and Version Used:
VS extension Roslynator 2022 v4.12.5
Steps to Reproduce:
- Enable
RCS1181
in your.editorconfig
file (disabled by default). - Make sure the containing project is configured to generate documentation files:
- Open project Properties.
- Go to page Build -> Output
-
- Generate a file containing API documentation
- Open a C# file and add a comment after a property. The comment must contain at least 1
<
or&
.
Actual Behavior:
namespace MyNamespace
{
/// <summary>
/// ...
/// </summary>
public class Class1
{
internal int MyProperty { get; set; } // Must be >= 0 & <= 5. <-- RCS1181: Convert comment to documentation comment
}
}
Applying code fix produces this:
namespace MyNamespace
{
/// <summary>
/// ...
/// </summary>
public class Class1
{
/// <summary>
/// Must be >= 0 & <= 5. <-- CS1570 is reported 3 times here!
/// </summary>
internal int MyProperty { get; set; }
}
}
In this example, compiler errors are:
- CS1570: XML comment has badly formed XML -- 'Whitespace is not allowed at this location.'
- CS1570: XML comment has badly formed XML -- 'An identifier was expected.'
- CS1570: XML comment has badly formed XML -- 'The character(s) '=' cannot be used at this location.'
Expected Behavior:
namespace MyNamespace
{
/// <summary>
/// ...
/// </summary>
public class Class1
{
/// <summary>
/// Must be >= 0 & <= 5.
/// </summary>
internal int MyProperty { get; set; }
}
}
Note that encoding other XML special chars (>
, "
and '
) is not required (at least for Visual Studio 2022) and doing so would produce source XML comments that are more complex to read (for developers) than needed.
Bottom line: RCS1181
should replace <
with <
and &
with &
(but IMHO leave >
, "
and '
unchanged).