1

I would like resharper to indent my code the following way:

var modification = shortUrlIndexCollection.FindAndModify
(
    Query.Or
    (
        Query.And
        (
            Query.EQ("_id", "Index"),
            Query.EQ("LockId", Guid.Empty)
        ),
        Query.LT("UnlockOn", now)
    ),
    SortBy
        .Null,
    Update
        .Set("LockId", guid)
        .Set("UnlockOn", now + reserveDuration),
    true
);

But instead it formats my code the following way:

var modification = shortUrlIndexCollection.FindAndModify
    (
        Query.Or
            (
                Query.And
                    (
                        Query.EQ("_id", "Index"),
                        Query.EQ("LockId", Guid.Empty)
                    ),
                Query.LT("UnlockOn", now)
            ),
        SortBy
            .Null,
        Update
            .Set("LockId", guid)
            .Set("UnlockOn", now + reserveDuration),
        true
    );

According to Custom Brace formatting with Resharper I have already tried the continuous line indent multiplier option, but it gives wrong results...

Community
  • 1
  • 1
Lu4
  • 14,873
  • 15
  • 79
  • 132
  • Have you tried Open ReSharper > Options > [Your language] > Formatting style > Other and try playing with options in sections called "Indentation" and "Other" – Greg Oks Nov 14 '12 at 21:16
  • I've tried inverting every possible switch in every category separately just to find out the setting that affects this indentation problem, as far as I found `continuous line indent multiplier` changes behaviour but doesn't help... – Lu4 Nov 14 '12 at 21:34

2 Answers2

4

Try Resharper 7.1 it has fixed the indenting of chained methods.

Just tryed it with my stylecop settings and the formatting becomes:

shortUrlIndexCollection.FindAndModify(
                Query.Or(
                    Query.And(Query.EQ("_id", "Index"), Query.EQ("LockId", Guid.Empty)), Query.LT("UnlockOn", now)),
                SortBy.Null,
                Update.Set("LockId", guid).Set("UnlockOn", now + reserveDuration),
                true);

Not what you want.

KeesDijk
  • 2,299
  • 1
  • 24
  • 37
2

There is no way to format ( and ) the way you want it in ReSharper 7.1 or lower. We're working on implementing a new indenting system in 8.0, which would give you a better control on layout of () and [].

Dmitry Osinovskiy
  • 9,999
  • 1
  • 47
  • 38