C# - Asserting Two Objects Are Equal in Unit Tests

Resharper fluent interface code formatting (align to the dot)

I'm using next settings in R# in Options -> Code Editing -> C# -> Formatting Style:

Line Breaks and Wrapping -> Arrangement of Member Access Expressions section -> Wrap chained method calls == Chop always

Tabs, Indents, Alignment -> Align Multiple Constructs section -> Chained method calls checked

Result:

enter image description here

Based on https://blog.jetbrains.com/dotnet/2012/11/12/code-formatting-improvements-in-resharper-71/ . Path for Chained method calls was is some version between 7.1 and R# 2018

ReSharper: formatting of delegates

ReSharper -> Options -> C# -> Formatting Style -> Braces Layout -> Anonymous method declaration

Set to "At next line (BSD style)"

ReSharper -> Options -> C# -> Formatting Style -> Other -> Align Multiline Constructs

Uncheck "Call Arguments" and you'll get what you're looking for.

Resharper formatting chained method

With Resharper 7.1.2, you can get the following formatting:

var foo = new FooDataBuilder().WithDate(myDate)
.WithBar(myBar)
.Build();

By setting the following Resharper options:

Code Editing->C#->Formatting Style->Line Breaks and Wrapping->Line Wrapping->Wrap chained method calls to Chop always

and

enable Code Editing->C#->Formatting Style->Other->Align Multiline Constructs->Chained method calls

I don't think you can align with FooDataBuilder() unless you do it manually. (This has been confirmed by @Dmitry Osinovskiy from Jetbrains so this may be the closest you're going to get to what you want.)

Formatting code into a single line using ReSharper

Use Line Breaks and WrappingPreserve Existing FormattingKeep existing line breaks.

Is there a way to keep ReSharper from formatting a region of code

I had a discussion with Resharper support about this, their answer:

Thank you very much for this information! We will discuss if we can
support such formatting style in one of the future versions.

Prevent ReSharper from formatting specific code block

At the moment this is not possible. See feature request RSRP-187963.

As a workaround, if you have a big chunk of "pre-formatted" code, you could move it to an own (partial class) file and add it to the "Generated Code" configuration list. This disables R#'s "Code Cleanup" for this file. Note that it also disables the inspections! (Unfortunately the "Generated Code Region" feature only disables the inspections, not the "Code Cleanup" for a region, as of R# version 9.2.)



Related Topics



Leave a reply



Submit