Ticket T270126
Visible to All Users

CodeRush C# Document Formatter - Looking for specific formatting option

created 10 years ago (modified 10 years ago)
C#

I recently upgraded to VS 2015, and 2015's C# formatting rules changed and don't support the formatting options I want, in so many ways. So I decided that since I have CodeRush and I use it all the time, that I'd switch to use its code formatter. I have it all working wonderfully, except for a couple of things that appear to be missing options. I've checked Resharper, and it has these options available.

Here are the ones that I would use all the time:

First, object initializers with indented braces, followed by indented property initializers. I can get everything except the braces to indent. This is what I want:

C#
MyObject myObject = new MyObject { MyProperty1 = "Foo", MyProperty2 = "Bar", };

This is what I can get:

C#
MyObject myObject = new MyObject { MyProperty1 = "Foo", MyProperty2 = "Bar", };

Next is method chaining, for LINQ. I want all of the chaining to be indented. But I can't figure out the option to make chains indent. What I want:

C#
MyObject[] results = foo .Where(f => f.MyValue == GoodDeal) .Select(f => f.ToMyObject()) .ToArray();

What I can get:

C#
MyObject[] results = foo .Where(f => f.MyValue == GoodDeal) .Select(f => f.ToMyObject()) .ToArray();

Finally, when I create anonymous method calls inside of other stuff, I want the braces to indent. So, what I want:

C#
MyObject[] results = foo .Where(f => f.MyValue == GoodDeal) .Select(f => { // Do something with multiple lines here Bar bar = f.CalculateBar(); if (bar.IsValid) return new MyObjectBar(bar); return f.ToMyObject(); }) .ToArray();

vs. what I get:

C#
MyObject[] results = foo .Where(f => f.MyValue == GoodDeal) .Select(f => { // Do something with multiple lines here Bar bar = f.CalculateBar(); if (bar.IsValid) return new MyObjectBar(bar); return f.ToMyObject(); }) .ToArray();

I was able to get all of these formatting rules set up within 5 minutes in Resharper on a co-worker's system.

Is there a way I can create custom formatters so that I don't have to wait for you guys to incorporate these formatters? I've noticed that lots of refactorings that didn't format properly when they were done DID format properly when I started using your formatters, so it would be great if I could just start using it. :) And the CodeRush formatter works better than the built-in one for me now.

Comments (1)
DevExpress Support Team 10 years ago

    Hi Jason,

    Thank you for using our product and for such detailed feedback on the formatting functionality.
    We've discussed your suggestions and think that both of them (indentation for braces and indentation for parts of query expressions) make a sense.
    We'll work to implement your suggestion regarding the indentation for braces and their contents, and will inform you when it is ready.
    We cannot, however, implement formatting of the query expressions fast. This functionality will require significant changes in the architecture of the product. So, I cannot promise you that we will do this in the nearest future. There is a chance, however, that we will change our plans.

    Thank you for your assistance.

    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.