Bug Report T374044
Visible to All Users

Organize Members - Redundant line breaks remain after applying

created 9 years ago

I'm trying to get CodeRush for Roslyn configured such that whitespace is normalized / cleaned up after running Code Cleanup.

My desired outcome is that every member in the entire class has exactly one blank line between it and the next member. Also, there should be no whitespace after opening a class / namespace or before closing it.

Unfortunately, I'm unable to figure out the right combination of settings to make that happen.

For example, starting with this code…

C#
using System; using System.Linq; using Microsoft.AspNet.Mvc; namespace MyProject.Controllers { public class KeysController : Controller { [Route("api/keys")] [HttpGet] public IActionResult GetKeys() { throw new NotImplementedException(); } [Route("api/keys/{id}")] [HttpGet] public IActionResult GetKey(int id) { throw new NotImplementedException(); } } }

Notice the whitespace above and below the "GetKeys" method.

After running code cleanup, what I want it to look like is this:

C#
using System; using System.Linq; using Microsoft.AspNet.Mvc; namespace MyProject.Controllers { public class KeysController : Controller { [Route("api/keys/{id}")] [HttpGet] public IActionResult GetKey(int id) { throw new NotImplementedException(); } [Route("api/keys")] [HttpGet] public IActionResult GetKeys() { throw new NotImplementedException(); } } }

What it actually looks like is this:

C#
using System; using System.Linq; using Microsoft.AspNet.Mvc; namespace MyProject.Controllers { public class KeysController : Controller { [Route("api/keys/{id}")] [HttpGet] public IActionResult GetKey(int id) { throw new NotImplementedException(); } [Route("api/keys")] [HttpGet] public IActionResult GetKeys() { throw new NotImplementedException(); } } }

My "organize members" settings are as follows:

* Rules scheme = StyleCop
* Empty line count between groups = 1
* Remove existing line breaks = checked
* Skip initialized fields = unchecked
* All default rules listed have the "Empty line count between members" value set to 1. (That's the only change.)

My "code cleanup" settings have the following items checked:

* Organize members
* Remove all regions
* Remove unused namespace references
* Sort namespace references
* Use 'nameof'
* Remove redundant type cast
* Force braces in statements
* Remove unused variables
* Remove redundant braces in statements
* Apply variable declaration style
* Apply built-in type style
* Apply 'this' qualifier style
* Apply visibility style

Let me know if there's something I'm missing to get the desired result. Thanks!

Comments (1)
DevExpress Support Team 9 years ago

    Hi Travis,

    Thank you for providing the code sample and your Organize Members and Code Cleanup settings. I have reproduced this issue with remaining redundant line breaks after applying the Code Cleanup feature. We are working on it and will notify you when we have any results.

    Answers approved by DevExpress Support

    created 9 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.