Formatting fluent API

When I use a code refactoring, Rider insists on reformatting my code too. Is it possible either to not reformat code when doing a refactoring (such as file-scoped namespaces in project), or else, is it possible to format fluent API the way I like it? Instead I end up with 100+ files all with messed up fluent API calls.

Specifically, I would like my fluent API calls to look like this:

FluentAPI
.Start()
.DoSomething(x)
.DoSomethingElse(y);

Instead, Rider makes it like this which I do not want:

FluentAPI
   .Start()
   .DoSomething(x)
   .DoSomethingElse(y);

Thanks

0
5 comments

Hello Dave Cousineau ,

Thank you for reporting the issue. Unfortunately at the moment there is no way to format Fluen API this way. I have created a corresponding record on our bug tracker: RSRP-494152. The issue is handled by a dedicated developer there. Please upvote it and click Watch to monitor the progress of the issue.

Let me know if you have any further questions. Have a good day!

0

Thanks. I've been thinking about this, and while I would like the formatting option, what I would also like maybe even more is to be able to perform the refactoring without reformatting. Is this possible? It will probably never be the case that Rider will format my code 100% as I want it. There are all kind of other ways that the auto-formatting gets things wrong. The indenting on fluent-api is just the major one. Really what would have been better is if I could have done the namespace refactoring and not reformatted every single file in my solution.

Thanks

0

Dave Cousineau  "Refactoring without reformatting" is a topic that is too generic. In most situations, you can configure format settings to avoid conflicts with code refactoring.

You could specify your needs, such as configuring Fluent API format settings. I will check if Rider has corresponding format settings.

0

it's kind of too late anyway. I already ran “apply file-scoped namespaces in solution” and now I have thousands of source files with messed up indenting. I'm just stuck fixing them bit-by-bit day-by-day as I encounter them.

0

Dave Cousineau You can create support request in IDE directly, so that we could notice your reply timely. In Help | Contact Support, you can create support request there.

Here is a tip that could help you recognize the code style settings in editor: select your code, press Alt + Enter to trigger Context Menu, then select Detect code style settings to adjust your format settings there.

0

Please sign in to leave a comment.