Bug Report T557130
Visible to All Users

Code Formatting - The Spacing options in Formatting have certain issues

created 7 years ago

Hi

I'm having issues with the new Formatting > Spacing options - as it is messing up some of my code now. I've gone through and identified which options:

NOTE - I believe some of the reasons is because I use TABS and not spaces - it seems to put spaces in the code instead of tabs.

Code as it should be:

C#
public static string GetHashSha256(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); var hashstring = new SHA256Managed(); byte[] hash = hashstring.ComputeHash(bytes); return GetStringFromHash(hash); }

Issue #1

Option ticked>>> C#>Formatting>Spacing> "Statement" - this turned on, but no sub options ticked produces this code:

C#
public static string GetHashSha256(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); var hashstring = new SHA256Managed(); byte[] hash = hashstring.ComputeHash(bytes); return GetStringFromHash(hash); }

Notice the bottom 4 lines are all to the left - and have SPACES in front of them, though the correct number of spaces, strange how the first 3 lines are not.

Issue #2

Option ticked>>> C#>Formatting>Spacing> "Parameters" - this turned on, but only default sub options ticked produces this code:

C#
public static string GetHashSha256(string text){ byte[] bytes = Encoding.UTF8.GetBytes(text); var hashstring = new SHA256Managed(); byte[] hash = hashstring.ComputeHash(bytes); return GetStringFromHash(hash); }

Notice the opening curly brace is now on the same line as the method - I like to have mine on the line below and the formatting is changing this and ignoring my VS setting.

That's it for now - it's only tested on a small cs file I've looked at, but will report any others I spot!

Disabling the two options "Statements, Parameters" solves it for now.

Thanks

Show previous comments (4)
AE AE
Alex Eg (DevExpress) 7 years ago

    Thank you, Alan.
    We appreciate your willing to help us make CRR better. I uploaded the hotfix in the ticket and we will be happy to hear your feedback!

    AM AM
    Alan Middleton999 7 years ago

      Hi Alex,

      I've installed and HF and the above 3 issues have been fixed… BUT a NEW one has been introduced.

      It's on the Formatting>Spacing>Statement option – when this is turned ON the below issue happens… The comment line in the code below is duplicated each time the code cleanup button is pressed. So before it has one line, then after 3 presses it looks like the after section:

      NOTE - this happens if i have either Spaces or Tabs selected for indenting.

      BEFORE:

      C#
      public static string GetHashSha256(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); var hashstring = new SHA256Managed(); // a comment byte[] hash = hashstring.ComputeHash(bytes); return GetStringFromHash(hash); }

      AFTER 3 cleanup clicks:

      C#
      public static string GetHashSha256(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); var hashstring = new SHA256Managed(); // a comment // a comment // a comment // a comment // a comment // a comment // a comment // a comment byte[] hash = hashstring.ComputeHash(bytes); return GetStringFromHash(hash); }

      This is only 3 clicks on the code cleanup button I have in the tool bar (I have to always click it 3 times to do a full clean up of the file.

      For now, I have to leave the "Statement" option unchecked due to this.

      AE AE
      Alex Eg (DevExpress) 7 years ago

        Alan,
        Thank you for testing the hotfix and providing your feedback!
        I've created a separate ticket on your behalf (Formatting - Comments are duplicated when spacing options are used). It has been placed in our processing queue and will be answered shortly.

        Answers approved by DevExpress Support

        created 7 years ago (modified 7 years ago)

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          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.