Bug Report T1032757
Visible to All Users

Formatting - An XML document comment is incorrectly indented if a member is wrapped in directives

created 3 years ago

Hello DevExpress Team.

We use CodeRush in our team and have located a small problem with the code cleanup.

Given we have the following code:

Example 1:

C#
/// <summary> /// Some comment. /// </summary> #pragma warning disable CS0618 // Reason: Legacy code public class AClass : AnObsoleteClass #pragma warning restore CS0618

Everything is fine here, we want the indentation of the comment to be on the same level as the class it belongs to. Sadly, if we run the cleanup now, the following happens:

Example 2:

C#
/// <summary> /// Some comment. /// </summary> #pragma warning disable CS0618 // Reason: Legacy code public class AClass : AnObsoleteClass #pragma warning restore CS0618

The second and third line are indented to match the pragma now. New cleanup-runs don't change the code further.

If we remove the indentation on the first line too:

Example 3:

C#
/// <summary> /// Some comment. /// </summary> #pragma warning disable CS0618 // Reason: Legacy code public class AClass : AnObsoleteClass #pragma warning restore CS0618

And run code cleanup now, it is formatted back to match example 1, before the next run of cleanup formats the code to example 2.

The expected results would be:

  1. Code cleanup on example 1 doesn't change anything.
  2. Code cleanup on example 2 changes the code to example 1.
  3. Code cleanup on example 3 changes the code to example 1. (This is given at the moment)

Could you please look into this?

Thanks a lot and have a nice day,

Michael

Comments (3)
DevExpress Support Team 3 years ago

    Hi Michael,

    Thank you for your report. I have reproduced this issue locally. We need to research the possibility of fixing it and will then inform you about our results.
    As a workaround I recommend that you change your code like this:

    C#
    #pragma warning disable CS0618 // Reason: Legacy code /// <summary> /// Some comment. /// </summary> public class AClass : AnObsoleteClass { } #pragma warning restore CS0618
    MB MB
    Michael Breunig 3 years ago

      Hi Andrew,

      thanks for the fast answer and your help!

      I'm looking forward to the result of your research.

      Have a nice weekend,

      Michael

      DevExpress Support Team 3 years ago

        Hi Michael,

        We are here to help you. We will definitely inform you about our results.

        Have a nice weekend too.

        Answers approved by DevExpress Support

        created 3 years ago

        We have addressed the issue described in this ticket and will include a fix in our next maintenance update. Should you need to apply our fix prior to official release, you can request a hotfix here.

        Note: Hotfixes may be unavailable for betas/updates set for release within a week.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.