Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCS1181 wrongly considers that namespaces can have XML comments #1525

Closed
Bergam64 opened this issue Sep 16, 2024 · 0 comments · Fixed by #1526
Closed

RCS1181 wrongly considers that namespaces can have XML comments #1525

Bergam64 opened this issue Sep 16, 2024 · 0 comments · Fixed by #1526
Assignees

Comments

@Bergam64
Copy link

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 the namespace.

Actual Behavior:

namespace MyNamespace // Some comment. <-- RCS1181: Convert comment to documentation comment
{
    /// <summary>
    /// ...
    /// </summary>
    public class Class1
    {
        internal int MyProperty { get; set; }
    }
}

which is wrong, because applying the code fix produces code that triggers a compiler error:

/// <summary> <-- CS1587: XML comment is not placed on a valid language element
/// Some comment.
/// </summary>
namespace MyNamespace
{
    /// <summary>
    /// ...
    /// </summary>
    public class Class1
    {
        internal int MyProperty { get; set; }
    }
}

Expected Behavior:

namespace MyNamespace // Comment. <-- No RCS1181
{
    /// <summary>
    /// ...
    /// </summary>
    public class Class1
    {
        internal int MyProperty { get; set; }
    }
}

You can't add documentation comments to a namespace (see first table here).

Bottom line: RCS1181 should never be reported for comments on namespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants